debug
This commit is contained in:
@@ -446,8 +446,35 @@ async function reportStats(data) {
|
||||
}
|
||||
}
|
||||
|
||||
function resolveDPlayerContainer() {
|
||||
return document.getElementById('dplayer') || document.querySelector('.dplayer');
|
||||
}
|
||||
|
||||
function updateDPlayerMaxHeight(maxHeight) {
|
||||
const videoElement = document.querySelector("video");
|
||||
const videoWrap = document.querySelector(".video-play-page .dplayer-video-wrap");
|
||||
|
||||
if (videoElement) {
|
||||
videoElement.style.maxHeight = maxHeight;
|
||||
}
|
||||
|
||||
if (videoWrap) {
|
||||
videoWrap.style.maxHeight = maxHeight;
|
||||
}
|
||||
}
|
||||
|
||||
function initDPlayer(strPlayUrl) {
|
||||
let DomDPlayer = document.getElementById('dplayer')
|
||||
let DomDPlayer = resolveDPlayerContainer();
|
||||
if (!DomDPlayer) {
|
||||
console.warn('DPlayer 容器不存在');
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!strPlayUrl) {
|
||||
console.warn('DPlayer 播放地址为空');
|
||||
return null;
|
||||
}
|
||||
|
||||
videoPlayer = new DPlayer({
|
||||
container: DomDPlayer,
|
||||
autoplay: true,
|
||||
@@ -468,25 +495,22 @@ function initDPlayer(strPlayUrl) {
|
||||
|
||||
// 监听全屏进入事件
|
||||
videoPlayer.on('fullscreen', function () {
|
||||
if (DomDPlayer.classList) {
|
||||
DomDPlayer.classList.add("dp-fullscreen");
|
||||
// 设置视频元素的样式,取消 max-height
|
||||
document.querySelector("video").style.maxHeight = "none";
|
||||
document.querySelector(".video-play-page .dplayer-video-wrap").style.maxHeight = "none";
|
||||
|
||||
}
|
||||
updateDPlayerMaxHeight("none");
|
||||
});
|
||||
|
||||
// 监听全屏退出事件
|
||||
videoPlayer.on('fullscreen_cancel', function () {
|
||||
if (DomDPlayer.classList) {
|
||||
DomDPlayer.classList.remove("dp-fullscreen");
|
||||
// 恢复 max-height 为 480px
|
||||
if (isMobile()) {
|
||||
document.querySelector("video").style.maxHeight = "218px";
|
||||
document.querySelector(".video-play-page .dplayer-video-wrap").style.maxHeight = "218px";
|
||||
} else {
|
||||
document.querySelector("video").style.maxHeight = strMaxPlayHeight ?? '480px';
|
||||
document.querySelector(".video-play-page .dplayer-video-wrap").style.maxHeight = strMaxPlayHeight ?? '480px';
|
||||
}
|
||||
|
||||
if (isMobile()) {
|
||||
updateDPlayerMaxHeight("218px");
|
||||
} else {
|
||||
updateDPlayerMaxHeight(strMaxPlayHeight ?? '480px');
|
||||
}
|
||||
});
|
||||
|
||||
videoPlayer.on('error', function () {
|
||||
@@ -499,6 +523,8 @@ function initDPlayer(strPlayUrl) {
|
||||
videoPlayer.on('timeupdate', function () {
|
||||
|
||||
});
|
||||
|
||||
return videoPlayer;
|
||||
}
|
||||
|
||||
function findFirstUrl(obj) {
|
||||
@@ -656,4 +682,3 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -253,7 +253,15 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
},
|
||||
|
||||
initDPlayer(strPlayUrl) {
|
||||
let DomDPlayer = document.getElementById('dplayer')
|
||||
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,
|
||||
@@ -275,11 +283,15 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
// 监听全屏进入事件
|
||||
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 () {
|
||||
|
||||
@@ -300,6 +312,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
videoPlayer.seek(20); // 跳过到 20 秒
|
||||
}
|
||||
});
|
||||
return videoPlayer
|
||||
},
|
||||
|
||||
|
||||
@@ -415,7 +428,15 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
* @param {boolean} boolIsFirstPlayCctv 是否首次播放广告
|
||||
*/
|
||||
initDPlayer264(strPlayUrl, boolIsFirstPlayCctv = false) {
|
||||
let DomDPlayer = document.getElementById('dplayer')
|
||||
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,
|
||||
@@ -439,10 +460,14 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
videoPlayer.play()
|
||||
|
||||
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));
|
||||
@@ -455,6 +480,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
// videoInfoJs.countDownFn()
|
||||
// }
|
||||
});
|
||||
return videoPlayer
|
||||
},
|
||||
|
||||
|
||||
@@ -667,4 +693,3 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
// }));
|
||||
// }
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user