更新时间:2024-11-15 GMT+08:00
手动播放
手动播放的代码示例,如下所示:
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <title>手动播放demo</title> <style> html, body { width: 100%; height: 100%; padding: 0; margin: 0; } .preview_player { width: 1280px; height: 720px; margin: 20px auto; border: 1px solid #ddd; position: relative; } .preview_player_el { width: 100%; height: 100%; } .unmute_mask { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); text-align: center; } .unmute_btn { display: inline-block; padding: 10px; color: rgb(50, 250, 50); border: 1px solid rgb(50, 250, 50); background: rgba(50, 250, 50, 0.3); transform: translateY(400px); cursor: pointer; } </style> <script type="text/javascript" src="./sdk/HWLLSPlayer.js"></script> </head> <body> <div class="preview_player"> <div id="preview" class="preview_player_el"></div> <div class="unmute_mask" id="unmute-mask"> <div class="unmute_btn" onclick="playAction()">点击开始播放</div> </div> </div> <script type="text/javascript"> const playClient = HWLLSPlayer.createClient() const unmuteMask = document.getElementById('unmute-mask') const playAction = function () { playClient.resume() unmuteMask.style.display = 'none' } // 播放视频 const streamUrl = 'your stream url' const options = { elementId: 'preview', autoPlay: false, } playClient.startPlay(streamUrl, options) </script> </body> </html>
父主题: 代码示例