Skip to content

Commit f00ac31

Browse files
authored
Unify API and add docs (#2)
1 parent eb774ad commit f00ac31

File tree

6 files changed

+530
-388
lines changed

6 files changed

+530
-388
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ module.exports = {
2929

3030
## Usage
3131

32-
`LiveExWebRTC` comes with two `Phoenix.LiveComponent`s:
32+
`LiveExWebRTC` comes with two `Phoenix.LiveView`s:
3333
* `LiveExWebRTC.Publisher` - sends audio and video via WebRTC from a web browser to a Phoenix app (browser publishes)
34-
* `LiveExWebRTC.Subscriber` - sends audio and video via WebRTC from a Phoenix app to a web browser (browser subscribes)
34+
* `LiveExWebRTC.Player` - sends audio and video via WebRTC from a Phoenix app to a web browser and plays it in the HTMLVideoElement (browser subscribes)
3535

36-
See module docs for more.
36+
See module docs and [live_broadcaster](https://github.com/elixir-webrtc/live_broadcaster) for more.
3737

3838
## Local development
3939

assets/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { createPublisherHook } from "./publisher.js";
2-
import { createSubscriberHook } from "./subscriber.js";
2+
import { createPlayerHook } from "./player.js";
33

4-
export { createPublisherHook, createSubscriberHook };
4+
export { createPublisherHook, createPlayerHook };

assets/subscriber.js renamed to assets/player.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function createSubscriberHook(iceServers = []) {
1+
export function createPlayerHook(iceServers = []) {
22
return {
33
async mounted() {
44
this.pc = new RTCPeerConnection({ iceServers: iceServers });
@@ -8,8 +8,9 @@ export function createSubscriberHook(iceServers = []) {
88
};
99

1010
this.pc.ontrack = (ev) => {
11-
console.log("ontrack");
12-
this.el.srcObject = ev.streams[0];
11+
if (!this.el.srcObject) {
12+
this.el.srcObject = ev.streams[0];
13+
}
1314
};
1415
this.pc.addTransceiver("audio", { direction: "recvonly" });
1516
this.pc.addTransceiver("video", { direction: "recvonly" });

0 commit comments

Comments
 (0)