srs.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import {SrsRTC } from './SrsRTC.js';
  2. import { Connection } from './connection.js';
  3. const sdk = new SrsRTC();
  4. const testConfig ={
  5. userId: '11111',
  6. roomId: '111',
  7. }
  8. const connection =new Connection(testConfig);
  9. console.log('sdk',sdk)
  10. console.log('sdk',connection)
  11. connection.socket.emit('pushVideo',{
  12. videoList:['0-1-0'],
  13. videoId: 'mini'
  14. })
  15. setTimeout(()=>{
  16. console.log('第二个')
  17. connection.socket.emit('pushVideo',{
  18. videoList:['0-1-0'],
  19. videoId: 'mini'
  20. })
  21. },5000)
  22. setTimeout(()=>{
  23. console.log('第三个')
  24. connection.socket.emit('pushVideo',{
  25. videoList:['0-1-0'],
  26. videoId: 'mini'
  27. })
  28. },12000)
  29. window.connection =connection
  30. connection.socket.on('getVideo',(videoId)=>{
  31. console.log('getVideo',videoId)
  32. if(videoId){
  33. const steamUrl ='webrtc://demo-kms.4dage.com/live/' + videoId
  34. getVideo(steamUrl)
  35. }
  36. })
  37. const getVideo =(videoUrl)=>{
  38. $('#testVideoFeed').prop('srcObject', sdk.stream);
  39. sdk.getVideo(videoUrl).then(function(session){
  40. console.log('session',session.sessionid)
  41. }).catch(function (reason) {
  42. console.error(reason);
  43. })
  44. }
  45. // sdk.pc.ondatachannel = function(ev) {
  46. // console.log('Data channel is created!');
  47. // ev.channel.onopen = function() {
  48. // console.log('Data channel is open and ready to be used.');
  49. // };
  50. // };