veplayer-mp-douyin
Advanced tools
Comparing version 1.0.6 to 1.2.3-alpha.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable unicorn/filename-case */ | ||
/* eslint-disable @typescript-eslint/prefer-optional-chain */ | ||
/* eslint-disable @typescript-eslint/comma-dangle */ | ||
@@ -8,4 +10,3 @@ /** | ||
const index_1 = require("../tool/index"); | ||
const error_1 = require("../utils/error"); | ||
const index_2 = require("../enums/index"); | ||
const xgerror_1 = require("../xgerror"); | ||
exports.default = Behavior({ | ||
@@ -17,2 +18,3 @@ properties: { | ||
observer(newVal, _changedPath) { | ||
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain | ||
this.collector && this.collector.setConfig(newVal); | ||
@@ -66,4 +68,4 @@ } | ||
const message = 'Collector for log not configured'; | ||
const error = new error_1.XGError(error_1.ErrorCategory.Collector, index_2.ErrorCodes.Collector_NOT_CONFIGURED, message); | ||
error.severity = error_1.ErrorSeverity.INTERRUPTED; | ||
const error = (0, xgerror_1.XGError)(xgerror_1.ErrorCategory.COLLECTOR, xgerror_1.ErrorCodes.Collector_NOT_CONFIGURED, message); | ||
error.severity = xgerror_1.ErrorSeverity.INTERRUPTED; | ||
this.setData({ | ||
@@ -70,0 +72,0 @@ error |
@@ -13,3 +13,3 @@ "use strict"; | ||
properties: { | ||
// 原片id | ||
// 原片id,见https://bytedance.feishu.cn/wiki/SG1MwJyWhiqwUxkkZvjcConanue | ||
albumId: { | ||
@@ -19,3 +19,3 @@ type: String, | ||
}, | ||
// 剧集id | ||
// 剧集id,见https://bytedance.feishu.cn/wiki/SG1MwJyWhiqwUxkkZvjcConanue | ||
episodeId: { | ||
@@ -25,2 +25,15 @@ type: String, | ||
}, | ||
// 使用cdn类型,1: 抖音云 2: 三方云 | ||
// 如果不填服务端默认不从CDN上获取链接 | ||
cloudType: { | ||
type: Number, | ||
}, | ||
// 三方云链接,当cloud_type为2,即三方云时必传 | ||
threePartyCloud: { | ||
type: String, | ||
}, | ||
// 短剧版本,服务端新增参数,当cloud_type不为空时必传,见https://bytedance.feishu.cn/wiki/SG1MwJyWhiqwUxkkZvjcConanue | ||
version: { | ||
type: String, | ||
} | ||
}, | ||
@@ -27,0 +40,0 @@ data: { |
@@ -28,2 +28,22 @@ "use strict"; | ||
}, | ||
/** | ||
* @description 起播之前是否显示中间播放按钮,只在起播之前生效 | ||
*/ | ||
showCenterPlayBtn: { | ||
type: Boolean, | ||
value: true, | ||
}, | ||
/** | ||
* @description 起播之后播放按钮的位置 | ||
* center: 居中; | ||
* bottom: 控制栏左侧 | ||
* center-bottom: 底部居中(扩展态) | ||
*/ | ||
playBtnPosition: { | ||
type: String, | ||
value: 'bottom', | ||
}, | ||
/** | ||
* @description 播放过程中是否显示播放按钮,如果为false, 则播放过程中一直不展示播放按钮 | ||
*/ | ||
showPlayBtn: { | ||
@@ -33,2 +53,13 @@ type: Boolean, | ||
}, | ||
/** | ||
* @description 【扩展属性】播放按钮显示模式 | ||
*/ | ||
playBtnMode: { | ||
type: String, | ||
value: 'normal', | ||
}, | ||
showMuteBtn: { | ||
type: Boolean, | ||
value: false, | ||
}, | ||
controls: { | ||
@@ -43,10 +74,2 @@ type: String, | ||
}, | ||
playBtnPosition: { | ||
type: String, | ||
value: 'center', | ||
}, | ||
showCenterPlayBtn: { | ||
type: Boolean, | ||
value: true, | ||
}, | ||
preRollUnitId: String, | ||
@@ -74,6 +97,2 @@ postRollUnitId: String, | ||
}, | ||
showMuteBtn: { | ||
type: Boolean, | ||
value: false, | ||
}, | ||
showPlaybackRateBtn: { | ||
@@ -119,2 +138,11 @@ type: Boolean, | ||
}, | ||
// 是否开启界面暗水印功能,用于视频防盗录场景。暗水印解码效果需要根据实际情况而定。小程序使用了暗水印能力后出现的盗录场景,可以拉客服咨询。 | ||
enableDarkWaterMark: { | ||
type: Boolean, | ||
value: false, | ||
}, | ||
// 对视频内容的传输过程进行加密,通过 encrypted-token 设置通用加密(CENC)的解密 key,加密流程见 FFmpeg通用加密https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/guide/open-capabilities/encrypted-token。 | ||
encryptedToken: { | ||
type: String, | ||
}, | ||
}, | ||
@@ -121,0 +149,0 @@ data: {}, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MediaEvents = void 0; | ||
exports.ExtendsEvents = exports.MediaEvents = void 0; | ||
var MediaEvents; | ||
@@ -30,1 +30,11 @@ (function (MediaEvents) { | ||
})(MediaEvents = exports.MediaEvents || (exports.MediaEvents = {})); | ||
/** | ||
* 扩展事件 | ||
*/ | ||
var ExtendsEvents; | ||
(function (ExtendsEvents) { | ||
ExtendsEvents["USER_ACTION"] = "useraction"; | ||
ExtendsEvents["PROGRESS_DRAG_START"] = "progressdragstart"; | ||
ExtendsEvents["PROGRESS_DRAG_END"] = "progressdragend"; | ||
ExtendsEvents["ACTIVE"] = "active"; | ||
})(ExtendsEvents = exports.ExtendsEvents || (exports.ExtendsEvents = {})); |
@@ -17,4 +17,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VERSION = exports.PKG = exports.PlayerModes = void 0; | ||
__exportStar(require("./errorCode"), exports); | ||
exports.DefaultInteractiveConfig = exports.PLAY_BTN_MODE = exports.PLAY_BTN_POSITION = exports.ControlsStates = exports.ControlsStateClass = exports.InteractStates = exports.VERSION = exports.PKG = exports.PlayerModes = void 0; | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
__exportStar(require("./events"), exports); | ||
@@ -25,4 +25,59 @@ var PlayerModes; | ||
PlayerModes["PORTRAIT"] = "portrait"; | ||
PlayerModes["FULLSCREEN"] = "fullscreen"; | ||
})(PlayerModes = exports.PlayerModes || (exports.PlayerModes = {})); | ||
exports.PKG = 'veplayer-mp-douyin'; | ||
exports.VERSION = '1.0.6'; | ||
exports.PKG = 'douyin'; | ||
exports.VERSION = '1.2.3-alpha.0'; | ||
/** | ||
* 控制栏状态枚举 | ||
*/ | ||
var InteractStates; | ||
(function (InteractStates) { | ||
InteractStates["FOCUS"] = "focus"; | ||
InteractStates["BLUR"] = "blur"; | ||
InteractStates["IMMERSE"] = "immerse"; | ||
})(InteractStates = exports.InteractStates || (exports.InteractStates = {})); | ||
/** | ||
* 控制栏状态对应的类名枚举 | ||
*/ | ||
var ControlsStateClass; | ||
(function (ControlsStateClass) { | ||
ControlsStateClass["FOCUS"] = "xg-state-focus"; | ||
ControlsStateClass["BLUR"] = "xg-state-blur"; | ||
ControlsStateClass["IMMERSE"] = "xg-state-immerse"; | ||
})(ControlsStateClass = exports.ControlsStateClass || (exports.ControlsStateClass = {})); | ||
/** | ||
* @description 控制栏枚举值 | ||
*/ | ||
var ControlsStates; | ||
(function (ControlsStates) { | ||
ControlsStates["NATIVE"] = "native"; | ||
ControlsStates["CUSTOM"] = "custom"; | ||
ControlsStates["FOCUS"] = "focus"; | ||
ControlsStates["HIDDEN"] = "hidden"; | ||
ControlsStates["BLUR"] = "blur"; | ||
ControlsStates["IMMERSE"] = "immerse"; | ||
})(ControlsStates = exports.ControlsStates || (exports.ControlsStates = {})); | ||
/** | ||
* 播放按钮位置枚举 | ||
*/ | ||
var PLAY_BTN_POSITION; | ||
(function (PLAY_BTN_POSITION) { | ||
PLAY_BTN_POSITION["CENTER"] = "center"; | ||
PLAY_BTN_POSITION["BOTTOM"] = "bottom"; | ||
PLAY_BTN_POSITION["CENTER_BOTTOM"] = "center-bottom"; | ||
})(PLAY_BTN_POSITION = exports.PLAY_BTN_POSITION || (exports.PLAY_BTN_POSITION = {})); | ||
/** | ||
* 播放按钮位置枚举 | ||
* PLAY_BTN_MODE | ||
*/ | ||
var PLAY_BTN_MODE; | ||
(function (PLAY_BTN_MODE) { | ||
PLAY_BTN_MODE["NORMAL"] = "normal"; | ||
PLAY_BTN_MODE["BG"] = "bg"; | ||
})(PLAY_BTN_MODE = exports.PLAY_BTN_MODE || (exports.PLAY_BTN_MODE = {})); | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
exports.DefaultInteractiveConfig = { | ||
immersive: false, | ||
delay: 10000, | ||
focusDelay: 0, // 隐藏态进入focus态是否自动 | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable no-magic-numbers */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable max-len */ | ||
@@ -10,5 +12,6 @@ /* eslint-disable object-shorthand */ | ||
const collectorBehavior_1 = require("./behaviors/collectorBehavior"); | ||
const interact_behavior_1 = require("./behaviors/interact_behavior"); | ||
const industryBehavior_1 = require("./behaviors/industryBehavior"); | ||
const index_1 = require("./enums/index"); | ||
const error_1 = require("./utils/error"); | ||
const xgerror_1 = require("./xgerror"); | ||
const index_2 = require("./utils/index"); | ||
@@ -18,21 +21,9 @@ const request_1 = require("./request"); | ||
(0, index_2.XgComponent)({ | ||
behaviors: [videoBehavior_1.default, douyinBehavior_1.default, collectorBehavior_1.default, industryBehavior_1.default], | ||
behaviors: [videoBehavior_1.default, douyinBehavior_1.default, collectorBehavior_1.default, interact_behavior_1.default, industryBehavior_1.default], | ||
properties: { | ||
controls: { | ||
type: String, | ||
optionalTypes: [Boolean], | ||
value: 'custom', | ||
observer(newVal, _changedPath) { | ||
const { customControls } = this.data; | ||
// console.log(`!!!!!Player${this.data.videoId} controls:`, `newVal:${newVal}, oldVal:${oldVal}, !!newVal:${!!newVal} customControls:${customControls}`); | ||
if (!customControls) { | ||
this.setData({ | ||
customControls: newVal === 'native' ? false : newVal, | ||
}); | ||
} | ||
if (newVal !== 'native') { | ||
newVal ? this.focusPlayer(false) : this.blurPlayer(); | ||
} | ||
}, | ||
}, | ||
// controls: { | ||
// type: String, | ||
// optionalTypes: [Boolean], | ||
// value: 'custom', | ||
// }, | ||
// tag的类型,用来继承其他标签 | ||
@@ -64,10 +55,9 @@ // 支持的值 'video', 'video-player' | ||
observer(newVal, _changedPath) { | ||
// console.log('definitionUrls:', newVal, oldVal); | ||
this.setData({ definitionUrls: newVal }); | ||
}, | ||
}, | ||
autoBlurTime: { | ||
type: Number, | ||
value: 10000, | ||
}, | ||
// autoBlurTime: { | ||
// type: Number, | ||
// value: 10000, | ||
// }, | ||
/** | ||
@@ -93,2 +83,7 @@ * @description 是否允许空资源起播 | ||
}, | ||
// 当前实例是否是激活状态 | ||
isActive: { | ||
type: Boolean, | ||
value: true, | ||
}, | ||
}, | ||
@@ -123,3 +118,2 @@ data: { | ||
playbackDefinitionList: undefined, | ||
isFocus: true, | ||
customControls: false, | ||
@@ -131,8 +125,8 @@ // 可否可使用video以外的其他tagType | ||
observers: { | ||
error: function (err) { | ||
if (err instanceof error_1.XGError && err.severity === error_1.ErrorSeverity.INTERRUPTED) { | ||
// console.log('error:', err); | ||
this._emitEvt(index_1.MediaEvents.ERROR, err); | ||
} | ||
}, | ||
// error: function (err) { | ||
// if (err?.severity === ErrorSeverity.INTERRUPTED) { | ||
// this.triggerEvent(MediaEvents.ERROR, err) | ||
// this.triggerCollector(MediaEvents.ERROR, err) | ||
// } | ||
// }, | ||
seeking: function (flag) { | ||
@@ -147,2 +141,7 @@ this._emitEvt(flag ? index_1.MediaEvents.SEEKING : index_1.MediaEvents.SEEKCOMPLETE); | ||
}, | ||
'isActive': function () { | ||
const { isActive } = this.data; | ||
index_2.VE_DEBUGGER.log('isActive change', isActive); | ||
this.triggerCollector(index_1.ExtendsEvents.ACTIVE, { isActive }); | ||
}, | ||
'currentSrc': function () { | ||
@@ -179,3 +178,2 @@ const { currentSrc, src, videoId } = this.data; | ||
else if (playAuthToken) { | ||
// console.log('ServiceRequest: ', playDomain, playAuthToken); | ||
this.setData({ | ||
@@ -194,2 +192,3 @@ isLoadingData: true, | ||
}); | ||
this._emitError({}, data.error); | ||
} | ||
@@ -206,2 +205,15 @@ else { | ||
}, | ||
// 'controls': function() { | ||
// const { customControls, controls } = this.data | ||
// VE_DEBUGGER.log(`!!!!!Player${this.data.videoId} controls:${controls}`, `newVal:${controls} customControls:${customControls}`) | ||
// if (!customControls) { | ||
// VE_DEBUGGER.log('set customControls') | ||
// this.setData({ | ||
// customControls: controls !== 'native', | ||
// }) | ||
// } | ||
// if (controls !== 'native') { | ||
// controls ? this.focusPlayer(false) : this.blurPlayer() | ||
// } | ||
// }, | ||
}, | ||
@@ -223,4 +235,3 @@ lifetimes: { | ||
const { videoId, videoProps, isFullScreen } = this.data; | ||
const { controls } = this.properties; | ||
// console.log('>>>>Player attached', this.properties.loggerInfo) | ||
// const { controls } = this.properties | ||
let _videoId = videoId || componentId; | ||
@@ -232,5 +243,5 @@ if (!_videoId) { | ||
videoId: _videoId, | ||
customControls: controls !== 'native' ? controls : false, | ||
// customControls: controls !== 'native', | ||
}); | ||
const videoCtx = tt.createVideoContext(_videoId, this); | ||
const videoCtx = tt.createVideoContext(_videoId, tagType === 'video' ? this : this.videoPlayer); | ||
const propsClassNames = ((_a = videoProps.className) === null || _a === void 0 ? void 0 : _a.split(' ')) || []; | ||
@@ -269,7 +280,7 @@ const classNames = [ | ||
ready() { | ||
const { controls, src, allowNullSource, playAuthToken, veDebugger, autoplay } = this.properties; | ||
const { src, allowNullSource, playAuthToken, veDebugger, autoplay } = this.properties; | ||
const { currentSrc, videoId } = this.data; | ||
index_2.VE_DEBUGGER.debugger = veDebugger; | ||
this.updateStatusOfShowLoading(); | ||
!!controls && this.focusPlayer(); | ||
// !!controls && this.focusPlayer() | ||
index_2.VE_DEBUGGER.log('ready', videoId, !!this.media, `isHidden:${allowNullSource && !src && !currentSrc} autoplay:${autoplay}`); | ||
@@ -306,4 +317,5 @@ // 允许空地址起播,且src和currentSrc都是空的时候隐藏video标签 | ||
const message = (e === null || e === void 0 ? void 0 : e.stack) || (e === null || e === void 0 ? void 0 : e.message) || ''; | ||
const error = new error_1.XGError(error_1.ErrorCategory.UNKNOWN, index_1.ErrorCodes.Component_LIFETIME_ERROR, message); | ||
error.severity = error_1.ErrorSeverity.IGNORABLE; | ||
const error = (0, xgerror_1.XGError)(xgerror_1.ErrorCategory.UNKNOWN, xgerror_1.ErrorCodes.Component_LIFETIME_ERROR, message); | ||
error.severity = xgerror_1.ErrorSeverity.IGNORABLE; | ||
this._emitError(e, error); | ||
this.setData({ | ||
@@ -321,26 +333,11 @@ error: error, | ||
}, | ||
focusPlayer(needAutoHide = true) { | ||
const { autoBlurTime } = this.properties; | ||
const { isFocus } = this.data; | ||
if (this.fTimer) { | ||
clearTimeout(this.fTimer); | ||
this.fTimer = null; | ||
} | ||
// console.log(`!!!!!Player${videoId} focusPlayer`, `isFocus:${isFocus}, controls:${controls}`) | ||
needAutoHide && | ||
(this.fTimer = setTimeout(() => { | ||
this.blurPlayer(); | ||
}, autoBlurTime)); | ||
!isFocus && | ||
this.setData({ | ||
isFocus: true, | ||
}); | ||
getVideoPlayer(ref) { | ||
this.videoPlayer = ref; | ||
}, | ||
blurPlayer() { | ||
const { isFocus } = this.data; | ||
// console.log(`!!!!!Player${videoId} blurPlayer`, `isFocus:${isFocus} controls:${this.properties.controls}`) | ||
if (isFocus) { | ||
this.setData({ | ||
isFocus: false, | ||
}); | ||
_emitError(e, err) { | ||
index_2.VE_DEBUGGER.log('_emitError', err, e); | ||
if ((err === null || err === void 0 ? void 0 : err.severity) === xgerror_1.ErrorSeverity.INTERRUPTED) { | ||
const evData = Object.assign(Object.assign({ e, data: this.data }, e.detail), err); | ||
this.triggerEvent(index_1.MediaEvents.ERROR, evData); | ||
this.triggerCollector(index_1.MediaEvents.ERROR, evData); | ||
} | ||
@@ -352,29 +349,27 @@ }, | ||
_emitEvt(evName, e) { | ||
const evData = { e, data: this.data }; | ||
const evData = Object.assign({ e, data: this.data }, e.detail); | ||
// Fire event to context | ||
this.media.emit(evName, evData); | ||
evName !== index_1.MediaEvents.ERROR && this.triggerCollector(evName, e); | ||
this.triggerCollector(evName, e); | ||
// The event is a component prop event for 'bind***' | ||
this.triggerEvent(evName, evData); | ||
}, | ||
onTap() { | ||
const { mode, loadedMeta, paused, isFocus, ended } = this.data; | ||
const { controls, enablePlayGesture } = this.properties; | ||
if (enablePlayGesture && mode === "portrait" /* PlayerModes.PORTRAIT */) { | ||
if (loadedMeta) { | ||
if (paused || ended) { | ||
this.media.play(); | ||
} | ||
else { | ||
this.media.pause(); | ||
} | ||
} | ||
} | ||
// console.log(`!!!!!Player${videoId} onTap`, `controls:${controls}, data.controls:${this.data.controls}, isFocus:${isFocus}`); | ||
if (!isFocus && controls) { | ||
this.focusPlayer(); | ||
} | ||
}, | ||
// onTap() { | ||
// const { mode, loadedMeta, paused, isFocus, ended } = this.data | ||
// const { controls, enablePlayGesture } = this.properties | ||
// if (enablePlayGesture && mode === PlayerModes.PORTRAIT) { | ||
// if (loadedMeta) { | ||
// if (paused || ended) { | ||
// this.media.play() | ||
// } else { | ||
// this.media.pause() | ||
// } | ||
// } | ||
// } | ||
// if (!isFocus && controls) { | ||
// this.focusPlayer() | ||
// } | ||
// }, | ||
onError(e) { | ||
let { errMsg } = e.detail; | ||
const { errMsg, errNo } = e.detail; | ||
const { isLoadingData, currentSrc, allowNullSource, videoId } = this.data; | ||
@@ -386,14 +381,8 @@ index_2.VE_DEBUGGER.log(videoId, 'onError', videoId, `isLoadingData:${isLoadingData} currentSrc:${!!currentSrc} allowNullSource:${allowNullSource} isReturn:${!currentSrc && (allowNullSource || isLoadingData)}`, e.detail); | ||
} | ||
let errCode; | ||
if (/Format error$/gi.test(errMsg)) { | ||
errCode = index_1.ErrorCodes.MEDIA_ERR_FORMAT_ERROR; | ||
errMsg = '格式错误'; | ||
} | ||
else { | ||
errCode = index_1.ErrorCodes.MEDIA_ERR_UNKNOWN; | ||
errMsg = '其他错误'; | ||
} | ||
this.triggerCollector(index_1.MediaEvents.ERROR, e, { errCode, errMsg }); | ||
const errCode = e.detail.errCode || 0; | ||
const isIndustryErrCode = (String(errNo)).startsWith('1567'); | ||
const error = (0, xgerror_1.XGError)(isIndustryErrCode ? xgerror_1.ErrorCategory.INDUSTRY : xgerror_1.ErrorCategory.MEDIA, errCode, errMsg, e.detail); | ||
this._emitError(e, error); | ||
this.setData({ | ||
error: new error_1.XGError(error_1.ErrorCategory.MEDIA, errCode, errMsg), | ||
error, | ||
}); | ||
@@ -404,3 +393,2 @@ }, | ||
const { duration } = e.detail; | ||
// console.log('onLoadedMetadata', e.detail) | ||
this.setData({ | ||
@@ -420,3 +408,2 @@ loadedMeta: true, | ||
const { firstPlay } = this.data; | ||
const { controls } = this.properties; | ||
const obj = { | ||
@@ -432,9 +419,9 @@ paused: false, | ||
this._emitEvt(index_1.MediaEvents.PLAY, e); | ||
// console.log(`!!!!!Player${videoId} onPlay`, `isFocus:${isFocus}, controls:${controls}, data.controls:${this.data.controls}`) | ||
!!controls && this.focusPlayer(); | ||
// !!controls && this.focusPlayer() | ||
this.switchControlsOnPlay(); | ||
}, | ||
onPause(e) { | ||
const { controls } = this.properties; | ||
// console.log(`!!!!!Player${videoId} onPause`, `isFocus:${isFocus}, controls:${controls}, data.controls:${this.data.controls}`) | ||
!!controls && this.focusPlayer(false); | ||
// const { controls } = this.properties | ||
// !!controls && this.focusPlayer(false) | ||
this.switchControlsOnPause(); | ||
this.setData({ | ||
@@ -448,3 +435,2 @@ paused: true, | ||
const { currentTime, duration } = e.detail; | ||
// console.log('Math.floor((currentTime / duration) * 100)', Math.floor((currentTime / duration) * 100)) | ||
const data = { | ||
@@ -500,2 +486,7 @@ currentTime: currentTime || 0, | ||
onControlsToggle(e) { | ||
const { customControls } = this.data; | ||
// 自定义控制栏不在此处做响应 | ||
if (customControls) { | ||
return; | ||
} | ||
this._emitEvt(index_1.MediaEvents.CONTROLSTOGGLE, e); | ||
@@ -512,5 +503,2 @@ }, | ||
}, | ||
handleTap() { | ||
// console.log('>>>>>Index handleTap'); | ||
}, | ||
updateStatusOfShowLoading() { | ||
@@ -517,0 +505,0 @@ const { loadedMeta, seeking, paused } = this.data; |
@@ -6,3 +6,3 @@ "use strict"; | ||
properties: { | ||
hide: { | ||
isHidden: { | ||
type: Boolean, | ||
@@ -9,0 +9,0 @@ value: true, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const index_1 = require("../../utils/index"); | ||
const plugin_useraction_behavior_1 = require("../../behaviors/plugin_useraction_behavior"); | ||
(0, index_1.XgComponent)({ | ||
behaviors: [], | ||
behaviors: [plugin_useraction_behavior_1.default], | ||
properties: { | ||
hide: { | ||
isHidden: { | ||
type: Boolean, | ||
@@ -14,11 +15,32 @@ value: true, | ||
}, | ||
mode: { | ||
type: String, | ||
value: "portrait" /* PlayerModes.PORTRAIT */, | ||
// 竖屏或者全屏的时候增加底部边距处理 | ||
observer(newVal, _oldVal, _changedPath) { | ||
if (newVal === "portrait" /* PlayerModes.PORTRAIT */ || newVal === "fullscreen" /* PlayerModes.FULLSCREEN */) { | ||
this.setData({ | ||
modeClass: 'xgplayer-controls-portrait', | ||
}); | ||
} | ||
else { | ||
this.setData({ | ||
modeClass: '', | ||
}); | ||
} | ||
}, | ||
}, | ||
}, | ||
data: { | ||
stateClass: 'xgplayer-controls-hide', | ||
// stateClass: 'xgplayer-controls-hide', | ||
stateClass: 'xgplayer-controls-portrait', | ||
}, | ||
lifetimes: { | ||
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名 | ||
// attached: function () { }, | ||
// moved: function () { }, | ||
// detached: function () { }, | ||
created() { | ||
this.pluginName = 'Controls'; | ||
}, | ||
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名 | ||
// attached: function () { }, | ||
// moved: function () { }, | ||
// detached: function () { }, | ||
}, | ||
@@ -34,3 +56,3 @@ pageLifetimes: { | ||
this.setData({ | ||
stateClass: 'xgplayer-controls-hide', | ||
isHidden: true, | ||
}); | ||
@@ -40,3 +62,3 @@ }, | ||
this.setData({ | ||
stateClass: '', | ||
isHidden: false, | ||
}); | ||
@@ -43,0 +65,0 @@ }, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable no-magic-numbers */ | ||
/* eslint-disable @typescript-eslint/no-magic-numbers */ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
const videoEventsBehavior_1 = require("../../behaviors/videoEventsBehavior"); | ||
const index_1 = require("../../tool/index"); | ||
const index_2 = require("../../utils/index"); | ||
const index_3 = require("../../enums/index"); | ||
(0, index_2.XgComponent)({ | ||
@@ -60,3 +64,3 @@ behaviors: [videoEventsBehavior_1.default], | ||
ready() { | ||
// console.log('!!!![progress]>>>ready', this.properties.videoId) | ||
this.dragStartTime = -1; | ||
this.addMediaEvents(index_1.default); | ||
@@ -118,11 +122,23 @@ }, | ||
const { duration } = this.data; | ||
this.setData({ | ||
isActive: false, | ||
}); | ||
if (!duration) { | ||
this.dragStartTime = -1; | ||
return; | ||
} | ||
const seekTime = value * duration / 100; | ||
// console.log('>>>onChange', e.detail, value, this.data.duration, seekTime) | ||
this.triggerEvent(index_3.ExtendsEvents.PROGRESS_DRAG_END, { | ||
startTime: this.dragStartTime, | ||
endTime: seekTime, | ||
actionType: 'seekend', | ||
componentName: 'progress', | ||
props: 'currentTime', | ||
from: this.dragStartTime, | ||
to: seekTime, | ||
}); | ||
this.setData({ | ||
isActive: false, | ||
isSeeking: true, | ||
}); | ||
this.dragStartTime = -1; | ||
this.media.seek(seekTime); | ||
@@ -137,2 +153,12 @@ }, | ||
const cTime = value * this.data.duration / 100; | ||
if (this.dragStartTime < 0) { | ||
this.dragStartTime = cTime; | ||
this.triggerEvent(index_3.ExtendsEvents.PROGRESS_DRAG_START, { | ||
startTime: cTime, | ||
actionType: 'seekstart', | ||
componentName: 'progress', | ||
props: 'currentTime', | ||
from: cTime, | ||
}); | ||
} | ||
this.setData({ | ||
@@ -143,3 +169,8 @@ isActive: true, | ||
}, | ||
onTouchEnd() { | ||
this.setData({ | ||
isActive: false, | ||
}); | ||
}, | ||
}, | ||
}); |
@@ -5,5 +5,6 @@ "use strict"; | ||
const videoEventsBehavior_1 = require("../../behaviors/videoEventsBehavior"); | ||
const plugin_useraction_behavior_1 = require("../../behaviors/plugin_useraction_behavior"); | ||
const index_2 = require("../../tool/index"); | ||
(0, index_1.XgComponent)({ | ||
behaviors: [videoEventsBehavior_1.default], | ||
behaviors: [videoEventsBehavior_1.default, plugin_useraction_behavior_1.default], | ||
/** | ||
@@ -21,2 +22,16 @@ * 组件的属性列表 | ||
/** | ||
* 所在位置 | ||
*/ | ||
position: { | ||
type: String, | ||
value: 'center', | ||
}, | ||
/** | ||
* 展示风格 | ||
*/ | ||
mode: { | ||
type: String, | ||
value: "normal" /* PLAY_BTN_MODE.NORMAL */, | ||
}, | ||
/** | ||
* 展示大小 | ||
@@ -34,8 +49,2 @@ */ | ||
value: true, | ||
observer(newVal, _changedPath) { | ||
const data = { | ||
className: newVal ? 'xg-paused' : 'xg-playing', | ||
}; | ||
this.setData(data); | ||
}, | ||
}, | ||
@@ -49,29 +58,17 @@ }, | ||
ctx: null, | ||
className: 'xg-icon-play', | ||
sizeClassName: 'xg-icon-middle', | ||
styleClassName: '', | ||
}, | ||
lifetimes: { | ||
created() { | ||
this.pluginName = 'PlayButton'; | ||
}, | ||
ready() { | ||
const { size } = this.data; | ||
const style = { | ||
width: '', | ||
height: '', | ||
const { size, position, mode } = this.properties; | ||
index_1.VE_DEBUGGER.log(this.pluginName, 'ready', `size:${size}, position:${position}, mode:${mode}`); | ||
const data = { | ||
sizeClassName: this.getSizeClass(size), | ||
styleClassName: this.getPositionClass(position, mode), | ||
}; | ||
switch (size) { | ||
case 'large': | ||
this.setData({ | ||
sizeClassName: 'xg-icon-large', | ||
}); | ||
break; | ||
case 'small': | ||
this.setData({ | ||
sizeClassName: 'xg-icon-small', | ||
}); | ||
break; | ||
default: | ||
// | ||
} | ||
this.setData({ | ||
style: (0, index_1.styleToText)(style), | ||
}); | ||
this.setData(data); | ||
this.addMediaEvents(index_2.default); | ||
@@ -87,4 +84,42 @@ }, | ||
methods: { | ||
onClick() { | ||
getSizeClass(size) { | ||
let ret = ''; | ||
switch (size) { | ||
case 'large': | ||
ret = 'xg-icon-large'; | ||
break; | ||
case 'small': | ||
ret = 'xg-icon-small'; | ||
break; | ||
default: | ||
ret = 'xg-icon-middle'; | ||
} | ||
return ret; | ||
}, | ||
getPositionClass(position, mode) { | ||
let ret = ''; | ||
switch (position) { | ||
case "center" /* PLAY_BTN_POSITION.CENTER */: | ||
ret = 'xg-play-center'; | ||
break; | ||
case "center-bottom" /* PLAY_BTN_POSITION.CENTER_BOTTOM */: | ||
ret = 'xg-play-bottom'; | ||
break; | ||
default: | ||
ret = 'xg-play-center'; | ||
} | ||
index_1.VE_DEBUGGER.log(this.pluginName, '[getPositionClass]', `class:${ret} position:${position} mode:${mode}`); | ||
if (mode === "bg" /* PLAY_BTN_MODE.BG */) { | ||
ret = (0, index_1.classNames)(ret, 'xg-icon-bg'); | ||
} | ||
return ret; | ||
}, | ||
onClick(e) { | ||
const { paused } = this.data; | ||
const data = { | ||
actionType: 'switch_play_pause', | ||
props: 'paused', | ||
from: paused, | ||
to: !paused, | ||
}; | ||
if (this.media) { | ||
@@ -98,4 +133,5 @@ if (paused) { | ||
} | ||
this.triggerUserAction('playbtn', e, data); | ||
}, | ||
}, | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serviceRequest = void 0; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
const xgplayer_service_miniprogram_1 = require("xgplayer-service-miniprogram"); | ||
const index_1 = require("../enums/index"); | ||
const error_1 = require("../utils/error"); | ||
const index_1 = require("../xgerror/index"); | ||
function serviceRequest(playAuthToken, playDomain) { | ||
@@ -13,2 +13,3 @@ return new Promise((resolve) => { | ||
const data = (res === null || res === void 0 ? void 0 : res.Data) || res || {}; | ||
const metaData = (res === null || res === void 0 ? void 0 : res.ResponseMetadata) || {}; | ||
if (Array.isArray(data.PlayInfoList)) { | ||
@@ -28,9 +29,14 @@ const defaultDef = data.PlayInfoList[0]; | ||
retData.playbackDefinitionList = qualityList; | ||
// retData.error = new XGError(ErrorCategory.SERVICE, ErrorCodes.SERVICE_PLAYINFOLIST_EMPTY, 'FOR_TEST') | ||
} | ||
retData.error = (0, index_1.XGError)(index_1.ErrorCategory.SERVICE, index_1.ErrorCodes.SERVICE_PLAYINFOLIST_EMPTY, 'Service Data Error'); | ||
resolve(retData); | ||
} | ||
else { | ||
const e = metaData.Error ? { | ||
message: metaData.Error.Message, | ||
} : { | ||
message: 'Service Error', | ||
}; | ||
const retData = { | ||
error: new error_1.XGError(error_1.ErrorCategory.SERVICE, index_1.ErrorCodes.SERVICE_PLAYINFOLIST_EMPTY, 'Service Error'), | ||
error: (0, index_1.XGError)(index_1.ErrorCategory.SERVICE, index_1.ErrorCodes.SERVICE_PLAYINFOLIST_EMPTY, e.message), | ||
}; | ||
@@ -41,4 +47,5 @@ resolve(retData); | ||
.catch(() => { | ||
const error = (0, index_1.XGError)(index_1.ErrorCategory.SERVICE, index_1.ErrorCodes.SERVICE_UNKNOWN, 'Service Request Running Error'); | ||
const retData = { | ||
error: new error_1.XGError(error_1.ErrorCategory.SERVICE, index_1.ErrorCodes.SERVICE_UNKNOWN, 'Service Error'), | ||
error, | ||
}; | ||
@@ -45,0 +52,0 @@ resolve(retData); |
@@ -17,3 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.format = exports.padStart = void 0; | ||
exports.getTouch = exports.classNames = exports.format = exports.padStart = void 0; | ||
/* eslint-disable no-magic-numbers */ | ||
@@ -66,1 +66,28 @@ /* eslint-disable @typescript-eslint/no-magic-numbers */ | ||
exports.format = format; | ||
function typeOf(obj) { | ||
// eslint-disable-next-line no-lookahead-lookbehind-regexp/no-lookahead-lookbehind-regexp | ||
return Object.prototype.toString.call(obj).match(/([^\s.*]+)(?=]$)/g)[0]; | ||
} | ||
function classNames(...args) { | ||
const classnames = []; | ||
args.forEach((item) => { | ||
if (typeOf(item) === 'String') { | ||
classnames.push(item); | ||
} | ||
else if (typeOf(item) === 'Object') { | ||
Object.keys(item).forEach(key => { | ||
if (item[key]) { | ||
classnames.push(key); | ||
} | ||
}); | ||
} | ||
}); | ||
return classnames.join(' '); | ||
} | ||
exports.classNames = classNames; | ||
function getTouch(e) { | ||
if (e.touches && e.touches.length > 0) { | ||
return e.touches[0]; | ||
} | ||
} | ||
exports.getTouch = getTouch; |
{ | ||
"name": "veplayer-mp-douyin", | ||
"version": "1.0.6", | ||
"version": "1.2.3-alpha.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "miniprogramType": "tt-npm", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
157875
59
2967
2