veplayer-mp-douyin
Advanced tools
Comparing version 1.0.3 to 1.0.4-alpha.0
@@ -46,2 +46,3 @@ "use strict"; | ||
ErrorCodes[ErrorCodes["SERVICE_PLAYINFOLIST_EMPTY"] = 2001] = "SERVICE_PLAYINFOLIST_EMPTY"; | ||
ErrorCodes[ErrorCodes["SERVICE_NOT_SUPPORT"] = 2002] = "SERVICE_NOT_SUPPORT"; | ||
})(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {})); |
@@ -7,3 +7,2 @@ "use strict"; | ||
const eventemitter3_1 = require("eventemitter3"); | ||
const xgplayer_service_miniprogram_1 = require("xgplayer-service-miniprogram"); | ||
const videoBehavior_1 = require("./behaviors/videoBehavior"); | ||
@@ -16,2 +15,3 @@ const douyinBehavior_1 = require("./behaviors/douyinBehavior"); | ||
const index_2 = require("./utils/index"); | ||
const request_1 = require("./request"); | ||
const index_3 = require("./tool/index"); | ||
@@ -135,3 +135,2 @@ (0, index_2.XgComponent)({ | ||
const { src, definitionList, playAuthToken, playDomain, isLoadingData } = this.data; | ||
console.log('>>>>observers', `isLoadingData:${isLoadingData} playDomain:${playDomain} playAuthToken:${playAuthToken} src:${src}`); | ||
this.triggerCollector('break'); | ||
@@ -156,25 +155,9 @@ this.updateCollector(this.data); | ||
}); | ||
(0, xgplayer_service_miniprogram_1.url)(playAuthToken, playDomain || undefined) | ||
.then((res) => { | ||
const data = (res === null || res === void 0 ? void 0 : res.Data) || res || {}; | ||
if (Array.isArray(data.PlayInfoList)) { | ||
const defaultDef = data.PlayInfoList[0]; | ||
const qualityList = data.PlayInfoList.sort((a, b) => b.Bitrate - a.Bitrate).map((item) => { | ||
const def = { | ||
text: item.Definition, | ||
url: item.MainPlayUrl, | ||
quality: item.Bitrate, | ||
}; | ||
return def; | ||
}); | ||
(0, request_1.serviceRequest)(playAuthToken, playDomain || undefined) | ||
.then(data => { | ||
if (data.error) { | ||
this.setData({ | ||
isLoadingData: false, | ||
currentSrc: defaultDef.MainPlayUrl, | ||
error: data.error, | ||
}); | ||
if (qualityList.length > 0) { | ||
this.setData({ | ||
playbackDefinition: defaultDef.Bitrate, | ||
playbackDefinitionList: qualityList, | ||
}); | ||
} | ||
} | ||
@@ -184,12 +167,42 @@ else { | ||
isLoadingData: false, | ||
error: new error_1.XGError(error_1.ErrorCategory.SERVICE, index_1.ErrorCodes.SERVICE_PLAYINFOLIST_EMPTY, 'Service Error'), | ||
currentSrc: data.url, | ||
}); | ||
} | ||
}) | ||
.catch(() => { | ||
this.setData({ | ||
isLoadingData: false, | ||
error: new error_1.XGError(error_1.ErrorCategory.SERVICE, index_1.ErrorCodes.SERVICE_UNKNOWN, 'Service Error'), | ||
}); | ||
}); | ||
// ServiceRequest(playAuthToken, playDomain || undefined) | ||
// .then((res) => { | ||
// const data = res?.Data || res || {} | ||
// if (Array.isArray(data.PlayInfoList)) { | ||
// const defaultDef = data.PlayInfoList[0] | ||
// const qualityList = data.PlayInfoList.sort((a, b) => b.Bitrate - a.Bitrate).map((item) => { | ||
// const def = { | ||
// text: item.Definition, | ||
// url: item.MainPlayUrl, | ||
// quality: item.Bitrate, | ||
// } | ||
// return def | ||
// }) | ||
// this.setData({ | ||
// isLoadingData: false, | ||
// currentSrc: defaultDef.MainPlayUrl, | ||
// }) | ||
// if (qualityList.length > 0) { | ||
// this.setData({ | ||
// playbackDefinition: defaultDef.Bitrate, | ||
// playbackDefinitionList: qualityList, | ||
// }) | ||
// } | ||
// } else { | ||
// this.setData({ | ||
// isLoadingData: false, | ||
// error: new XGError(ErrorCategory.SERVICE, ErrorCodes.SERVICE_PLAYINFOLIST_EMPTY, 'Service Error'), | ||
// }) | ||
// } | ||
// }) | ||
// .catch(() => { | ||
// this.setData({ | ||
// isLoadingData: false, | ||
// error: new XGError(ErrorCategory.SERVICE, ErrorCodes.SERVICE_UNKNOWN, 'Service Error'), | ||
// }) | ||
// }) | ||
} | ||
@@ -353,3 +366,3 @@ }, | ||
if (!currentSrc && isLoadingData) { | ||
console.warn('The is not aviliable [src] or [playAutoToken] for playback, please check~~'); | ||
console.warn('The is unavailable [src] or [playAutoToken] for playback, please check~~'); | ||
return; | ||
@@ -356,0 +369,0 @@ } |
{ | ||
"name": "veplayer-mp-douyin", | ||
"version": "1.0.3", | ||
"version": "1.0.4-alpha.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "miniprogramType": "tt-npm", |
@@ -1,48 +0,46 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const path = require('path') | ||
const fs = require('fs') | ||
function copyFolderSync(source, target) { | ||
if (!fs.existsSync(target)) { | ||
fs.mkdirSync(target); | ||
fs.mkdirSync(target) | ||
} | ||
fs.readdirSync(source).forEach((file) => { | ||
const sourcePath = path.join(source, file); | ||
const targetPath = path.join(target, file); | ||
const sourcePath = path.join(source, file) | ||
const targetPath = path.join(target, file) | ||
if (fs.lstatSync(sourcePath).isDirectory()) { | ||
copyFolderSync(sourcePath, targetPath); | ||
copyFolderSync(sourcePath, targetPath) | ||
} else { | ||
fs.copyFileSync(sourcePath, targetPath); | ||
fs.copyFileSync(sourcePath, targetPath) | ||
} | ||
}); | ||
}) | ||
} | ||
async function main() { | ||
const isExitSrc = fs.existsSync(path.join(__dirname, '../../src')); | ||
const isExitSrc = fs.existsSync(path.join(__dirname, '../../src')) | ||
const isUni = | ||
fs.existsSync(path.join(__dirname, '../../node_modules/@dcloudio')) || | ||
fs.existsSync(path.join(__dirname, `../../${isExitSrc ? 'src/' : ''}/pages.json`)); | ||
const isTaro = fs.existsSync(path.join(__dirname, '../../node_modules/@tarojs')); | ||
fs.existsSync(path.join(__dirname, `../../${isExitSrc ? 'src/' : ''}/pages.json`)) | ||
const isTaro = fs.existsSync(path.join(__dirname, '../../node_modules/@tarojs')) | ||
// 如果是uni或者taro项目,则执行复制 | ||
if (isUni || isTaro) { | ||
const isExitSrc = fs.existsSync(path.join(__dirname, '../../src')); | ||
const sourcePath = path.join(__dirname, '../../node_modules/veplayer-mp-douyin'); | ||
let targetPath = ''; | ||
const isExitTTCom = fs.existsSync(path.join(__dirname, `../../${isExitSrc ? 'src/' : ''}ttcomponents`)); | ||
const isExitSrc = fs.existsSync(path.join(__dirname, '../../src')) | ||
const sourcePath = path.join(__dirname, '../../node_modules/veplayer-mp-douyin') | ||
let targetPath = '' | ||
const isExitTTCom = fs.existsSync(path.join(__dirname, `../../${isExitSrc ? 'src/' : ''}ttcomponents`)) | ||
// 不存在则新建文件夹 | ||
if (!isExitTTCom) { | ||
const ttPath = fs.mkdirSync(path.join(__dirname, `../../${isExitSrc ? 'src/' : ''}ttcomponents`), { | ||
recursive: true | ||
}); | ||
recursive: true, | ||
}) | ||
if (!ttPath) { | ||
console.warn( | ||
`创建ttcomponents失败,请手动复制node_modules/veplayer-mp-douyin到${isExitSrc ? 'src/' : ''}tttcomponents` | ||
); | ||
return; | ||
console.warn(`创建ttcomponents失败,请手动复制node_modules/veplayer-mp-douyin到${isExitSrc ? 'src/' : ''}tttcomponents`) | ||
return | ||
} | ||
} | ||
targetPath = path.join(__dirname, `../../${isExitSrc ? 'src/' : ''}ttcomponents/veplayer-mp-douyin`); | ||
copyFolderSync(sourcePath, targetPath); | ||
targetPath = path.join(__dirname, `../../${isExitSrc ? 'src/' : ''}ttcomponents/veplayer-mp-douyin`) | ||
copyFolderSync(sourcePath, targetPath) | ||
} | ||
@@ -52,5 +50,5 @@ } | ||
try { | ||
main(); | ||
main() | ||
} catch (err) { | ||
console.warn('复制veplayer-mp-douyin失败,请手动复制node_modules/veplayer-mp-douyin到根目录下的ttcomponents'); | ||
console.warn('复制veplayer-mp-douyin失败,请手动复制node_modules/veplayer-mp-douyin到根目录下的ttcomponents') | ||
} |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
136367
56
2143
2