1
0
Fork 0
mirror of https://api.glitch.com/git/yaswvc synced 2026-01-12 05:28:10 +00:00

🎋🐲 Checkpoint

./public/main.js:5975361/1262
./views/index.ejs:5975361/235
This commit is contained in:
Glitch (peerjs-video) 2020-09-12 20:17:09 +00:00
parent ad8d5bbc75
commit 22fffe6960
2 changed files with 23 additions and 1 deletions

View file

@ -186,11 +186,31 @@ var app = new Vue({
this.attachSinkId(document.querySelector('#localVideo'), audioDestination); this.attachSinkId(document.querySelector('#localVideo'), audioDestination);
}, },
gotStream: function gotStream(stream) { gotStream: function gotStream(stream) {
console.log('gotStream', this.stream, stream);
if (this.stream) {
const oldVideo = this.stream.getTracks().find(track => track.kind === 'video');
this.stream.removeTrack(oldVideo);
this.stream.addTrack(stream);
} else {
this.stream = stream; // make stream available to console this.stream = stream; // make stream available to console
}
document.querySelector('#localVideo').srcObject = stream; document.querySelector('#localVideo').srcObject = stream;
// Refresh button list in case labels have become available // Refresh button list in case labels have become available
return navigator.mediaDevices.enumerateDevices(); return navigator.mediaDevices.enumerateDevices();
}, },
shareScreen: async function shareScreen() {
// if (!displayMediaStream) {
const displayMediaStream = await navigator.mediaDevices.getDisplayMedia();
// }
// senders.find(sender => sender.track.kind === 'video').replaceTrack(displayMediaStream.getTracks()[0]);
//show what you are showing in your "self-view" video.
// document.getElementById('self-view').srcObject = displayMediaStream;
//hide the share button and display the "stop-sharing" one
// document.getElementById('share-button').style.display = 'none';
// document.getElementById('stop-share-button').style.display = 'inline';
},
handleError: function handleError(error) { handleError: function handleError(error) {
console.log('navigator.MediaDevices.getUserMedia error: ', error.message, error.name); console.log('navigator.MediaDevices.getUserMedia error: ', error.message, error.name);
}, },

View file

@ -72,6 +72,8 @@
<label for="videoSource">Video source: </label> <label for="videoSource">Video source: </label>
<select id="videoSource" v-on:change="start" class="form-control"></select> <select id="videoSource" v-on:change="start" class="form-control"></select>
</div> </div>
<!-- share screen -->
<span class="btn btn-primary" v-on:click="shareScreen()">Share screen</span>
</details> </details>
</div> </div>
</div> </div>