代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html lang="en">
<div class="container">
<video controls crossorigin playsinline></video>
</div>
<p id="version"></p>
<h3>download info:</h3>
<p id="info"></p>
<link rel="stylesheet" href="//cdn.plyr.io/3.4.7/plyr.css">
<script src="//cdn.plyr.io/3.4.7/plyr.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@swarmcloud/hls/hls.min.js"></script>
<script>
var p2pConfig = {
logLevel: 'debug',
live: false, // set to true in live mode
swFile: './sw.js',
getStats: function (totalP2PDownloaded, totalP2PUploaded, totalHTTPDownloaded) {
var total = totalHTTPDownloaded + totalP2PDownloaded;
document.querySelector('#info').innerText = `p2p ratio: ${Math.round(totalP2PDownloaded/total*100)}%, saved traffic: ${totalP2PDownloaded}KB, uploaded: ${totalP2PUploaded}KB`;
},
// trackerZone: 'hk', // if using Hongkong tracker
// trackerZone: 'us', // if using USA tracker
// token: YOUR_TOKEN
// Other p2pConfig options provided by CDNBye
}
document.querySelector('#version').innerText = `hls.js version: ${Hls.version} cdnbye version: ${Hls.engineVersion}`;
if (!Hls.P2pEngine.isMSESupported()) {
// use ServiceWorker based p2p engine if hls.js is not supported, need additional file sw.js
new Hls.P2pEngine.ServiceWorkerEngine(p2pConfig)
}
Hls.P2pEngine.tryRegisterServiceWorker(p2pConfig).then(() => {
var source = 'https://test-streams.mux.dev/x36xhzz/url_2/193039199_mp4_h264_aac_ld_7.m3u8';
var video = document.querySelector('video');
// For more options see: https://github.com/sampotts/plyr/#options
// captions.update is required for captions to work with hls.js
var player = new Plyr(video, {
captions: {active: true, update: true, language: 'en'},
// autoplay: true,
});
if (!Hls.isSupported()) {
video.src = source;
} else {
// For more Hls.js options, see https://github.com/dailymotion/hls.js
var hls = new Hls({
p2pConfig
});
hls.loadSource(source);
hls.attachMedia(video);
window.hls = hls;
// Handle changing captions
player.on('languagechange', () => {
// Caption support is still flaky. See: https://github.com/sampotts/plyr/issues/994
setTimeout(() => hls.subtitleTrack = player.currentTrack, 50);
});
}
// Expose player so it can be used from the console
window.player = player;
})
</script>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。