|
- <!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>
- <style>
- #video {
- width: 100%;
- height: 100%;
- }
- </style>
- </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=1724921782-0-0-d7ac627dd65378c195ced9de16c63bc4&aliyun_uuid=edbaf313fe5a4102bfcf4951f38ebbf8';
- 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>
|