修改内容处理
parent
59b26a3640
commit
7f4d4469fc
|
|
@ -50,6 +50,7 @@
|
|||
</view>
|
||||
<view v-if="!isEmpty(video_item.goods) && base_config_data && base_config_data.is_video_detail_show_goods && base_config_data.is_video_detail_show_goods == 1" class="product-card">
|
||||
<view class="flex-col gap-10">
|
||||
<text>{{ video_item.show_goods }}</text>
|
||||
<view v-if="video_item.show_goods" class="flex-row align-c gap-10 product-card-item" :data-id="video_item.id" @tap.stop="handle_product_card_item">
|
||||
<view class="product-image">
|
||||
<image :src="video_item.goods.images" mode="aspectFill" class="product-image"></image>
|
||||
|
|
@ -320,6 +321,7 @@
|
|||
listener_height: 0,
|
||||
comments_data: {},
|
||||
editor_path_type: 'video',
|
||||
is_manual_pause: false, // 是否手动暂停
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
|
|
@ -350,6 +352,11 @@
|
|||
params: app.globalData.launch_params_handle(params),
|
||||
});
|
||||
},
|
||||
onShow() {
|
||||
if (!this.is_manual_pause && this.video_contexts != null) {
|
||||
this.video_play_event(this.video_contexts[this.current_index], true);
|
||||
}
|
||||
},
|
||||
onHide() {
|
||||
// 清理定时器
|
||||
if (this.video_switch_debounce_timer) {
|
||||
|
|
@ -549,18 +556,16 @@
|
|||
});
|
||||
|
||||
setTimeout(() => {
|
||||
if (!this.paused) {
|
||||
//#ifdef H5
|
||||
if (this.video_contexts[this.current_index]) { // 当前播放的视频索引为0
|
||||
this.video_play_event(this.video_contexts[this.current_index], true);
|
||||
}
|
||||
//#endif
|
||||
//#ifndef H5
|
||||
if (this.create_video_contexts[this.current_index]) { // 当前播放的视频索引为0
|
||||
this.video_play_event(this.create_video_contexts[this.current_index], true);
|
||||
}
|
||||
//#endif
|
||||
//#ifdef H5
|
||||
if (this.video_contexts[this.current_index]) { // 当前播放的视频索引为0
|
||||
this.video_play_event(this.video_contexts[this.current_index], true);
|
||||
}
|
||||
//#endif
|
||||
//#ifndef H5
|
||||
if (this.create_video_contexts[this.current_index]) { // 当前播放的视频索引为0
|
||||
this.video_play_event(this.create_video_contexts[this.current_index], true);
|
||||
}
|
||||
//#endif
|
||||
}, 200);
|
||||
}, 0);
|
||||
}
|
||||
|
|
@ -603,6 +608,7 @@
|
|||
this.setData({
|
||||
current_index: current,
|
||||
paused: false,
|
||||
is_manual_pause: false,
|
||||
current_video_progress: 0,
|
||||
current_video_duration: 1,
|
||||
is_seeking: false,
|
||||
|
|
@ -675,6 +681,9 @@
|
|||
if (index !== exceptIndex && context) {
|
||||
try {
|
||||
context.pause();
|
||||
this.setData({
|
||||
is_manual_pause: false,
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn(`暂停视频 ${index} 失败:`, error);
|
||||
}
|
||||
|
|
@ -694,7 +703,6 @@
|
|||
// 切换播放暂停
|
||||
toggle_play_pause() {
|
||||
const currentIndex = this.current_index;
|
||||
|
||||
// 检查视频上下文是否存在
|
||||
const videoContext = this.create_video_contexts[currentIndex] || this.video_contexts[currentIndex];
|
||||
if (!videoContext) {
|
||||
|
|
@ -703,7 +711,8 @@
|
|||
}
|
||||
|
||||
this.setData({
|
||||
paused: !this.paused
|
||||
paused: !this.paused,
|
||||
is_manual_pause: !this.paused,
|
||||
});
|
||||
|
||||
if (this.paused) {
|
||||
|
|
@ -736,7 +745,7 @@
|
|||
// 安全的视频播放事件处理
|
||||
video_play_event(videoContext, is_first_play = false) {
|
||||
if (!videoContext) {
|
||||
this.setData({ paused: true });
|
||||
this.setData({ paused: true, is_manual_pause: false });
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -744,7 +753,7 @@
|
|||
if (is_first_play) {
|
||||
//#ifdef H5
|
||||
videoContext.play().catch((error) => {
|
||||
this.setData({ paused: true });
|
||||
this.setData({ paused: true, is_manual_pause: false });
|
||||
});
|
||||
//#endif
|
||||
//#ifndef H5
|
||||
|
|
@ -755,7 +764,7 @@
|
|||
}
|
||||
} catch (error) {
|
||||
console.error('视频播放异常:', error);
|
||||
this.setData({ paused: true });
|
||||
this.setData({ paused: true, is_manual_pause: false });
|
||||
}
|
||||
},
|
||||
// 安全获取视频数据的方法,处理索引超限情况
|
||||
|
|
@ -839,11 +848,11 @@
|
|||
},
|
||||
on_transition(e) {
|
||||
const dy = e.detail.dy;
|
||||
let status = 'direction'
|
||||
let status = 'direction';
|
||||
if (dy > 0) {
|
||||
status = 'next'
|
||||
status = 'next';
|
||||
} else if (dy < 0) {
|
||||
status = 'prev'
|
||||
status = 'prev';
|
||||
}
|
||||
// 如果历史的是向下滑动,这次也是向下滑动,就不更新数据
|
||||
if (this.direction != status) {
|
||||
|
|
@ -852,22 +861,8 @@
|
|||
})
|
||||
}
|
||||
},
|
||||
// 切换播放暂停
|
||||
toggle_play_pause() {
|
||||
if (this.create_video_contexts[this.current_index] == null) return; // 当前播放的视频索引为1
|
||||
|
||||
this.setData({
|
||||
paused: !this.paused
|
||||
});
|
||||
// 判断是否暂停
|
||||
if (this.paused) {
|
||||
this.create_video_contexts[this.current_index].pause(); // 暂停中间的视频
|
||||
} else {
|
||||
this.video_play_event(this.create_video_contexts[this.current_index], false); // 播放中间的视频
|
||||
}
|
||||
},
|
||||
handle_play() {
|
||||
this.setData({ paused: false });
|
||||
this.setData({ paused: false, is_manual_pause: false });
|
||||
},
|
||||
// 收藏
|
||||
handle_like(e) {
|
||||
|
|
@ -1327,8 +1322,8 @@
|
|||
// 暂停所有视频
|
||||
this.pause_all_videos_except(-1);
|
||||
// 清空视频上下文数组
|
||||
this.create_video_contexts = [];
|
||||
this.video_contexts = [];
|
||||
// this.create_video_contexts = [];
|
||||
// this.video_contexts = [];
|
||||
console.log('视频资源清理完成');
|
||||
} catch (error) {
|
||||
console.error('清理视频资源时出错:', error);
|
||||
|
|
|
|||
|
|
@ -248,6 +248,7 @@ export default {
|
|||
<style lang="scss" scoped>
|
||||
.search-record-container {
|
||||
background: #fff;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.header-top {
|
||||
|
|
|
|||
Loading…
Reference in New Issue