|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <!DOCTYPE html>
- <html lang="en">
-
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <script src="https://unpkg.com/aliyun-rts-sdk@1.2.1/dist/aliyun-rts-sdk.js"></script>
- </head>
-
- <body>
- <video id="video" controls muted="false"></video>
- </body>
-
- </html>
- <script>
- // // var socket = io.connect('http://localhost:3000');
- // var socket = io.connect('http://47.98.202.174');
- // socket.emit('commit', { message: 'hello world' });
- // socket.on('message', function (data) {
- // console.log('client message', data);
- // });
- var aliRts = new AliRTS()
- // aliRts.isSupport(supportInfo).then(re=> {
- // // 可用
- // }).catch(err=> {
- // // 不可用
- // console.log(`not support errorCode: ${err.errorCode}`);
- // console.log(`not support message: ${err.message}`);
- // });
- const pullStreamUrl = 'artc://rts-pull-live.deepeleph.com/quanjiang_DEMO00001/SXT003-0?auth_key=1720586611-0-0-d42e030b8f76246f7aacfbdba6620160&aliyun_uuid=dda449e6fecd461e8a445b992fa56b86';
- const mediaEle = document.querySelector('video');
- aliRts.on("onError", (err) => {
- console.log(`errorCode: ${err.errorCode}`);
- console.log(`message: ${err.message}`);
- })
-
- const PLAY_EVENT = {
- CANPLAY: "canplay",
- WAITING: "waiting",
- PLAYING: "playing"
- }
-
- aliRts.on('onPlayEvent', (play) => {
- console.log(">>play.event:" + play.event);
- if (play.event === PLAY_EVENT.CANPLAY) {
- // 拉流可以播放
- } else if (play.event === PLAY_EVENT.WAITING) {
- // 拉流卡顿等待缓冲中 (仅Chrome)
- } else if (play.event === PLAY_EVENT.PLAYING) {
- // 拉流卡顿结束恢复播放 (仅Chrome)
- }
- });
- aliRts.startLiveStream(pullStreamUrl, mediaEle);
-
- </script>
|