This commit is contained in:
Your Name
2026-05-26 16:53:21 +08:00
parent b764e7555d
commit 97aefcf86b
2 changed files with 118 additions and 68 deletions

View File

@@ -252,35 +252,47 @@ document.addEventListener('DOMContentLoaded', function () {
// this.initJyPlayer264(strPlayUrl)
},
initDPlayer(strPlayUrl) {
let DomDPlayer = document.getElementById('dplayer')
videoPlayer = new DPlayer({
container: DomDPlayer,
autoplay: true,
screenshot: false,
//logo: dplayerLogo,
video: {
url: strPlayUrl,
type: 'hls',
},
pluginOptions: {
hls: {
maxBufferLength: 600,
},
},
});
initDPlayer(strPlayUrl) {
let DomDPlayer = document.getElementById('dplayer') || document.querySelector('.dplayer')
if (!DomDPlayer) {
console.warn('DPlayer 容器不存在')
return null
}
if (!strPlayUrl) {
console.warn('DPlayer 播放地址为空')
return null
}
videoPlayer = new DPlayer({
container: DomDPlayer,
autoplay: true,
screenshot: false,
//logo: dplayerLogo,
video: {
url: strPlayUrl,
type: 'hls',
},
pluginOptions: {
hls: {
maxBufferLength: 600,
},
},
});
videoPlayer.play()
videoPlayer.play()
// 监听全屏进入事件
videoPlayer.on('fullscreen', function () {
DomDPlayer.classList.add("dp-fullscreen");
});
// 监听全屏退出事件
videoPlayer.on('fullscreen_cancel', function () {
DomDPlayer.classList.remove("dp-fullscreen");
});
// 监听全屏进入事件
videoPlayer.on('fullscreen', function () {
if (DomDPlayer.classList) {
DomDPlayer.classList.add("dp-fullscreen");
}
});
// 监听全屏退出事件
videoPlayer.on('fullscreen_cancel', function () {
if (DomDPlayer.classList) {
DomDPlayer.classList.remove("dp-fullscreen");
}
});
videoPlayer.on('error', function () {
});
@@ -295,12 +307,13 @@ document.addEventListener('DOMContentLoaded', function () {
}, 1000); // 等待一会儿确保视频已开始
});
// 监听当前播放时间
videoPlayer.on('timeupdate', function () {
if (videoPlayer.video.currentTime < 20) { // 当前时间小于 20 秒
videoPlayer.seek(20); // 跳过到 20 秒
}
});
},
videoPlayer.on('timeupdate', function () {
if (videoPlayer.video.currentTime < 20) { // 当前时间小于 20 秒
videoPlayer.seek(20); // 跳过到 20 秒
}
});
return videoPlayer
},
/**
@@ -414,11 +427,19 @@ document.addEventListener('DOMContentLoaded', function () {
* @param {string} strPlayUrl
* @param {boolean} boolIsFirstPlayCctv 是否首次播放广告
*/
initDPlayer264(strPlayUrl, boolIsFirstPlayCctv = false) {
let DomDPlayer = document.getElementById('dplayer')
if(videoPlayer == null){
videoPlayer = new DPlayer({
container: DomDPlayer,
initDPlayer264(strPlayUrl, boolIsFirstPlayCctv = false) {
let DomDPlayer = document.getElementById('dplayer') || document.querySelector('.dplayer')
if (!DomDPlayer) {
console.warn('DPlayer 容器不存在')
return null
}
if (!strPlayUrl) {
console.warn('DPlayer 播放地址为空')
return null
}
if(videoPlayer == null){
videoPlayer = new DPlayer({
container: DomDPlayer,
autoplay: true,
screenshot: false,
//logo: dplayerLogo,
@@ -438,24 +459,29 @@ document.addEventListener('DOMContentLoaded', function () {
videoPlayer.play()
videoPlayer.on('fullscreen', function () {
DomDPlayer.classList.add("dp-fullscreen");
});
videoPlayer.on('fullscreen_cancel', function () {
DomDPlayer.classList.remove("dp-fullscreen");
});
videoPlayer.on('fullscreen', function () {
if (DomDPlayer.classList) {
DomDPlayer.classList.add("dp-fullscreen");
}
});
videoPlayer.on('fullscreen_cancel', function () {
if (DomDPlayer.classList) {
DomDPlayer.classList.remove("dp-fullscreen");
}
});
videoPlayer.on('error', function () {
//videoInfoJs.beforePlay(videoInfoJs.checkPlaylineUrl(videoInfoJs.intPlayLine, strPlayUrl));
});
videoPlayer.on('play', function () {
// if (videoInfoJs.boolIsShowCctvImg || videoInfoJs.boolIsShowCctvVideo) {
// if (boolIsFirstPlayCctv && publicJs.strEquipmentCode == 'ios') {
videoPlayer.on('play', function () {
// if (videoInfoJs.boolIsShowCctvImg || videoInfoJs.boolIsShowCctvVideo) {
// if (boolIsFirstPlayCctv && publicJs.strEquipmentCode == 'ios') {
// return;
// }
// videoInfoJs.countDownFn()
// }
});
},
// videoInfoJs.countDownFn()
// }
});
return videoPlayer
},
/**
@@ -667,4 +693,3 @@ document.addEventListener('DOMContentLoaded', function () {
// }));
// }