veplayer-mp-wechat
Advanced tools
Comparing version 1.0.3-alpha.0 to 1.0.4-alpha.0
@@ -14,5 +14,5 @@ "use strict"; | ||
value: {}, | ||
observer(newVal, oldVal, _changedPath) { | ||
observer(newVal, _changedPath) { | ||
this.collector && this.collector.setConfig(newVal); | ||
} | ||
}, | ||
}, | ||
@@ -22,4 +22,4 @@ // 屏蔽日志配置验证,默认false,true的时候可以不配置日志 | ||
type: Boolean, | ||
value: false | ||
} | ||
value: false, | ||
}, | ||
}, | ||
@@ -32,3 +32,3 @@ data: {}, | ||
this.verifyCollector(); | ||
} | ||
}, | ||
}, | ||
@@ -69,7 +69,7 @@ methods: { | ||
this.setData({ | ||
error: error | ||
error, | ||
}); | ||
} | ||
} | ||
} | ||
}, | ||
}, | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* 这里维护所有原始video属性,使用这个Behavior的目的是为了区分开自定义组件属性减少混乱 | ||
* | ||
* 原生Video组件属性说明: | ||
* https://developers.weixin.qq.com/miniprogram/dev/component/video.html | ||
*/ | ||
exports.default = Behavior({ | ||
@@ -8,5 +14,2 @@ properties: { | ||
value: '', | ||
observer(newVal, oldVal, _changedPath) { | ||
// console.log('src:', newVal, oldVal); | ||
} | ||
}, | ||
@@ -20,3 +23,3 @@ /** | ||
type: Number, | ||
value: 0 | ||
value: 0, | ||
}, | ||
@@ -26,27 +29,27 @@ danmuList: Array, | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
enableDanmu: { | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
autoplay: { | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
loop: { | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
muted: { | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
initialTime: { | ||
type: Number, | ||
value: 0 | ||
value: 0, | ||
}, | ||
pageGesture: { | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
@@ -59,23 +62,23 @@ /** | ||
type: Boolean, | ||
value: true | ||
value: true, | ||
}, | ||
showFullscreenBtn: { | ||
type: Boolean, | ||
value: true | ||
value: true, | ||
}, | ||
showPlayBtn: { | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
showCenterPlayBtn: { | ||
type: Boolean, | ||
value: true | ||
value: true, | ||
}, | ||
enableProgressGesture: { | ||
type: Boolean, | ||
value: true | ||
value: true, | ||
}, | ||
objectFit: { | ||
type: String, | ||
value: 'contain' | ||
value: 'contain', | ||
}, | ||
@@ -89,3 +92,3 @@ /** | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
@@ -95,27 +98,27 @@ title: String, | ||
type: String, | ||
value: 'center' | ||
value: 'center', | ||
}, | ||
enablePlayGesture: { | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
autoPauseIfNavigate: { | ||
type: Boolean, | ||
value: true | ||
value: true, | ||
}, | ||
autoPauseIfOpenNative: { | ||
type: Boolean, | ||
value: true | ||
value: true, | ||
}, | ||
vslideGesture: { | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
vslideGestureInFullscreen: { | ||
type: Boolean, | ||
value: true | ||
value: true, | ||
}, | ||
showBottomProgress: { | ||
type: Boolean, | ||
value: true | ||
value: true, | ||
}, | ||
@@ -126,27 +129,27 @@ adUnitId: String, | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
pictureInPictureMode: { | ||
type: String, | ||
optionalTypes: [Array] | ||
optionalTypes: [Array], | ||
}, | ||
pictureInPictureShowProgress: { | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
enableAutoRotation: { | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
showScreenLockButton: { | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
showSnapshotButton: { | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
showBackgroundPlaybackButton: { | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
@@ -156,31 +159,31 @@ backgroundPoster: String, | ||
type: String, | ||
value: 'no-referrer' | ||
value: 'no-referrer', | ||
}, | ||
isDrm: { | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
isLive: { | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
provisionUrl: { | ||
type: String | ||
type: String, | ||
}, | ||
certificateUrl: { | ||
type: String | ||
type: String, | ||
}, | ||
licenseUrl: { | ||
type: String | ||
type: String, | ||
}, | ||
preferredPeakBitRate: { | ||
type: Number | ||
type: Number, | ||
}, | ||
needLoading: { | ||
type: Boolean, | ||
value: true | ||
} | ||
value: true, | ||
}, | ||
}, | ||
data: {}, | ||
methods: {} | ||
methods: {}, | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable object-shorthand */ | ||
/** | ||
@@ -12,3 +13,3 @@ * @description 用于绑定或者解除绑定video相关事件 | ||
type: String, | ||
value: '' | ||
value: '', | ||
}, | ||
@@ -18,4 +19,2 @@ }, | ||
'videoId': function (newVal, oldVal) { | ||
const { videoId } = this.properties; | ||
// console.log('!!!!observers videoId', newVal, oldVal, videoId, videoId === newVal) | ||
if (newVal === oldVal || !newVal) { | ||
@@ -26,3 +25,3 @@ return; | ||
this.addMediaEvents(); | ||
} | ||
}, | ||
}, | ||
@@ -46,3 +45,3 @@ methods: { | ||
key: index_1.MediaEvents[key], | ||
funName: funName | ||
funName: funName, | ||
}); | ||
@@ -68,4 +67,4 @@ }); | ||
this.media = null; | ||
} | ||
} | ||
}, | ||
}, | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ErrorCodes = void 0; | ||
/* eslint-disable unicorn/filename-case */ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
/* eslint-disable no-magic-numbers */ | ||
var ErrorCodes; | ||
@@ -12,5 +15,5 @@ (function (ErrorCodes) { | ||
ErrorCodes[ErrorCodes["Collector_NOT_CONFIGURED"] = 9] = "Collector_NOT_CONFIGURED"; | ||
//////////////////////////////////////////////////////////////////////// | ||
//////////////////////// 1000 -> 1999 = MEDIA ////////////////////////// | ||
//////////////////////////////////////////////////////////////////////// | ||
// ////////////////////////////////////////////////////////////////////// | ||
// ////////////////////// 1000 -> 1999 = MEDIA ////////////////////////// | ||
// ////////////////////////////////////////////////////////////////////// | ||
/** | ||
@@ -42,7 +45,7 @@ * https://developers.weixin.qq.com/minigame/dev/api/media/video/Video.onError.html | ||
// MEDIA_ELEMENT_ERROR: | ||
//////////////////////////////////////////////////////////////////////// | ||
//////////////////////// 1000 -> 1999 = SERVICE //////////////////////// | ||
//////////////////////////////////////////////////////////////////////// | ||
// ////////////////////////////////////////////////////////////////////// | ||
// ////////////////////// 1000 -> 1999 = SERVICE //////////////////////// | ||
// ////////////////////////////////////////////////////////////////////// | ||
ErrorCodes[ErrorCodes["SERVICE_UNKNOWN"] = 2000] = "SERVICE_UNKNOWN"; | ||
ErrorCodes[ErrorCodes["SERVICE_PLAYINFOLIST_EMPTY"] = 2001] = "SERVICE_PLAYINFOLIST_EMPTY"; | ||
})(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {})); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable max-len */ | ||
/* eslint-disable object-shorthand */ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
const eventemitter3_1 = require("eventemitter3"); | ||
const xgplayer_service_miniprogram_1 = require("xgplayer-service-miniprogram"); | ||
const videoBehavior_1 = require("./behaviors/videoBehavior"); | ||
@@ -10,3 +12,4 @@ const collectorBehavior_1 = require("./behaviors/collectorBehavior"); | ||
const index_2 = require("./utils/index"); | ||
const index_3 = require("./tool/index"); | ||
const index_3 = require("./request/index"); | ||
const index_4 = require("./tool/index"); | ||
(0, index_2.XgComponent)({ | ||
@@ -16,6 +19,6 @@ behaviors: ['wx://component-export', videoBehavior_1.default, collectorBehavior_1.default], | ||
controls: { | ||
type: String || Boolean, | ||
type: String, | ||
optionalTypes: [Boolean], | ||
value: 'custom', | ||
observer(newVal, oldVal, _changedPath) { | ||
observer(newVal, _changedPath) { | ||
const { customControls } = this.data; | ||
@@ -25,3 +28,3 @@ // console.log(`>>>Player${this.data.videoId} controls:`, `newVal:${newVal}, oldVal:${oldVal}, !!newVal:${!!newVal} customControls:${customControls}`); | ||
this.setData({ | ||
customControls: newVal === 'native' ? false : newVal | ||
customControls: newVal === 'native' ? false : newVal, | ||
}); | ||
@@ -32,19 +35,19 @@ } | ||
} | ||
} | ||
}, | ||
}, | ||
mode: { | ||
type: String, | ||
value: "portrait" /* PlayerModes.PORTRAIT */ | ||
value: "portrait" /* PlayerModes.PORTRAIT */, | ||
}, | ||
componentId: { | ||
type: String, | ||
value: '' | ||
value: '', | ||
}, | ||
playAuthToken: { | ||
type: String, | ||
value: '' | ||
value: '', | ||
}, | ||
playDomain: { | ||
type: String, | ||
value: 'https://vod.volcengineapi.com' // 默认火山引擎点播openapi域名 | ||
value: 'https://vod.volcengineapi.com', // 默认火山引擎点播openapi域名 | ||
}, | ||
@@ -54,11 +57,11 @@ definitionUrls: { | ||
value: [], | ||
observer(newVal, oldVal, _changedPath) { | ||
observer(newVal, _changedPath) { | ||
// console.log('definitionUrls:', newVal, oldVal); | ||
this.setData({ definitionUrls: newVal }); | ||
} | ||
}, | ||
}, | ||
autoBlurTime: { | ||
type: Number, | ||
value: 10000 | ||
} | ||
value: 10000, | ||
}, | ||
}, | ||
@@ -70,2 +73,3 @@ data: { | ||
videoSourceUrl: undefined, | ||
currentSrc: '', | ||
classNames: '', | ||
@@ -89,3 +93,4 @@ error: null, | ||
definitionChangeTime: null, | ||
showLoading: true, | ||
loading: true, | ||
isLoadingData: true, | ||
showPoster: false, | ||
@@ -95,3 +100,3 @@ playbackDefinition: undefined, | ||
isFocus: true, | ||
customControls: false // 控制栏初始状态 | ||
customControls: false, // 控制栏初始状态 | ||
}, | ||
@@ -114,2 +119,12 @@ observers: { | ||
}, | ||
'currentSrc': function () { | ||
const { currentSrc, src } = this.data; | ||
this.setData({ | ||
error: null, | ||
isLoadingData: false, | ||
}); | ||
this.updateCollector({ | ||
src: currentSrc || src, | ||
}); | ||
}, | ||
'src,definitionList,playAuthToken,playDomain': function () { | ||
@@ -124,42 +139,66 @@ const { src, definitionList, playAuthToken, playDomain } = this.data; | ||
this.setData({ | ||
definitionList: definitionList | ||
definitionList: definitionList, | ||
}); | ||
} | ||
this.setData({ | ||
currentSrc: src, | ||
isLoadingData: false, | ||
}); | ||
} | ||
else if (playAuthToken) { | ||
// console.log('ServiceRequest: ', playDomain, playAuthToken); | ||
(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; | ||
}); | ||
this.setData({ | ||
isLoadingData: true, | ||
}); | ||
(0, index_3.serviceRequest)(playAuthToken, playDomain || undefined) | ||
.then(data => { | ||
if (data.error) { | ||
this.setData({ | ||
videoSourceUrl: defaultDef.MainPlayUrl | ||
isLoadingData: false, | ||
error: data.error, | ||
}); | ||
if (qualityList.length > 0) { | ||
this.setData({ | ||
playbackDefinition: defaultDef.Bitrate, | ||
playbackDefinitionList: qualityList | ||
}); | ||
} | ||
} | ||
else { | ||
this.setData({ | ||
error: new error_1.XGError(error_1.ErrorCategory.SERVICE, index_1.ErrorCodes.SERVICE_PLAYINFOLIST_EMPTY, 'Service Error') | ||
isLoadingData: false, | ||
currentSrc: data.url, | ||
}); | ||
} | ||
}).catch((err) => { | ||
this.setData({ | ||
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'), | ||
// }) | ||
// }) | ||
} | ||
} | ||
}, | ||
}, | ||
@@ -169,6 +208,6 @@ lifetimes: { | ||
var _a; | ||
// eslint-disable-next-line @typescript-eslint/no-this-alias | ||
const self = this; | ||
const { videoId, videoProps, isFullScreen, loadedMeta, toggleCtrlOverLayer, ended } = this.data; | ||
const { videoId, videoProps, isFullScreen } = this.data; | ||
const { controls } = this.properties; | ||
this.__deviceInfo = wx.getDeviceInfo(); | ||
// console.log('>>>>Player attached', this.properties.loggerInfo) | ||
@@ -181,3 +220,3 @@ let _videoId = videoId || this.properties.componentId; | ||
videoId: _videoId, | ||
customControls: controls !== 'native' ? controls : false | ||
customControls: controls !== 'native' ? controls : false, | ||
}); | ||
@@ -188,5 +227,5 @@ const videoCtx = wx.createVideoContext(_videoId, this); | ||
// use Set to filter duplicate string item in Array | ||
...new Set([isFullScreen ? ' xg-video-fullscreen' : '', ...propsClassNames]) | ||
...new Set([isFullScreen ? ' xg-video-fullscreen' : '', ...propsClassNames]), | ||
].filter((item) => !!item); | ||
const showCtrlOverlay = (loadedMeta && toggleCtrlOverLayer) || ended; | ||
// const showCtrlOverlay = (loadedMeta && toggleCtrlOverLayer) || ended | ||
const videoProxyCtx = new Proxy(videoCtx, { | ||
@@ -197,15 +236,16 @@ get(target, prop, receiver) { | ||
self.setData({ | ||
seeking: true | ||
seeking: true, | ||
}); | ||
} | ||
return Reflect.get(target, prop, receiver); | ||
} | ||
}, | ||
}); | ||
if (Object.isExtensible(videoProxyCtx)) { | ||
// eslint-disable-next-line @typescript-eslint/dot-notation | ||
!videoProxyCtx['on'] && Object.assign(videoProxyCtx, new eventemitter3_1.EventEmitter(), eventemitter3_1.EventEmitter.prototype); | ||
this.media = videoProxyCtx; | ||
} | ||
index_3.default.setMedia(_videoId, this.media); | ||
index_4.default.setMedia(_videoId, this.media); | ||
this.setData({ | ||
classNames: classNames.join(' ') | ||
classNames: classNames.join(' '), | ||
}); | ||
@@ -230,3 +270,3 @@ }, | ||
} | ||
index_3.default.removeMedia(this.data.videoId); | ||
index_4.default.removeMedia(this.data.videoId); | ||
this.triggerCollector('detached', {}); | ||
@@ -239,2 +279,3 @@ this.destroyCollector(); | ||
error(e) { | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
const message = (e === null || e === void 0 ? void 0 : e.stack) || (e === null || e === void 0 ? void 0 : e.message) || ''; | ||
@@ -244,5 +285,5 @@ const error = new error_1.XGError(error_1.ErrorCategory.UNKNOWN, index_1.ErrorCodes.Component_LIFETIME_ERROR, message); | ||
this.setData({ | ||
error: error | ||
error: error, | ||
}); | ||
} | ||
}, | ||
}, | ||
@@ -254,4 +295,4 @@ methods: { | ||
focusPlayer(needAutoHide = true) { | ||
const { autoBlurTime, controls } = this.properties; | ||
const { isFocus, videoId } = this.data; | ||
const { autoBlurTime } = this.properties; | ||
const { isFocus } = this.data; | ||
if (this.fTimer) { | ||
@@ -266,11 +307,11 @@ clearTimeout(this.fTimer); | ||
!isFocus && this.setData({ | ||
isFocus: true | ||
isFocus: true, | ||
}); | ||
}, | ||
blurPlayer() { | ||
const { isFocus, videoId } = this.data; | ||
const { isFocus } = this.data; | ||
// console.log(`!!!!!Player${videoId} blurPlayer`, `isFocus:${isFocus} controls:${this.properties.controls}`) | ||
if (isFocus) { | ||
this.setData({ | ||
isFocus: false | ||
isFocus: false, | ||
}); | ||
@@ -290,4 +331,4 @@ } | ||
}, | ||
onTap(e) { | ||
const { mode, loadedMeta, paused, isFocus, ended, videoId } = this.data; | ||
onTap() { | ||
const { mode, loadedMeta, paused, isFocus, ended } = this.data; | ||
const { controls, enablePlayGesture } = this.properties; | ||
@@ -311,2 +352,7 @@ if (enablePlayGesture && mode === "portrait" /* PlayerModes.PORTRAIT */) { | ||
let { errMsg } = e.detail; | ||
const { isLoadingData, currentSrc } = this.data; | ||
if (!currentSrc && isLoadingData) { | ||
console.warn('The is unavailable [src] or [playAutoToken] for playback, please check~~'); | ||
return; | ||
} | ||
let errCode; | ||
@@ -323,3 +369,3 @@ if (/Format error$/gi.test(errMsg)) { | ||
this.setData({ | ||
error: new error_1.XGError(error_1.ErrorCategory.MEDIA, errCode, errMsg) | ||
error: new error_1.XGError(error_1.ErrorCategory.MEDIA, errCode, errMsg), | ||
}); | ||
@@ -329,11 +375,11 @@ }, | ||
const { definitionChangePoint } = this.data; | ||
const { duration, height, width } = e.detail; | ||
const { duration } = e.detail; | ||
// console.log('onLoadedMetadata', e.detail) | ||
this.setData({ | ||
loadedMeta: true, | ||
duration: duration | ||
duration: duration, | ||
}); | ||
if (definitionChangePoint) { | ||
this.setData({ | ||
definitionChangePoint: undefined | ||
definitionChangePoint: undefined, | ||
}); | ||
@@ -345,10 +391,11 @@ this.media.seek(definitionChangePoint); | ||
onPlay(e) { | ||
const { firstPlay, videoId, isFocus } = this.data; | ||
const { firstPlay } = this.data; | ||
const { controls } = this.properties; | ||
const obj = { | ||
paused: false, | ||
ended: false | ||
ended: false, | ||
error: null, | ||
}; | ||
if (!firstPlay) { | ||
obj['firstPlay'] = true; | ||
obj.firstPlay = true; | ||
} | ||
@@ -366,3 +413,3 @@ this.setData(obj); | ||
this.setData({ | ||
paused: true | ||
paused: true, | ||
}); | ||
@@ -372,3 +419,3 @@ this._emitEvt(index_1.MediaEvents.PAUSE, e); | ||
onTimeupdate(e) { | ||
const { seeking, paused } = this.data; | ||
const { seeking } = this.data; | ||
const { currentTime, duration } = e.detail; | ||
@@ -379,3 +426,3 @@ // console.log('Math.floor((currentTime / duration) * 100)', Math.floor((currentTime / duration) * 100)) | ||
duration: duration || 0, | ||
playPercent: duration > 0 ? Math.floor((currentTime / duration) * 100) : 0 | ||
playPercent: duration > 0 ? Math.floor((currentTime / duration) * 100) : 0, | ||
}; | ||
@@ -386,14 +433,8 @@ if (seeking) { | ||
} | ||
/** | ||
* @description 兼容ios和android在暂停之后seek时事件触发不一致导致的问题 | ||
*/ | ||
if (this.__deviceInfo.platform !== 'ios' && !seeking && paused) { | ||
data.paused = false; | ||
} | ||
this.setData(data); | ||
this._emitEvt(index_1.MediaEvents.TIMEUPDATE, e); | ||
}, | ||
onSeeked(e) { | ||
onSeeked() { | ||
this.setData({ | ||
seeking: false | ||
seeking: false, | ||
}); | ||
@@ -407,3 +448,3 @@ // 挪到状态变化内进行事件监听 | ||
ended: true, | ||
paused: true | ||
paused: true, | ||
}; | ||
@@ -420,3 +461,3 @@ if (seeking) { | ||
buffered: buffered, | ||
bufferedTime: buffered * this.data.duration / 100 | ||
bufferedTime: buffered * this.data.duration / 100, | ||
}); | ||
@@ -426,5 +467,5 @@ this._emitEvt(index_1.MediaEvents.PROGRESS, e); | ||
onFullscreenChange(e) { | ||
const { fullScreen, direction } = e.detail; | ||
const { fullScreen } = e.detail; | ||
this.setData({ | ||
isFullScreen: fullScreen | ||
isFullScreen: fullScreen, | ||
}); | ||
@@ -446,2 +487,3 @@ this._emitEvt(index_1.MediaEvents.FULLSCREENCHANGE, e); | ||
onCompErrorRetry() { | ||
// | ||
}, | ||
@@ -451,6 +493,6 @@ handleTap() { | ||
}, | ||
updateStatusOfShowLoading(e) { | ||
updateStatusOfShowLoading() { | ||
const { loadedMeta, seeking, paused } = this.data; | ||
this.setData({ | ||
showLoading: !loadedMeta || (seeking && !paused) | ||
loading: !loadedMeta || (seeking && !paused), | ||
}); | ||
@@ -461,8 +503,11 @@ }, | ||
this.setData({ | ||
showPoster: poster && !error && !autoplay && !firstPlay | ||
showPoster: poster && !error && !autoplay && !firstPlay, | ||
}); | ||
}, | ||
updateLoggerParams() { } | ||
updateLoggerParams() { | ||
// | ||
}, | ||
}, | ||
export() { | ||
// eslint-disable-next-line @typescript-eslint/no-this-alias | ||
const component = this; | ||
@@ -475,8 +520,10 @@ return { | ||
component.setData({ | ||
definitionUrls: urlArr | ||
definitionUrls: urlArr, | ||
}); | ||
}, | ||
updateLoggerParams() { } | ||
updateLoggerParams() { | ||
// | ||
}, | ||
}; | ||
} | ||
}, | ||
}); |
@@ -9,20 +9,20 @@ "use strict"; | ||
value: true, | ||
observer(newVal, oldVal, _changedPath) { | ||
observer(newVal, _changedPath) { | ||
const stateClass = newVal ? 'xg-bottom-progress-hide' : ''; | ||
this.setData({ | ||
stateClass | ||
stateClass, | ||
}); | ||
} | ||
}, | ||
}, | ||
buffered: { | ||
type: Number, | ||
value: 0 | ||
value: 0, | ||
}, | ||
played: { | ||
type: Number, | ||
value: 0 | ||
value: 0, | ||
}, | ||
strokeWidth: { | ||
type: Number, | ||
value: 2 | ||
value: 2, | ||
}, | ||
@@ -35,38 +35,22 @@ borderRadius: { | ||
type: String, | ||
value: 'rgba(255, 255, 255, 0.2)' | ||
value: 'rgba(255, 255, 255, 0.2)', | ||
}, | ||
cacheColor: { | ||
type: String, | ||
value: 'rgba(255, 255, 255, 0.38)' | ||
value: 'rgba(255, 255, 255, 0.38)', | ||
}, | ||
playedColor: { | ||
type: String, | ||
value: '#FFFFFF' | ||
} | ||
value: '#FFFFFF', | ||
}, | ||
}, | ||
data: { | ||
stateClass: 'xg-bottom-progress-hide' | ||
stateClass: 'xg-bottom-progress-hide', | ||
}, | ||
observers: {}, | ||
lifetimes: { | ||
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名 | ||
created: function () { }, | ||
attached: function () { }, | ||
ready: function () { | ||
// console.log('[progress]>>>ready', this.properties.videoId) | ||
// this.addMediaEvents(mediaManager) | ||
}, | ||
moved: function () { }, | ||
detached: function () { | ||
// console.log('[progress]>>>detached') | ||
// this.removeMediaEvents(mediaManager) | ||
}, | ||
}, | ||
lifetimes: {}, | ||
pageLifetimes: { | ||
// 组件所在页面的生命周期函数 | ||
show: function () { }, | ||
hide: function () { }, | ||
resize: function () { }, | ||
// 组件所在页面的生命周期函数 | ||
}, | ||
methods: {} | ||
methods: {}, | ||
}); |
@@ -10,21 +10,21 @@ "use strict"; | ||
value: true, | ||
observer(newVal, oldVal, _changedPath) { | ||
observer(newVal, _changedPath) { | ||
newVal ? this.hideControls() : this.showControls(); | ||
} | ||
} | ||
}, | ||
}, | ||
}, | ||
data: { | ||
stateClass: '' | ||
stateClass: 'xgplayer-controls-hide', | ||
}, | ||
lifetimes: { | ||
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名 | ||
attached: function () { }, | ||
moved: function () { }, | ||
detached: function () { }, | ||
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名 | ||
// attached: function () { }, | ||
// moved: function () { }, | ||
// detached: function () { }, | ||
}, | ||
pageLifetimes: { | ||
// 组件所在页面的生命周期函数 | ||
show: function () { }, | ||
hide: function () { }, | ||
resize: function () { }, | ||
// 组件所在页面的生命周期函数 | ||
// show: function () { }, | ||
// hide: function () { }, | ||
// resize: function () { }, | ||
}, | ||
@@ -34,3 +34,3 @@ methods: { | ||
this.setData({ | ||
stateClass: 'xgplayer-controls-hide' | ||
stateClass: 'xgplayer-controls-hide', | ||
}); | ||
@@ -40,6 +40,6 @@ }, | ||
this.setData({ | ||
stateClass: '' | ||
stateClass: '', | ||
}); | ||
} | ||
} | ||
}, | ||
}, | ||
}); |
@@ -14,3 +14,3 @@ "use strict"; | ||
type: String, | ||
value: 'hide' | ||
value: 'hide', | ||
}, | ||
@@ -22,4 +22,4 @@ /** | ||
type: Object, | ||
value: undefined | ||
} | ||
value: undefined, | ||
}, | ||
}, | ||
@@ -33,3 +33,3 @@ /** | ||
// console.log('component loading ready:', this.data); | ||
} | ||
}, | ||
}, | ||
@@ -42,4 +42,4 @@ /** | ||
this.triggerEvent('retry'); | ||
} | ||
} | ||
}, | ||
}, | ||
}); |
@@ -14,4 +14,4 @@ "use strict"; | ||
type: String, | ||
value: 'hide' | ||
} | ||
value: 'hide', | ||
}, | ||
}, | ||
@@ -25,3 +25,3 @@ /** | ||
// console.log('component loading ready:', this.data); | ||
} | ||
}, | ||
}, | ||
@@ -31,3 +31,3 @@ /** | ||
*/ | ||
methods: {} | ||
methods: {}, | ||
}); |
@@ -10,3 +10,3 @@ "use strict"; | ||
src: { | ||
type: String | ||
type: String, | ||
}, | ||
@@ -19,4 +19,4 @@ /** | ||
type: String, | ||
value: 'aspectFit' | ||
} | ||
value: 'aspectFit', | ||
}, | ||
}, | ||
@@ -27,3 +27,3 @@ /** | ||
data: { | ||
loaded: false | ||
loaded: false, | ||
}, | ||
@@ -33,3 +33,3 @@ lifetimes: { | ||
// console.log('component poster ready:', this.data); | ||
} | ||
}, | ||
}, | ||
@@ -42,7 +42,9 @@ /** | ||
this.setData({ | ||
loaded: true | ||
loaded: true, | ||
}); | ||
}, | ||
onError() { } | ||
} | ||
onError() { | ||
// | ||
}, | ||
}, | ||
}); |
@@ -11,15 +11,15 @@ "use strict"; | ||
type: String, | ||
value: 'progress' | ||
value: 'progress', | ||
}, | ||
blockSize: { | ||
type: Number, | ||
value: 12 | ||
value: 12, | ||
}, | ||
blockColor: { | ||
type: String, | ||
value: '#ffffff' | ||
value: '#ffffff', | ||
}, | ||
strokeWidth: { | ||
type: Number, | ||
value: 2 | ||
value: 2, | ||
}, | ||
@@ -32,12 +32,12 @@ borderRadius: { | ||
type: String, | ||
value: 'rgba(255, 255, 255, 0.2)' | ||
value: 'rgba(255, 255, 255, 0.2)', | ||
}, | ||
cacheColor: { | ||
type: String, | ||
value: 'rgba(255, 255, 255, 0.38)' | ||
value: 'rgba(255, 255, 255, 0.38)', | ||
}, | ||
playedColor: { | ||
type: String, | ||
value: '#FFFFFF' | ||
} | ||
value: '#FFFFFF', | ||
}, | ||
}, | ||
@@ -55,14 +55,14 @@ data: { | ||
currentTimeText: '00:00', | ||
blockStyle: 'left: 0' | ||
blockStyle: 'left: 0', | ||
}, | ||
lifetimes: { | ||
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名 | ||
created: function () { }, | ||
attached: function () { }, | ||
ready: function () { | ||
// created() {}, | ||
// attached () { }, | ||
ready() { | ||
// console.log('!!!![progress]>>>ready', this.properties.videoId) | ||
this.addMediaEvents(index_1.default); | ||
}, | ||
moved: function () { }, | ||
detached: function () { | ||
// moved () { }, | ||
detached() { | ||
// console.log('[progress]>>>detached') | ||
@@ -73,12 +73,9 @@ this.removeMediaEvents(index_1.default); | ||
pageLifetimes: { | ||
// 组件所在页面的生命周期函数 | ||
show: function () { }, | ||
hide: function () { }, | ||
resize: function () { }, | ||
// 组件所在页面的生命周期函数 | ||
}, | ||
methods: { | ||
onClick: function (e) { | ||
onClick() { | ||
// 空方法,用于阻止进度条的点击事件冒泡 | ||
}, | ||
_onTimeupdate: function (data) { | ||
_onTimeupdate(data) { | ||
const { currentTime, duration, playPercent } = data.data; | ||
@@ -89,4 +86,4 @@ if (!this.data.isActive && !this.data.isSeeking) { | ||
blockStyle: `left:${playPercent}%;`, | ||
currentTime: currentTime, | ||
currentTimeText: (0, index_2.format)(currentTime) | ||
currentTime, | ||
currentTimeText: (0, index_2.format)(currentTime), | ||
}); | ||
@@ -97,14 +94,14 @@ } | ||
duration, | ||
durationText: (0, index_2.format)(duration) | ||
durationText: (0, index_2.format)(duration), | ||
}); | ||
} | ||
}, | ||
_onProgress: function (data) { | ||
const { buffered, bufferedTime } = data.data; | ||
_onProgress(data) { | ||
const { buffered } = data.data; | ||
// console.log('[progress]>_onProgress', buffered, bufferedTime) | ||
this.setData({ | ||
buffered: buffered | ||
buffered, | ||
}); | ||
}, | ||
_onLoadedmetadata: function (data) { | ||
_onLoadedmetadata(data) { | ||
const { duration } = data.data; | ||
@@ -114,12 +111,12 @@ // console.log('[progress]>_onLoadedmetadata', duration, format(duration)) | ||
duration, | ||
durationText: (0, index_2.format)(duration) | ||
durationText: (0, index_2.format)(duration), | ||
}); | ||
}, | ||
_onSeekcomplete: function (e) { | ||
//// console.log('[progress]_onSeekComplete') | ||
_onSeekcomplete() { | ||
// // console.log('[progress]_onSeekComplete') | ||
this.setData({ | ||
isSeeking: false | ||
isSeeking: false, | ||
}); | ||
}, | ||
onProgressChange: function (e) { | ||
onProgressChange(e) { | ||
const { value } = e.detail; | ||
@@ -134,7 +131,7 @@ const { duration } = this.data; | ||
isActive: false, | ||
isSeeking: true | ||
isSeeking: true, | ||
}); | ||
this.media.seek(seekTime); | ||
}, | ||
onProgressChanging: function (e) { | ||
onProgressChanging(e) { | ||
const { value } = e.detail; | ||
@@ -148,6 +145,6 @@ const { duration } = this.data; | ||
isActive: true, | ||
currentTimeText: (0, index_2.format)(cTime) | ||
currentTimeText: (0, index_2.format)(cTime), | ||
}); | ||
} | ||
} | ||
}, | ||
}, | ||
}); |
@@ -14,3 +14,3 @@ "use strict"; | ||
type: String, | ||
value: 'show' | ||
value: 'show', | ||
}, | ||
@@ -22,4 +22,4 @@ /** | ||
type: String, | ||
value: 'small' | ||
} | ||
value: 'small', | ||
}, | ||
}, | ||
@@ -32,3 +32,3 @@ /** | ||
ctx: null, | ||
sizeClassName: 'xg-icon-middle' | ||
sizeClassName: 'xg-icon-middle', | ||
}, | ||
@@ -40,3 +40,3 @@ lifetimes: { | ||
width: '', | ||
height: '' | ||
height: '', | ||
}; | ||
@@ -46,3 +46,3 @@ switch (size) { | ||
this.setData({ | ||
sizeClassName: 'xg-icon-large' | ||
sizeClassName: 'xg-icon-large', | ||
}); | ||
@@ -52,10 +52,12 @@ break; | ||
this.setData({ | ||
sizeClassName: 'xg-icon-small' | ||
sizeClassName: 'xg-icon-small', | ||
}); | ||
break; | ||
default: | ||
// | ||
} | ||
this.setData({ | ||
style: (0, index_1.styleToText)(style) | ||
style: (0, index_1.styleToText)(style), | ||
}); | ||
} | ||
}, | ||
}, | ||
@@ -67,3 +69,3 @@ /** | ||
onClick() { | ||
const { paused, media } = this.data; | ||
// const { paused, media } = this.data; | ||
// if (media) { | ||
@@ -76,4 +78,4 @@ // if (paused) { | ||
// } | ||
} | ||
} | ||
}, | ||
}, | ||
}); |
@@ -17,3 +17,3 @@ "use strict"; | ||
type: Boolean, | ||
value: false | ||
value: false, | ||
}, | ||
@@ -25,3 +25,3 @@ /** | ||
type: String, | ||
value: 'small' | ||
value: 'small', | ||
}, | ||
@@ -34,9 +34,9 @@ /** | ||
value: true, | ||
observer(newVal, oldVal, _changedPath) { | ||
observer(newVal, _changedPath) { | ||
const data = { | ||
className: newVal ? 'xg-paused' : 'xg-playing' | ||
className: newVal ? 'xg-paused' : 'xg-playing', | ||
}; | ||
this.setData(data); | ||
} | ||
} | ||
}, | ||
}, | ||
}, | ||
@@ -50,3 +50,3 @@ /** | ||
className: 'xg-icon-play', | ||
sizeClassName: 'xg-icon-middle' | ||
sizeClassName: 'xg-icon-middle', | ||
}, | ||
@@ -58,3 +58,3 @@ lifetimes: { | ||
width: '', | ||
height: '' | ||
height: '', | ||
}; | ||
@@ -64,3 +64,3 @@ switch (size) { | ||
this.setData({ | ||
sizeClassName: 'xg-icon-large' | ||
sizeClassName: 'xg-icon-large', | ||
}); | ||
@@ -70,8 +70,10 @@ break; | ||
this.setData({ | ||
sizeClassName: 'xg-icon-small' | ||
sizeClassName: 'xg-icon-small', | ||
}); | ||
break; | ||
default: | ||
// | ||
} | ||
this.setData({ | ||
style: (0, index_1.styleToText)(style) | ||
style: (0, index_1.styleToText)(style), | ||
}); | ||
@@ -82,3 +84,3 @@ this.addMediaEvents(index_2.default); | ||
this.removeMediaEvents(index_2.default); | ||
} | ||
}, | ||
}, | ||
@@ -99,4 +101,4 @@ /** | ||
} | ||
} | ||
} | ||
}, | ||
}, | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable object-shorthand */ | ||
const mediaManager = { | ||
@@ -26,3 +27,3 @@ name: 'mediaManager', | ||
id: videoId, | ||
media: media | ||
media: media, | ||
}); | ||
@@ -45,8 +46,8 @@ } | ||
const _index = this._findById(videoId); | ||
//console.log('mediaManager>removeMedia', videoId, _index) | ||
// console.log('mediaManager>removeMedia', videoId, _index) | ||
if (_index >= 0) { | ||
return this._list.splice(_index, 1); | ||
} | ||
} | ||
}, | ||
}; | ||
exports.default = mediaManager; |
@@ -19,3 +19,3 @@ "use strict"; | ||
*/ | ||
styleIsolation: 'apply-shared' | ||
styleIsolation: 'apply-shared', | ||
}, options.options || {}); | ||
@@ -22,0 +22,0 @@ Component(options); |
@@ -7,5 +7,3 @@ "use strict"; | ||
Object.keys(style).forEach((key) => { | ||
const bbqKey = key.replace(/[A-Z]/g, (val) => { | ||
return '-' + val.toLowerCase(); | ||
}); | ||
const bbqKey = key.replace(/[A-Z]/g, (val) => `-${val.toLowerCase()}`); | ||
cssText += `${bbqKey}:${style[key]};`; | ||
@@ -12,0 +10,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DEBUG = void 0; | ||
/* eslint-disable @typescript-eslint/no-unnecessary-condition */ | ||
const DEBUG_OPEN = false; | ||
@@ -10,3 +11,3 @@ const useColor = false; | ||
error: 'color: #525252; background-color: red;', | ||
warn: 'color: #525252; background-color: yellow; ' | ||
warn: 'color: #525252; background-color: yellow; ', | ||
} | ||
@@ -17,3 +18,3 @@ : {}; | ||
config: { | ||
debug: DEBUG_OPEN ? 3 : 1 | ||
debug: DEBUG_OPEN ? 3 : 1, | ||
}, | ||
@@ -32,3 +33,3 @@ logInfo(message, ...optionalParams) { | ||
console[_fun](TAG, STYLE.error, message, ...optionalParams); | ||
} | ||
}, | ||
}; |
@@ -27,3 +27,3 @@ "use strict"; | ||
class XGError extends eventemitter3_1.EventEmitter { | ||
constructor(category, code, message = '', ...restArgs) { | ||
constructor(category, code, message, ...restArgs) { | ||
super(); | ||
@@ -30,0 +30,0 @@ this.severity = ErrorSeverity.INTERRUPTED; |
@@ -18,2 +18,4 @@ "use strict"; | ||
exports.format = exports.padStart = void 0; | ||
/* eslint-disable no-magic-numbers */ | ||
/* eslint-disable @typescript-eslint/no-magic-numbers */ | ||
/** | ||
@@ -41,3 +43,3 @@ * Util | ||
if (time >= 10) { | ||
return time + ''; | ||
return `${time}`; | ||
} | ||
@@ -49,2 +51,3 @@ else { | ||
function format(time) { | ||
// eslint-disable-next-line no-restricted-globals | ||
if (isNaN(time)) { | ||
@@ -51,0 +54,0 @@ return '00:00'; |
@@ -7,3 +7,3 @@ "use strict"; | ||
// While there remain elements to shuffle. | ||
while (currentIndex != 0) { | ||
while (currentIndex !== 0) { | ||
// Pick a remaining element. | ||
@@ -10,0 +10,0 @@ randomIndex = Math.floor(Math.random() * currentIndex); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateUppercaseUid = exports.generateLowercaseUid = exports.generateBaseStrUid = exports.generateUid = void 0; | ||
/* eslint-disable @typescript-eslint/comma-dangle */ | ||
const shuffle_1 = require("./shuffle"); | ||
@@ -12,3 +13,3 @@ function generateUid() { | ||
u /* uppercase */: true, | ||
l /* lowercase */: true | ||
l /* lowercase */: true, | ||
}) { | ||
@@ -15,0 +16,0 @@ const codes = []; |
{ | ||
"name": "veplayer-mp-wechat", | ||
"version": "1.0.3-alpha.0", | ||
"version": "1.0.4-alpha.0", | ||
"license": "MIT", | ||
@@ -25,6 +25,3 @@ "miniprogram": "dist", | ||
"xgplayer-service-miniprogram": "^0.4.0" | ||
}, | ||
"devDependencies": { | ||
"fs-extra": "^11.1.1" | ||
} | ||
} |
@@ -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-wechat'); | ||
let targetPath = ''; | ||
const isExitTTCom = fs.existsSync(path.join(__dirname, `../../${isExitSrc ? 'src/' : ''}wxcomponents`)); | ||
const isExitSrc = fs.existsSync(path.join(__dirname, '../../src')) | ||
const sourcePath = path.join(__dirname, '../../node_modules/veplayer-mp-wechat') | ||
let targetPath = '' | ||
const isExitTTCom = fs.existsSync(path.join(__dirname, `../../${isExitSrc ? 'src/' : ''}wxcomponents`)) | ||
// 不存在则新建文件夹 | ||
if (!isExitTTCom) { | ||
const ttPath = fs.mkdirSync(path.join(__dirname, `../../${isExitSrc ? 'src/' : ''}wxcomponents`), { | ||
recursive: true | ||
}); | ||
recursive: true, | ||
}) | ||
if (!ttPath) { | ||
console.warn( | ||
`创建wxcomponents失败,请手动复制node_modules/veplayer-mp-wechat到${isExitSrc ? 'src/' : ''}twxcomponents` | ||
); | ||
return; | ||
console.warn(`创建wxcomponents失败,请手动复制node_modules/veplayer-mp-wechat到${isExitSrc ? 'src/' : ''}twxcomponents`) | ||
return | ||
} | ||
} | ||
targetPath = path.join(__dirname, `../../${isExitSrc ? 'src/' : ''}wxcomponents/veplayer-mp-wechat`); | ||
copyFolderSync(sourcePath, targetPath); | ||
targetPath = path.join(__dirname, `../../${isExitSrc ? 'src/' : ''}wxcomponents/veplayer-mp-wechat`) | ||
copyFolderSync(sourcePath, targetPath) | ||
} | ||
@@ -52,5 +50,5 @@ } | ||
try { | ||
main(); | ||
main() | ||
} catch (err) { | ||
console.warn('复制veplayer-mp-wechat失败,请手动复制node_modules/veplayer-mp-wechat到根目录下的wxcomponents'); | ||
console.warn('复制veplayer-mp-wechat失败,请手动复制node_modules/veplayer-mp-wechat到根目录下的wxcomponents') | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
133039
0
58
2184