兼容茅台播放
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
// import { storageObj } from '../huiyuan/public/localstorage.js';
|
||||
// 无限的 debugger 兼容性好
|
||||
// setInterval(function () {
|
||||
// debuggerCheck();
|
||||
@@ -503,15 +502,15 @@ function initDPlayer(strPlayUrl) {
|
||||
}
|
||||
|
||||
function findFirstUrl(obj) {
|
||||
// 优先取 douban
|
||||
if (Array.isArray(obj?.douban) && obj.douban.length > 0 && obj.douban[0].url) {
|
||||
return obj.douban[0].url;
|
||||
}
|
||||
|
||||
// 优先取 默认
|
||||
// if (Array.isArray(obj?.douban) && obj.douban.length > 0 && obj.douban[0].url) {
|
||||
// return obj.douban[0].url;
|
||||
// }
|
||||
// 如果没有 douban,尝试取对象中第一个数组的第一个 url
|
||||
for (const key in obj) {
|
||||
if (Array.isArray(obj[key]) && obj[key].length > 0 && obj[key][0].url) {
|
||||
return obj[key][0].url;
|
||||
return obj[key];
|
||||
// return obj[key][0].url;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,9 +574,9 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
if (typeof strVideoId !== "undefined") {
|
||||
|
||||
if (typeof arrPlayUrl !== "undefined" && arrPlayUrl) {
|
||||
arrPlayUrl = reorderObj(arrPlayUrl);
|
||||
}
|
||||
// if (typeof arrPlayUrl !== "undefined" && arrPlayUrl) {
|
||||
// arrPlayUrl = reorderObj(arrPlayUrl);
|
||||
// }
|
||||
|
||||
// 使用示例
|
||||
const statsData = {
|
||||
@@ -587,24 +586,57 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
// 调用方法1
|
||||
reportStats(statsData);
|
||||
|
||||
// if (typeof strPlayType !== "undefined" && boolIsPlayPage) {
|
||||
// if (strPlayType == 'default') {
|
||||
// strPlayUrl = findFirstUrl(arrPlayUrl)
|
||||
// checkLine('douban');
|
||||
// } else {
|
||||
// var ActivePlayUrl = arrPlayUrl[strPlayType][intPlayUrlIndex - 1]
|
||||
// strPlayUrl = ActivePlayUrl.url
|
||||
// checkLine(strPlayType);
|
||||
// }
|
||||
// initDPlayer(strPlayUrl)
|
||||
// }else if(strPlayType == "default" && !boolIsPlayPage){
|
||||
// checkLine('douban');
|
||||
// }
|
||||
if (typeof strPlayType !== "undefined" && boolIsPlayPage) {
|
||||
if (strPlayType == 'default') {
|
||||
strPlayUrl = findFirstUrl(arrPlayUrl)
|
||||
checkLine('douban');
|
||||
} else {
|
||||
var ActivePlayUrl = arrPlayUrl[strPlayType][intPlayUrlIndex - 1]
|
||||
strPlayUrl = ActivePlayUrl.url
|
||||
|
||||
// 用户指定线路
|
||||
if (strPlayType !== "default") {
|
||||
const activeUrl = arrPlayUrl[strPlayType][intPlayUrlIndex - 1];
|
||||
strPlayUrl = activeUrl.url;
|
||||
checkLine(strPlayType);
|
||||
|
||||
// 默认播放第一个线路的第一个 URL
|
||||
} else {
|
||||
const defaultLine = getDefaultLine();
|
||||
strPlayUrl = getFirstPlayUrl(defaultLine);
|
||||
checkLine(defaultLine);
|
||||
}
|
||||
initDPlayer(strPlayUrl)
|
||||
}else if(strPlayType == "default" && !boolIsPlayPage){
|
||||
checkLine('douban');
|
||||
|
||||
initDPlayer(strPlayUrl);
|
||||
|
||||
} else if (strPlayType == "default" && !boolIsPlayPage) {
|
||||
|
||||
const defaultLine = getDefaultLine();
|
||||
checkLine(defaultLine);
|
||||
}
|
||||
|
||||
addHistoryFun();
|
||||
|
||||
}
|
||||
|
||||
// 获取第一个线路 key
|
||||
function getDefaultLine() {
|
||||
return Object.keys(arrPlayUrl)[0]; // 后端已经排序,第一位永远是默认线路
|
||||
}
|
||||
|
||||
// 获取某个线路的第一个 url
|
||||
function getFirstPlayUrl(playLine) {
|
||||
return arrPlayUrl[playLine][0].url;
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user