![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/webrtc/tutorials/ |
Upload File : |
<!-- Styles --> <style> video { width: 200px } </style> <!-- Video Output Zone --> <div id="video-out"></div> <!-- Libs and Scripts --> <script src="https://cdn.pubnub.com/pubnub.js"></script> <script src="https://stephenlb.github.io/webrtc-sdk/js/webrtc.js"></script> <script>(()=>{ 'use strict'; // ~Warning~ You must get your own API Keys for non-demo purposes. // ~Warning~ Get your PubNub API Keys: https://www.pubnub.com/get-started/ // The phone *number* can by any string value const pubkey = 'pub-c-561a7378-fa06-4c50-a331-5c0056d0163c'; const subkey = 'sub-c-17b7db8a-3915-11e4-9868-02ee2ddab7fe'; const number = "BROADCAST-VIEWER";//(''+Math.random()*100000).split('.')[0]; // Phone const phone = PHONE({ number : number , media : { audio : true, video : true } , publish_key : pubkey , subscribe_key : subkey , ssl : true }); // Local Camera Display phone.ready( video => { console.log('Ready'); //phone.$('video-out').appendChild(video); }); // Debugging Output phone.debug( info => console.info(info) ); // Receive Broadcaster Updates PUBNUB({ pubkey : pubkey , subkey : subkey , ssl : true }).subscribe({ channel : "BROADCASTER1234" , callback : message => message.notify == "reload" && location.reload(false) }); // As soon as the phone is ready we can make calls phone.ready(()=>{ phone.hangup(); phone.dial("BROADCASTER-TEST"); //setTimeout( () => playing || location.reload, 6000 ); }); // Broadcaster's Video var playing = false; phone.receive(function(broadcaster){ console.log("Fetching broadcaster's video"); // Display Your Friend's Live Video broadcaster.connected( broadcaster => { if (playing) return; playing = true; console.log("Playing broadcaster's video"); PUBNUB.$('video-out').appendChild(broadcaster.video); setTimeout( phone.toggleAudio, 1000 ); setTimeout( phone.toggleVideo, 1000 ); }); broadcaster.ended( broadcaster => { playing = false; console.log('Stream ended'); }); }); })();</script>