私は、今skywayのAPIで電話機能を導入しようとしています。しかし、自分自身の映像は映るのですが、PeerIDと相手の映像が表示されない状態になっています。もしわかる方がいらしたら、教えて頂いきたいです。
エラー箇所
meta.innerText = ` UA: ${navigator.userAgent} SDK: ${sdkSrc ? sdkSrc.src : 'unknown'} `.trim(); peer = new Peer({ key: '$$$$$$$$$$$$$$$', debug: 3 });
参考にしたサイト
https://webrtc.ecl.ntt.com/js-tutorial.html
https://github.com/skyway/skyway-js-sdk-tutorial/blob/master/index.html
https://webrtc.ecl.ntt.com/skyway-js-sdk-tutorial/
view
1<!DOCTYPE html> 2<html> 3<head> 4</head> 5 6<body style="margin: 0;"> 7 8<div class="sp"> 9 10 <div class="pure-g"> 11 12 <!-- Video area --> 13 <div class="pure-u-2-3" id="video-container"> 14 <video id="their-video" autoplay></video> 15 <video id="my-video" muted="true" autoplay></video> 16 </div> 17 18 <!-- Steps --> 19 <div class="pure-u-1-3"> 20 <h2>SkyWay Video Chat</h2> 21 22 <p>Your id: <span id="my-id">...</span></p> 23 <p>Share this id with others so they can call you.</p> 24 <h3>Make a call</h3> 25 <form id="make-call" class="pure-form"> 26 <input type="text" placeholder="Call user id..." id="callto-id"> 27 <button href="#" class="pure-button pure-button-success" type="submit">Call</button> 28 </form> 29 <form id="end-call" class="pure-form"> 30 <p>Currently in call with <span id="their-id">...</span></p> 31 <button href="#" class="pure-button pure-button-success" type="submit">End Call</button> 32 </form> 33 </div> 34 </div> 35 <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script> 36 <script type="text/javascript" src="https://cdn.webrtc.ecl.ntt.com/skyway-latest.js"></script> 37 <script type="text/javascript" src="/assets/script.js"></script> 38 39</div> 40
javascripts
1'use strict'; 2 3let localStream = null; 4let peer = null; 5let existingCall = null; 6 7navigator.mediaDevices.getUserMedia({video: true, audio: true}) 8 .then(function (stream) { 9 // Success 10 $('#my-video').get(0).srcObject = stream; 11 localStream = stream; 12 }).catch(function (error) { 13 // Error 14 console.error('mediaDevice.getUserMedia() error:', error); 15 return; 16}); 17 18peer = new Peer({ 19 key: '$$$$$$$$$$$$$$$$$$$$', 20 debug: 3 21}); 22 23peer.on('open', function(){ 24 $('#my-id').text(peer.id); 25}); 26 27peer.on('error', function(err){ 28 alert(err.message); 29}); 30 31peer.on('close', function(){ 32}); 33 34peer.on('disconnected', function(){ 35}); 36 37$('#make-call').submit(function(e){ 38 e.preventDefault(); 39 const call = peer.call($('#callto-id').val(), localStream); 40 setupCallEventHandlers(call); 41}); 42 43$('#end-call').click(function(){ 44 existingCall.close(); 45}); 46 47peer.on('call', function(call){ 48 call.answer(localStream); 49 setupCallEventHandlers(call); 50}); 51 52function setupCallEventHandlers(call){ 53 if (existingCall) { 54 existingCall.close(); 55 }; 56 57 existingCall = call; 58 59 call.on('stream', function(stream){ 60 addVideo(call,stream); 61 setupEndCallUI(); 62 $('#their-id').text(call.remoteId); 63 }); 64 call.on('close', function(){ 65 removeVideo(call.remoteId); 66 setupMakeCallUI(); 67 }); 68} 69 70function addVideo(call,stream){ 71 $('#their-video').get(0).srcObject = stream; 72} 73 74function removeVideo(peerId){ 75 $('#'+peerId).remove(); 76} 77 78function setupMakeCallUI(){ 79 $('#make-call').show(); 80 $('#end-call').hide(); 81} 82 83function setupEndCallUI() { 84 $('#make-call').hide(); 85 $('#end-call').show(); 86} 87
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。