fix
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
"pages": [
|
"pages": [
|
||||||
"pages/tab-bar/medicine-box/index",
|
"pages/tab-bar/medicine-box/index",
|
||||||
"pages/tab-bar/medicine-box/add/index",
|
"pages/tab-bar/medicine-box/add/index",
|
||||||
"pages/tab-bar/drug-wiki/index",
|
|
||||||
"pages/tab-bar/education/index",
|
"pages/tab-bar/education/index",
|
||||||
"pages/tab-bar/profile/index",
|
"pages/tab-bar/profile/index",
|
||||||
"pages/tab-bar/profile/edit/index",
|
"pages/tab-bar/profile/edit/index",
|
||||||
@@ -27,10 +26,6 @@
|
|||||||
"pagePath": "pages/tab-bar/medicine-box/index",
|
"pagePath": "pages/tab-bar/medicine-box/index",
|
||||||
"text": "电子药箱"
|
"text": "电子药箱"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"pagePath": "pages/tab-bar/drug-wiki/index",
|
|
||||||
"text": "药品百科"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"pagePath": "pages/tab-bar/education/index",
|
"pagePath": "pages/tab-bar/education/index",
|
||||||
"text": "惠教中心"
|
"text": "惠教中心"
|
||||||
|
|||||||
@@ -7,11 +7,6 @@ Component({
|
|||||||
text: '电子药箱',
|
text: '电子药箱',
|
||||||
icon: '💊',
|
icon: '💊',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
pagePath: 'pages/tab-bar/drug-wiki/index',
|
|
||||||
text: '药品百科',
|
|
||||||
icon: '📖',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
pagePath: 'pages/tab-bar/education/index',
|
pagePath: 'pages/tab-bar/education/index',
|
||||||
text: '惠教中心',
|
text: '惠教中心',
|
||||||
|
|||||||
@@ -87,18 +87,14 @@ Page({
|
|||||||
if (wx.setVisualEffectOnCapture) wx.setVisualEffectOnCapture({ visualEffect: 'none' });
|
if (wx.setVisualEffectOnCapture) wx.setVisualEffectOnCapture({ visualEffect: 'none' });
|
||||||
|
|
||||||
if (this.data.currentTime > 0) {
|
if (this.data.currentTime > 0) {
|
||||||
wx.setStorageSync("interruptedTime", this.data.currentTime);
|
this.flushProgress();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onUnload() {
|
onUnload() {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
if (wx.setVisualEffectOnCapture) wx.setVisualEffectOnCapture({ visualEffect: 'none' });
|
if (wx.setVisualEffectOnCapture) wx.setVisualEffectOnCapture({ visualEffect: 'none' });
|
||||||
|
this.flushProgress();
|
||||||
if (this.data.currentTime > 0) {
|
|
||||||
wx.setStorageSync("interruptedTime", this.data.currentTime);
|
|
||||||
wx.setStorageSync("currentTime", this.data.currentTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.pauseVideoBeforeNavigate();
|
this.pauseVideoBeforeNavigate();
|
||||||
@@ -130,6 +126,8 @@ Page({
|
|||||||
wx.onNetworkStatusChange(this._networkStatusChangeHandler);
|
wx.onNetworkStatusChange(this._networkStatusChangeHandler);
|
||||||
|
|
||||||
this._pauseVideoHandler = () => {
|
this._pauseVideoHandler = () => {
|
||||||
|
// 来电等系统中断:先落盘进度再暂停
|
||||||
|
this.flushProgress();
|
||||||
this._wasPlayingBeforeInterrupt = this.data.playing;
|
this._wasPlayingBeforeInterrupt = this.data.playing;
|
||||||
this.pauseVideoBeforeNavigate();
|
this.pauseVideoBeforeNavigate();
|
||||||
};
|
};
|
||||||
@@ -143,6 +141,7 @@ Page({
|
|||||||
};
|
};
|
||||||
|
|
||||||
this._appHideHandler = () => {
|
this._appHideHandler = () => {
|
||||||
|
this.flushProgress();
|
||||||
this.setData({ isAppHidden: true });
|
this.setData({ isAppHidden: true });
|
||||||
this.pauseVideoBeforeNavigate();
|
this.pauseVideoBeforeNavigate();
|
||||||
};
|
};
|
||||||
@@ -172,25 +171,36 @@ Page({
|
|||||||
this.getVideoContext().play();
|
this.getVideoContext().play();
|
||||||
},
|
},
|
||||||
|
|
||||||
syncResumeTime() {
|
// 统一写进度:interruptedTime 与 currentTime 成对写,保证两者永远一致
|
||||||
if (this.data.resumeTime > 0) {
|
flushProgress(time?: number) {
|
||||||
this.getVideoContext().seek(this.data.resumeTime);
|
const t = Math.max(time || this.data.currentTime || 0, Number(wx.getStorageSync("currentTime") || 0));
|
||||||
|
if (t <= 0) return;
|
||||||
|
wx.setStorageSync("interruptedTime", t);
|
||||||
|
wx.setStorageSync("currentTime", t);
|
||||||
|
},
|
||||||
|
|
||||||
|
// 视频元信息就绪后才 seek,否则 seek 会被静默忽略
|
||||||
|
onPlayerLoadedMetadata() {
|
||||||
|
this.seekToResumeTime();
|
||||||
|
},
|
||||||
|
|
||||||
|
seekToResumeTime() {
|
||||||
|
const t = this.getResumeTime();
|
||||||
|
if (t > 0) {
|
||||||
|
this.getVideoContext().seek(t);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onPlayerPlay() {
|
onPlayerPlay() {
|
||||||
this.setData({ playing: true, resumeTime: 0 });
|
this.setData({ playing: true });
|
||||||
wx.removeStorageSync("interruptedTime");
|
this.seekToResumeTime();
|
||||||
this.startSendProgress();
|
this.startSendProgress();
|
||||||
},
|
},
|
||||||
|
|
||||||
onPlayerPause() {
|
onPlayerPause() {
|
||||||
this.setData({ playing: false });
|
this.setData({ playing: false });
|
||||||
this.clearSendProgressTimer();
|
this.clearSendProgressTimer();
|
||||||
// 用户主动点击暂停时,存入进度
|
this.flushProgress();
|
||||||
if (this.data.currentTime > 0) {
|
|
||||||
wx.setStorageSync("interruptedTime", this.data.currentTime);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onPlayerEnded() {
|
onPlayerEnded() {
|
||||||
@@ -212,16 +222,12 @@ Page({
|
|||||||
|
|
||||||
// 接收原生组件的时间更新
|
// 接收原生组件的时间更新
|
||||||
onPlayerTimeUpdate(e: any) {
|
onPlayerTimeUpdate(e: any) {
|
||||||
// 兼容 VOD 插件可能多包一层 detail 的情况
|
|
||||||
let time = e.detail?.currentTime ?? e.detail?.detail?.currentTime;
|
let time = e.detail?.currentTime ?? e.detail?.detail?.currentTime;
|
||||||
if (typeof time === 'number' && time > 0) {
|
if (typeof time === 'number' && time > 0) {
|
||||||
const currentTime = Math.floor(time);
|
const currentTime = Math.floor(time);
|
||||||
this.data.currentTime = currentTime; // 纯内存更新,不触发无用渲染
|
if (currentTime === this.data.currentTime) return;
|
||||||
|
this.data.currentTime = currentTime;
|
||||||
// 每 5 秒落盘一次 currentTime 作为终极兜底,不要太频繁避免卡顿
|
if (currentTime % 5 === 0) this.flushProgress(currentTime);
|
||||||
if (currentTime % 5 === 0) {
|
|
||||||
wx.setStorageSync("currentTime", currentTime);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -305,9 +311,9 @@ Page({
|
|||||||
eveId: targetData.eveId,
|
eveId: targetData.eveId,
|
||||||
nodes: htmlToWxNodes(targetData.content),
|
nodes: htmlToWxNodes(targetData.content),
|
||||||
fileid: targetData.extend.fileid,
|
fileid: targetData.extend.fileid,
|
||||||
|
resumeTime: this.getResumeTime(),
|
||||||
});
|
});
|
||||||
|
|
||||||
this.syncResumeTime();
|
|
||||||
this.selectComponent("#tabs")?.resize();
|
this.selectComponent("#tabs")?.resize();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -15,13 +15,15 @@
|
|||||||
height="210px"
|
height="210px"
|
||||||
appid="1304584727"
|
appid="1304584727"
|
||||||
fileid="{{fileid}}"
|
fileid="{{fileid}}"
|
||||||
|
initial-time="{{resumeTime}}"
|
||||||
enable-progress-gesture="{{false}}"
|
enable-progress-gesture="{{false}}"
|
||||||
playerid="myPlayerId"
|
playerid="myPlayerId"
|
||||||
bindplay="onPlayerPlay"
|
bindplay="onPlayerPlay"
|
||||||
bindpause="onPlayerPause"
|
bindpause="onPlayerPause"
|
||||||
bindended="onPlayerEnded"
|
bindended="onPlayerEnded"
|
||||||
binderror="onPlayerError"
|
binderror="onPlayerError"
|
||||||
bindtimeupdate="onPlayerTimeUpdate"
|
bindtimeupdate="onPlayerTimeUpdate"
|
||||||
|
bindloadedmetadata="onPlayerLoadedMetadata"
|
||||||
show-fullscreen-btn
|
show-fullscreen-btn
|
||||||
>
|
>
|
||||||
<cover-view class="cover"></cover-view>
|
<cover-view class="cover"></cover-view>
|
||||||
|
|||||||
Reference in New Issue
Block a user