veplayer-mp-wechat
Advanced tools
@@ -70,3 +70,4 @@ "use strict"; | ||
delay: 10000, | ||
focusDelay: 0, // 隐藏态进入focus态是否自动 | ||
focusDelay: 0, | ||
clickHide: false // tap的时候是否隐藏 | ||
}; |
@@ -29,8 +29,9 @@ "use strict"; | ||
} | ||
if (newVal !== "native" /* ControlsStates.NATIVE */) { | ||
const _auto = !(!newVal || newVal === "hidden" /* ControlsStates.HIDDEN */); | ||
const _state = !newVal || newVal === "hidden" /* ControlsStates.HIDDEN */ || newVal === "blur" /* ControlsStates.BLUR */ ? "blur" /* InteractStates.BLUR */ : "focus" /* InteractStates.FOCUS */; | ||
console.log(`>>>observer switchControls ${videoId} state:${_state} auto:${_auto} interactState:${interactState}`); | ||
this.switchControls(_state, _auto, true); | ||
} | ||
this.switchOutControls(newVal, interactState); | ||
// if (newVal !== ControlsStates.NATIVE) { | ||
// const _auto = !(!newVal || newVal === ControlsStates.HIDDEN) | ||
// const _state = !newVal || newVal === ControlsStates.HIDDEN || newVal === ControlsStates.BLUR ? InteractStates.BLUR : InteractStates.FOCUS | ||
// console.log(`>>>observer switchControls ${videoId} state:${_state} auto:${_auto} interactState:${interactState}`) | ||
// this.switchControls(_state, _auto, true) | ||
// } | ||
} | ||
@@ -247,3 +248,3 @@ }, | ||
this.destroyCollector(); | ||
clearTimeout(this._fTimer); | ||
// clearTimeout(this._fTimer) | ||
}, | ||
@@ -268,10 +269,30 @@ /** | ||
const { customControls, firstPlay, videoId, interactState } = this.data; | ||
// if (!customControls) { | ||
// return | ||
// } | ||
if (!customControls) { | ||
return; | ||
} | ||
const { controlsState, autoplay, controls } = this.properties; | ||
let ret = this.getStateByControls(controls); | ||
console.log(`>>>initControls ${videoId}`, `controls:${controls} interactState:${interactState} next:${ret.state} auto:${ret.auto}`); | ||
this.switchControls(ret.state, ret.auto, true); | ||
// this.switchControls(ret.state, ret.auto, true) | ||
this.switchOutControls(controls); | ||
}, | ||
switchOutControls(newVal, state) { | ||
if (newVal === "native" /* ControlsStates.NATIVE */) { | ||
return; | ||
} | ||
const _isBlur = newVal === "blur" /* ControlsStates.BLUR */; | ||
const _state = !newVal || newVal === "hidden" /* ControlsStates.HIDDEN */ || newVal === "blur" /* ControlsStates.BLUR */ ? "blur" /* InteractStates.BLUR */ : "focus" /* InteractStates.FOCUS */; | ||
const { focusDelay } = this.properties.interactiveConfig; | ||
if (this._pTimer) { | ||
clearTimeout(this._pTimer); | ||
this._pTimer = null; | ||
} | ||
console.log(`>>>switchOutControls controls:${newVal} state:${_state} isAuto:${_isBlur}`); | ||
this.switchControls(_state, _state === "focus" /* InteractStates.FOCUS */, true); | ||
if (focusDelay && _isBlur) { | ||
this._pTimer = setTimeout(() => { | ||
this.switchControls("focus" /* InteractStates.FOCUS */, true, true); | ||
}, focusDelay); | ||
} | ||
}, | ||
/** | ||
@@ -290,3 +311,3 @@ * | ||
const { delay, immersive, focusDelay } = this.properties.interactiveConfig || {}; | ||
console.log(`>>>switchControls ${videoId} needAuto:${needAuto} state>from:${interactState} to:${state}, immersive:${immersive}`); | ||
// console.log(`>>>switchControls ${videoId} needAuto:${needAuto} state>from:${interactState} to:${state}, immersive:${immersive}`) | ||
if (this._fTimer) { | ||
@@ -309,8 +330,12 @@ clearTimeout(this._fTimer); | ||
} | ||
needAuto && _delay > 0 && (this._fTimer = setTimeout(() => { | ||
console.log(`>>>AutoSwitchControls ${videoId} state:${_nextState} auto:${_nextAuto}`); | ||
this.switchControls(_nextState, _nextAuto, true); | ||
clearTimeout(this._fTimer); | ||
this._fTimer = null; | ||
}, _delay)); | ||
if (needAuto && _delay > 0) { | ||
this._fTimer = setTimeout(() => { | ||
console.log(`>>>AutoSwitchControls ${videoId} state:${_nextState} auto:${_nextAuto}`); | ||
this.switchControls(_nextState, _nextAuto, true); | ||
clearTimeout(this._fTimer); | ||
this._fTimer = null; | ||
}, _delay); | ||
// this._fTimer = setTimeout(this.timeoutFun.bind(this), _delay, _nextState, _nextAuto) | ||
} | ||
// console.log(`>>>switchControls_after ${videoId} _delay: ${_delay} needAuto:${needAuto} interactState:${interactState} state:${state} _nextState:${_nextState} ${needAuto && _delay > 0 } this._fTimer:${this._fTimer}`) | ||
state !== interactState && this.setData({ | ||
@@ -386,2 +411,3 @@ interactState: state, | ||
// 之前是focus状态,要切换到可自动隐藏的Focus | ||
console.log('>>>switchControls onplay', "focus" /* InteractStates.FOCUS */, true, false); | ||
this.switchControls("focus" /* InteractStates.FOCUS */, true, false); | ||
@@ -394,3 +420,6 @@ }, | ||
this._emitEvt(index_1.MediaEvents.PAUSE, e); | ||
this.isControlsShow() && this.switchControls("focus" /* InteractStates.FOCUS */, false, false); | ||
if (this.isControlsShow()) { | ||
this.switchControls("focus" /* InteractStates.FOCUS */, false, false); | ||
console.log('>>>switchControls onpause', "focus" /* InteractStates.FOCUS */, true, false); | ||
} | ||
}, | ||
@@ -505,3 +534,3 @@ onTimeupdate(e) { | ||
onTap(e) { | ||
const { mode, loadedMeta, paused, isFocus, ended, videoId, customControls, interactState } = this.data; | ||
const { mode, loadedMeta, paused, isFocus, ended, videoId, customControls, interactState, controls } = this.data; | ||
const { enablePlayGesture, interactiveConfig } = this.properties; | ||
@@ -533,3 +562,7 @@ if (!customControls) { | ||
else { | ||
if (interactState !== "focus" /* InteractStates.FOCUS */) { | ||
if (interactState === "focus" /* InteractStates.FOCUS */ && interactiveConfig.clickHide) { | ||
nextState = "blur" /* InteractStates.BLUR */; | ||
_auto = true; | ||
} | ||
else { | ||
nextState = "focus" /* InteractStates.FOCUS */; | ||
@@ -539,2 +572,7 @@ _auto = true; | ||
} | ||
console.log(`>>>switchControls onTap ${videoId} controls:${controls} interactState:${interactState} nextState:${nextState}`); | ||
// 由外部交互的的时候关闭内部交互 | ||
if (controls === "hidden" /* ControlsStates.HIDDEN */) { | ||
return; | ||
} | ||
nextState && this.switchControls(nextState, _auto, false); | ||
@@ -576,2 +614,6 @@ }, | ||
}; | ||
}, | ||
checkStateMatch() { | ||
const { controls, interactState } = this.data; | ||
// if (controls === ControlsStates.BLUR && interactState === ) | ||
} | ||
@@ -578,0 +620,0 @@ }, |
{ | ||
"name": "veplayer-mp-wechat", | ||
"version": "1.2.2-alpha.5", | ||
"version": "1.2.2-alpha.6", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "miniprogram": "dist", |
Sorry, the diff of this file is not supported yet
146231
1.66%2442
1.79%