質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
WebRTC

WebRTC(Web Real-Time Communication)とは、プラグイン無しでウェブブラウザ間の音声通話・ビデオチャットなどリアルタイムコミュニケーションができるオープンフレームワークです。W3CがAPIレベルで、IETFがプロトコルレベルでそれぞれ標準化が進められています。

Q&A

0回答

287閲覧

sharescreen付きビデオチャットをjoinRoomで繋ぎたい(1対1)

ya_suhn

総合スコア25

WebRTC

WebRTC(Web Real-Time Communication)とは、プラグイン無しでウェブブラウザ間の音声通話・ビデオチャットなどリアルタイムコミュニケーションができるオープンフレームワークです。W3CがAPIレベルで、IETFがプロトコルレベルでそれぞれ標準化が進められています。

0グッド

0クリップ

投稿2018/11/26 05:46

skywayのsharescreenオープンソースをjoinRoomで作成したい

skywayのpeer.idにとらわれず、こちらの指定したroomでビデオチャット+sharescreenができるようにしたい。

js

1/** 2オープンソース(https://github.com/skyway/skyway-screenshare?fbclid=IwAR02E8ZaWWWuQptWBgtCHeybZjlVvAhMoxu-n2KSGvnwjkkKW6dUnwhV3Hw) 3*/ 4/* eslint-disable require-jsdoc */ 5/** 6 * SkyWay Screenshare Sample App 7 * @author NTT Communications(skyway@ntt.com) 8 * @link https://github.com/nttcom/ECLRTC-ScreenShare 9 * @license MIT License 10 */ 11 12jQuery(function() { 13 // API key (bc26d227-0bf2-460a-b2cb-129a0dfafdc2 can only be used on localhost) 14 const APIKEY = '*******-****-****-****-********'; 15 16 // Call object 17 let existingCall = null; 18 19 // localStream 20 let localStream = null; 21 22 // Create Peer object 23 const peer = new Peer({key: APIKEY, debug: 3}); 24 25 // Prepare screen share object 26 const ss = ScreenShare.create({debug: true}); 27 console.log(peer); 28 29 // Get peer id from server 30 peer.on('open', () => { 31 jQuery('#my-id').text(peer.id); 32 }); 33 34 // Set your own stream and answer if you get a call 35 peer.on('call', call => { 36 call.answer(localStream); 37 step3(call); 38 console.log('event:recall'); 39 }); 40 41 // Error handler 42 peer.on('error', err => { 43 alert(err.message); 44 step2(); 45 }); 46 47 // Call peer 48 jQuery('#make-call').on('click', () => { 49 const call = peer.call(jQuery('#otherpeerid').val(), localStream); 50 step3(call); 51 }); 52 53 // Finish call 54 jQuery('#end-call').on('click', () => { 55 existingCall.close(); 56 step2(); 57 }); 58 59 // Get media stream again 60 jQuery('#step1-retry').on('click', () => { 61 jQuery('#step1-error').hide(); 62 step1(); 63 }); 64 65 // Start screenshare 66 jQuery('#start-screen').on('click', () => { 67 if (ss.isScreenShareAvailable() === false) { 68 alert('Screen Share cannot be used. Please install the Chrome extension.'); 69 return; 70 } 71 72 ss.start({ 73 width: jQuery('#Width').val(), 74 height: jQuery('#Height').val(), 75 frameRate: jQuery('#FrameRate').val(), 76 }) 77 .then(stream => { 78 jQuery('#my-video')[0].srcObject = stream; 79 80 if (existingCall !== null) { 81 const peerid = existingCall.peer; 82 existingCall.close(); 83 const call = peer.call(peerid, stream); 84 step3(call); 85 } 86 localStream = stream; 87 }) 88 .catch(error => { 89 console.log(error); 90 }); 91 }); 92 93 // End screenshare 94 jQuery('#stop-screen').on('click', () => { 95 ss.stop(); 96 localStream.getTracks().forEach(track => track.stop()); 97 }); 98 99 // Camera 100 jQuery('#start-camera').on('click', () => { 101 navigator.mediaDevices.getUserMedia({audio: true, video: true}) 102 .then(stream => { 103 jQuery('#my-video')[0].srcObject = stream; 104 105 if (existingCall !== null) { 106 const peerid = existingCall.peer; 107 existingCall.close(); 108 const call = peer.call(peerid, stream); 109 step3(call); 110 } 111 localStream = stream; 112 }) 113 .catch(err => { 114 jQuery('#step1-error').show(); 115 }); 116 }); 117 118 // Start step 1 119 step1(); 120 121 function step1() { 122 navigator.mediaDevices.getUserMedia({audio: true, video: true}) 123 .then(stream => { 124 jQuery('#my-video')[0].srcObject = stream; 125 localStream = stream; 126 step2(); 127 }) 128 .catch(err => { 129 jQuery('#step1-error').show(); 130 }); 131 } 132 133 function step2() { 134 // Update UI 135 jQuery('#step1, #step3').hide(); 136 jQuery('#step2').show(); 137 } 138 139 function step3(call) { 140 // Close any existing calls 141 if (existingCall) { 142 existingCall.close(); 143 } 144 145 // Wait for peer's media stream 146 call.on('stream', stream => { 147 jQuery('#their-video')[0].srcObject = stream; 148 jQuery('#step1, #step2').hide(); 149 jQuery('#step3').show(); 150 }); 151 152 // If the peer closes their connection 153 call.on('close', step2); 154 155 // Save call object 156 existingCall = call; 157 158 // Update UI 159 jQuery('#their-id').text(call.peer); 160 jQuery('#step1, #step2').hide(); 161 jQuery('#step3').show(); 162 } 163}); 164

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問