Update classic.php

pull/18/head
居桉 2020-02-27 00:14:58 +08:00 committed by GitHub
parent f070669116
commit c8124eac72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 38 additions and 10 deletions

View File

@ -637,16 +637,44 @@
); );
} }
function createDplayers(videos) { function createDplayers(videos) {
for (i = 0; i < videos.length; i++) { var url = '<?php echo str_replace('%2523', '%23', str_replace('%26amp%3B','&amp;',spurlencode(path_format($_SERVER['base_path'] . '/' . $path), '/'))); ?>' , subtitle = url.replace(/\.[^\.]+?(\?|$)/,'.vtt$1');
console.log(videos[i]); var dp = new DPlayer({
new DPlayer({ container: document.getElementById('video-a0'),
container: document.getElementById('video-a' + i), autoplay: false,
screenshot: true, screenshot: true,
video: { hotkey: true,
url: videos[i] volume: 1,
} preload: 'auto',
mutex: true,
video:{
url: url,
},
subtitle: {
url: subtitle,
fontSize: '25px',
bottom: '7%',
},
}); });
// 防止出现401 token过期
dp.on('error', function () {
console.log('获取资源错误,开始重新加载!');
let last = dp.video.currentTime;
dp.video.src = url;
dp.video.load();
dp.video.currentTime = last;
dp.play();
});
// 如果是播放状态 & 没有播放完 每25分钟重载视频防止卡死
setInterval(function () {
if (!dp.video.paused && !dp.video.ended) {
console.log('开始重新加载!');
let last = dp.video.currentTime;
dp.video.src = url;
dp.video.load();
dp.video.currentTime = last;
dp.play();
} }
}, 1000 * 60 * 25)
} }
addVideos(['<?php echo $DPvideo;?>']); addVideos(['<?php echo $DPvideo;?>']);
<?php } <?php }