mirror of
https://api.glitch.com/git/yaswvc
synced 2026-01-12 05:08:11 +00:00
🏗🌇 Checkpoint
./public/main.js:5975361/1661
This commit is contained in:
parent
809fa2bf48
commit
5fc7546f2c
1 changed files with 11 additions and 9 deletions
|
|
@ -3,7 +3,7 @@ var Peer = window.Peer;
|
||||||
var app = new Vue({
|
var app = new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
data: {
|
data: {
|
||||||
peer: new Peer({
|
peer: new Peer(localStorage.getItem('yaswvc-peerId'), {
|
||||||
host: '/',
|
host: '/',
|
||||||
path: '/peerjs/myapp'
|
path: '/peerjs/myapp'
|
||||||
}),
|
}),
|
||||||
|
|
@ -18,6 +18,14 @@ var app = new Vue({
|
||||||
renderVideo:function(stream, selector = '#remoteVideo') {
|
renderVideo:function(stream, selector = '#remoteVideo') {
|
||||||
document.querySelector(selector).srcObject = stream;
|
document.querySelector(selector).srcObject = stream;
|
||||||
},
|
},
|
||||||
|
// createPeer: function() {
|
||||||
|
// const peer = new Peer(localStorage.getItem('yaswvc-peerId'), {
|
||||||
|
// host: '/',
|
||||||
|
// path: '/peerjs/myapp'
|
||||||
|
// });
|
||||||
|
// localStorage.setItem('yaswvc-peerId', peer.id);
|
||||||
|
// return peer;
|
||||||
|
// },
|
||||||
connectToPeer: function() {
|
connectToPeer: function() {
|
||||||
let peerId = this.peer.id;
|
let peerId = this.peer.id;
|
||||||
this.logMessage(`Connecting to ${peerId}...`);
|
this.logMessage(`Connecting to ${peerId}...`);
|
||||||
|
|
@ -32,18 +40,11 @@ var app = new Vue({
|
||||||
|
|
||||||
let call = this.peer.call(this.peerId, this.stream);
|
let call = this.peer.call(this.peerId, this.stream);
|
||||||
call.on('stream', this.renderVideo);
|
call.on('stream', this.renderVideo);
|
||||||
// navigator.mediaDevices.getUserMedia({video: true, audio: true})
|
|
||||||
// .then((stream) => {
|
|
||||||
// let call = peer.call(peerId, stream);
|
|
||||||
// call.on('stream', renderVideo);
|
|
||||||
// })
|
|
||||||
// .catch((err) => {
|
|
||||||
// logMessage('Failed to get local stream', err);
|
|
||||||
// });
|
|
||||||
},
|
},
|
||||||
listenForPeerEvents: function () {
|
listenForPeerEvents: function () {
|
||||||
this.peer.on('open', (id) => {
|
this.peer.on('open', (id) => {
|
||||||
this.logMessage('My peer ID is: ' + id);
|
this.logMessage('My peer ID is: ' + id);
|
||||||
|
localStorage.setItem('yaswvc-peerId', id);
|
||||||
});
|
});
|
||||||
this.peer.on('error', (error) => {
|
this.peer.on('error', (error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
@ -165,6 +166,7 @@ var app = new Vue({
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
console.log('VUE is alive!');
|
console.log('VUE is alive!');
|
||||||
|
this.listenForPeerEvents();
|
||||||
navigator.mediaDevices.enumerateDevices().then(this.gotDevices).catch(this.handleError);
|
navigator.mediaDevices.enumerateDevices().then(this.gotDevices).catch(this.handleError);
|
||||||
this.start();
|
this.start();
|
||||||
document.querySelector('select#audioOutput').disabled = !('sinkId' in HTMLMediaElement.prototype);
|
document.querySelector('select#audioOutput').disabled = !('sinkId' in HTMLMediaElement.prototype);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue