|
|
@@ -7,18 +7,19 @@
|
|
|
<live-player v-if="liveItem.livingUrl && liveItem.liveType == 1" :id="'myLivePlayer_' + liveId"
|
|
|
:src="liveItem.livingUrl" autoplay mode="live" object-fit="cover" :muted="false"
|
|
|
orientation="vertical" :enable-play-gesture="false" min-cache="1" max-cache="3"
|
|
|
- @statechange="onLiveStateChange" @error="onLiveError" class="item"></live-player>
|
|
|
+ @statechange="onLiveStateChange" @error="onLiveError" class="item"
|
|
|
+ :flushed="false" :seek="0"></live-player>
|
|
|
|
|
|
<!-- 录播 -->
|
|
|
<video v-if="liveItem.videoUrl && liveItem.liveType == 2" :id="`myVideo_${liveId}`" :autoplay="true"
|
|
|
class="item" :src="liveItem.videoUrl" :controls="false"
|
|
|
- :object-fit="liveItem.showType==2||isFullscreen?'contain':'fill'" :custom-cache="false"
|
|
|
+ :object-fit="liveItem.showType==2||isFullscreen?'contain':'fill'"
|
|
|
:enable-progress-gesture="false" vslide-gesture-in-fullscreen="false" :show-center-play-btn="false"
|
|
|
- :http-cache="false" loop @error="videoError" @timeupdate="onVideoTimeUpdate"
|
|
|
+ loop @error="videoError" @timeupdate="onVideoTimeUpdate"
|
|
|
@loadedmetadata="onVideoMetaLoaded" @pause="onVideoPause" @play="onVideoPlay"
|
|
|
- @waiting="onVideoWaiting" :enable-play-gesture="false" :play-strategy="1"
|
|
|
- @dblclick="preventDoubleClick" preload="auto" :enable-stash-buffer="false" :stash-initial-size="0"
|
|
|
- :stash-max-size="0" :stash-time="0" type="application/x-mpegURL"></video>
|
|
|
+ @waiting="onVideoWaiting" :enable-play-gesture="false"
|
|
|
+ @dblclick="preventDoubleClick" preload="metadata"
|
|
|
+ :initial-time="0" :show-play-btn="false" :show-fullscreen-btn="false" :show-playback-rate-btn="false"></video>
|
|
|
<view v-if="liveItem.videoUrl && liveItem.liveType == 2" class="time"
|
|
|
:class="isFullscreen ? 'look-time' : 'time'">{{ diffTotalTime }}</view>
|
|
|
<view class="custom-controls" @click.stop="toggleFullscreen">
|
|
|
@@ -44,24 +45,24 @@
|
|
|
<view class="videolist" v-if="liveItem.status == 4">
|
|
|
<view class="video" :class="liveItem.showType == 1 ? 'video_row' : ''">
|
|
|
<!-- 直播回放 -->
|
|
|
- <video v-if="liveItem.videoUrl && liveItem.liveType == 3" :id="`myVideo_${liveId}`" class="item"
|
|
|
- :src="liveItem.videoUrl" :autoplay="true" :controls="true" object-fit="cover" :custom-cache="false"
|
|
|
- :enable-progress-gesture="liveItem.isSpeedAllowed" vslide-gesture-in-fullscreen="true"
|
|
|
- :show-center-play-btn="true" :http-cache="false" loop @error="videoError"
|
|
|
- @timeupdate="onVideoTimeUpdate" @loadedmetadata="onVideoMetaLoaded" @pause="onVideoPause"
|
|
|
- @play="onVideoPlay" :enable-play-gesture="true" preload="auto" @waiting="onVideoWaiting"
|
|
|
- type="application/x-mpegURL"></video>
|
|
|
+ <video v-if="liveItem.videoUrl && liveItem.liveType == 3" :id="`myVideo_${liveId}`" class="item"
|
|
|
+ :src="liveItem.videoUrl" :autoplay="true" :controls="true" object-fit="cover"
|
|
|
+ :enable-progress-gesture="liveItem.isSpeedAllowed" vslide-gesture-in-fullscreen="true"
|
|
|
+ :show-center-play-btn="true" loop @error="videoError"
|
|
|
+ @timeupdate="onVideoTimeUpdate" @loadedmetadata="onVideoMetaLoaded" @pause="onVideoPause"
|
|
|
+ @play="onVideoPlay" :enable-play-gesture="true" preload="metadata" @waiting="onVideoWaiting"
|
|
|
+ :initial-time="0"></video>
|
|
|
<view v-if="liveItem.videoUrl && liveItem.liveType == 3" class="lable">直播回放</view>
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
<view class="trailer-box" v-if="liveItem.status == 1">
|
|
|
<video v-if="liveItem.previewUrl" :id="`myVideo_${liveId}`" class="trailer-video" :src="liveItem.previewUrl"
|
|
|
- :autoplay="true" loop object-fit="cover" :custom-cache="false" :enable-progress-gesture="false"
|
|
|
- vslide-gesture-in-fullscreen="false" :show-center-play-btn="false" :http-cache="false"
|
|
|
- @error="videoError" @loadedmetadata="onVideoMetaLoaded" @pause="onVideoPause" @play="onVideoPlay"
|
|
|
- :disable-progress="true" :enable-play-gesture="true" @waiting="onVideoWaiting" preload="auto"
|
|
|
- type="application/x-mpegURL" :controls="false"></video>
|
|
|
+ :autoplay="true" loop object-fit="cover"
|
|
|
+ vslide-gesture-in-fullscreen="false" :show-center-play-btn="false"
|
|
|
+ @error="videoError" @loadedmetadata="onVideoMetaLoaded" @pause="onVideoPause" @play="onVideoPlay"
|
|
|
+ :disable-progress="true" :enable-play-gesture="true" @waiting="onVideoWaiting" preload="metadata"
|
|
|
+ :controls="false" :initial-time="0" :show-play-btn="false" :show-fullscreen-btn="false"></video>
|
|
|
<image v-if="liveItem.status == 1 && !liveItem.previewUrl" class="trailer-placeholder"
|
|
|
src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/no_live.png">
|
|
|
</image>
|
|
|
@@ -143,46 +144,54 @@
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
- return {
|
|
|
- videoLoaded: false, // 视频是否加载成功
|
|
|
- isManualPause: false, // 是否手动暂停
|
|
|
- waitingTimer: null, // 视频等待定时器
|
|
|
- waitingStartTime: 0, // 视频等待开始时间
|
|
|
- lastVideoUpdateTime: 0, // 视频最后更新时间
|
|
|
- trafficStartTime: 0, // 流量计算开始时间
|
|
|
- liveBeginWatchTime: 0, //开始观看的时间点 不包含预告
|
|
|
-
|
|
|
-
|
|
|
- // hasSubscribed: false, // 已成功订阅(永久禁用)
|
|
|
- isFullscreen: false,
|
|
|
- isVideoRotated: false,
|
|
|
- showNonVideoElementsFlag: true,
|
|
|
- showCustomControls: true,
|
|
|
- videoContext: null,
|
|
|
-
|
|
|
- // 流量计算相关
|
|
|
- uuId: '',
|
|
|
- totalTraffic: 0,
|
|
|
- bitrate: 800,
|
|
|
- bitrateLive: 1600,
|
|
|
-
|
|
|
- // 定时器
|
|
|
- trafficTimer: null,
|
|
|
- liveStartTimer: null,
|
|
|
- trafficInterval: null,
|
|
|
- lookTimer: null,
|
|
|
-
|
|
|
- // 状态数据
|
|
|
- liveCountdown: {},
|
|
|
- diffTotalTime: '',
|
|
|
- videoCurrentTime: 0,
|
|
|
- videoProgressKey: '',
|
|
|
- startTime: 0,
|
|
|
- stayTime: 0,
|
|
|
- // 内部状态跟踪
|
|
|
- hasInitialized: false,
|
|
|
- lastLiveItemStatus: null
|
|
|
- };
|
|
|
+ return {
|
|
|
+ videoLoaded: false, // 视频是否加载成功
|
|
|
+ isManualPause: false, // 是否手动暂停
|
|
|
+ waitingTimer: null, // 视频等待定时器
|
|
|
+ waitingStartTime: 0, // 视频等待开始时间
|
|
|
+ lastVideoUpdateTime: 0, // 视频最后更新时间
|
|
|
+ trafficStartTime: 0, // 流量计算开始时间
|
|
|
+ liveBeginWatchTime: 0, //开始观看的时间点 不包含预告
|
|
|
+
|
|
|
+ // 视频加载状态管理
|
|
|
+ videoLoading: false, // 视频是否正在加载
|
|
|
+ videoLoadError: false, // 视频加载是否出错
|
|
|
+ videoRetryCount: 0, // 视频加载重试次数
|
|
|
+ maxRetryCount: 3, // 最大重试次数
|
|
|
+ isHarmonyOS: false, // 是否为鸿蒙系统
|
|
|
+ localIsAgreement: false, // 本地存储的协议同意状态
|
|
|
+
|
|
|
+
|
|
|
+ // hasSubscribed: false, // 已成功订阅(永久禁用)
|
|
|
+ isFullscreen: false,
|
|
|
+ isVideoRotated: false,
|
|
|
+ showNonVideoElementsFlag: true,
|
|
|
+ showCustomControls: true,
|
|
|
+ videoContext: null,
|
|
|
+
|
|
|
+ // 流量计算相关
|
|
|
+ uuId: '',
|
|
|
+ totalTraffic: 0,
|
|
|
+ bitrate: 800,
|
|
|
+ bitrateLive: 1600,
|
|
|
+
|
|
|
+ // 定时器
|
|
|
+ trafficTimer: null,
|
|
|
+ liveStartTimer: null,
|
|
|
+ trafficInterval: null,
|
|
|
+ lookTimer: null,
|
|
|
+
|
|
|
+ // 状态数据
|
|
|
+ liveCountdown: {},
|
|
|
+ diffTotalTime: '',
|
|
|
+ videoCurrentTime: 0,
|
|
|
+ videoProgressKey: '',
|
|
|
+ startTime: 0,
|
|
|
+ stayTime: 0,
|
|
|
+ // 内部状态跟踪
|
|
|
+ hasInitialized: false,
|
|
|
+ lastLiveItemStatus: null
|
|
|
+ };
|
|
|
},
|
|
|
watch: {
|
|
|
// 深度监听 liveItem 的所有变化
|
|
|
@@ -231,7 +240,14 @@
|
|
|
},
|
|
|
},
|
|
|
beforeUnmount() {
|
|
|
+ // 暂停所有视频播放
|
|
|
+ this.pauseVideo();
|
|
|
+ // 清理所有定时器
|
|
|
this.cleanup();
|
|
|
+ // 清理所有可能的引用
|
|
|
+ this.liveItem = null;
|
|
|
+ this.liveId = null;
|
|
|
+ this.userData = null;
|
|
|
// 强制退出全屏
|
|
|
this.isFullscreen = false;
|
|
|
this.showCustomControls = true;
|
|
|
@@ -417,21 +433,61 @@
|
|
|
const livePlayerContext = uni.createLivePlayerContext(livePlayerId, this);
|
|
|
// console.log("直播")
|
|
|
if (livePlayerContext) {
|
|
|
- livePlayerContext.play();
|
|
|
+ if (this.isHarmonyOS) {
|
|
|
+ console.log('鸿蒙系统播放直播');
|
|
|
+ // 鸿蒙系统特殊处理:延迟播放并添加重试机制
|
|
|
+ setTimeout(() => {
|
|
|
+ try {
|
|
|
+ livePlayerContext.play();
|
|
|
+ console.log('鸿蒙系统直播播放命令已发送');
|
|
|
+ // 强制UI更新
|
|
|
+ this.$forceUpdate();
|
|
|
+ // 1秒后再次检查播放状态
|
|
|
+ setTimeout(() => {
|
|
|
+ console.log('鸿蒙系统直播播放状态检查');
|
|
|
+ // 再次强制UI更新
|
|
|
+ this.$forceUpdate();
|
|
|
+ }, 1000);
|
|
|
+ } catch (error) {
|
|
|
+ console.error('鸿蒙系统直播播放失败:', error);
|
|
|
+ // 播放失败时重试
|
|
|
+ setTimeout(() => {
|
|
|
+ livePlayerContext.play();
|
|
|
+ console.log('鸿蒙系统直播播放重试');
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
+ }, 500);
|
|
|
+ } else {
|
|
|
+ livePlayerContext.play();
|
|
|
+ }
|
|
|
}
|
|
|
} else if (this.liveItem.status == 1 && this.liveItem.previewUrl) {
|
|
|
const videoId = `myVideo_${this.liveId}`;
|
|
|
const videoContext = uni.createVideoContext(videoId, this);
|
|
|
|
|
|
if (videoContext) {
|
|
|
- videoContext.play();
|
|
|
+ if (this.isHarmonyOS) {
|
|
|
+ // 鸿蒙系统特殊处理:延迟播放
|
|
|
+ setTimeout(() => {
|
|
|
+ videoContext.play();
|
|
|
+ }, 500);
|
|
|
+ } else {
|
|
|
+ videoContext.play();
|
|
|
+ }
|
|
|
}
|
|
|
} else if (this.liveItem.liveType === 2 && this.liveItem.videoUrl && this.liveItem.status == 2) {
|
|
|
const videoId = `myVideo_${this.liveId}`;
|
|
|
const videoContext = uni.createVideoContext(videoId, this);
|
|
|
// console.log("录播")
|
|
|
if (videoContext) {
|
|
|
- videoContext.play();
|
|
|
+ if (this.isHarmonyOS) {
|
|
|
+ // 鸿蒙系统特殊处理:延迟播放
|
|
|
+ setTimeout(() => {
|
|
|
+ videoContext.play();
|
|
|
+ }, 500);
|
|
|
+ } else {
|
|
|
+ videoContext.play();
|
|
|
+ }
|
|
|
}
|
|
|
} // 回放视频使用video
|
|
|
else if (this.liveItem.liveType === 3 && this.liveItem.videoUrl && this.liveItem.status == 4) {
|
|
|
@@ -439,11 +495,26 @@
|
|
|
const videoContext = uni.createVideoContext(videoId, this);
|
|
|
// console.log("回放")
|
|
|
if (videoContext) {
|
|
|
- videoContext.play();
|
|
|
+ if (this.isHarmonyOS) {
|
|
|
+ // 鸿蒙系统特殊处理:延迟播放
|
|
|
+ setTimeout(() => {
|
|
|
+ videoContext.play();
|
|
|
+ }, 500);
|
|
|
+ } else {
|
|
|
+ videoContext.play();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('播放视频失败:', error);
|
|
|
+ // 播放失败时尝试重试
|
|
|
+ if (this.videoRetryCount < this.maxRetryCount) {
|
|
|
+ this.videoRetryCount++;
|
|
|
+ console.log(`视频播放失败,${this.videoRetryCount}秒后重试`);
|
|
|
+ setTimeout(() => {
|
|
|
+ this.playVideo();
|
|
|
+ }, this.videoRetryCount * 1000);
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -480,6 +551,7 @@
|
|
|
// 视频错误处理
|
|
|
videoError(e, liveItem) {
|
|
|
if (!liveItem || !this.liveId) return;
|
|
|
+ console.error('视频错误:', e, liveItem);
|
|
|
// 初始化重试计数
|
|
|
if (this.videoRetryCounts[liveItem.liveId] === undefined) {
|
|
|
this.videoRetryCounts[liveItem.liveId] = 0;
|
|
|
@@ -498,13 +570,16 @@
|
|
|
|
|
|
this.videoRetryCounts[this.liveId]++;
|
|
|
|
|
|
+ // 鸿蒙系统特殊处理:更长的重试延迟
|
|
|
+ const retryDelay = this.isHarmonyOS ? 3000 : 2000;
|
|
|
+
|
|
|
// 延迟重试
|
|
|
setTimeout(() => {
|
|
|
if (this.liveId === this.liveId) {
|
|
|
console.log(`第${this.videoRetryCounts[this.liveId]}次重试播放视频`);
|
|
|
this.playVideo();
|
|
|
}
|
|
|
- }, 2000);
|
|
|
+ }, retryDelay);
|
|
|
}, // 视频暂停
|
|
|
onVideoPause(e) {
|
|
|
if (this.liveItem.liveType === 2) {
|
|
|
@@ -587,6 +662,25 @@
|
|
|
this.trafficTimer = setInterval(() => {
|
|
|
that.calculateTraffic(bitrate);
|
|
|
}, 10000); // 每10秒计算一次
|
|
|
+ },
|
|
|
+ // 清理所有定时器
|
|
|
+ clearAllTimers() {
|
|
|
+ if (this.trafficTimer) {
|
|
|
+ clearInterval(this.trafficTimer);
|
|
|
+ this.trafficTimer = null;
|
|
|
+ }
|
|
|
+ if (this.lookTimer) {
|
|
|
+ clearInterval(this.lookTimer);
|
|
|
+ this.lookTimer = null;
|
|
|
+ }
|
|
|
+ if (this.liveStartTimer) {
|
|
|
+ clearInterval(this.liveStartTimer);
|
|
|
+ this.liveStartTimer = null;
|
|
|
+ }
|
|
|
+ if (this.trafficInterval) {
|
|
|
+ clearInterval(this.trafficInterval);
|
|
|
+ this.trafficInterval = null;
|
|
|
+ }
|
|
|
}, // 计算码率
|
|
|
calculateBitrate() {
|
|
|
// 如果接口返回了视频文件大小和时长,使用这些数据计算码率
|
|
|
@@ -679,6 +773,31 @@
|
|
|
that.getInternetTraffic();
|
|
|
}, 10000);
|
|
|
}
|
|
|
+
|
|
|
+ // 记录等待开始时间
|
|
|
+ if (!this.waitingStartTime) {
|
|
|
+ this.waitingStartTime = Date.now();
|
|
|
+ }
|
|
|
+ // 检测是否真的出现黑屏或卡顿(等待超过5秒且视频时间没有更新)
|
|
|
+ if (!this.waitingTimer) {
|
|
|
+ this.waitingTimer = setTimeout(() => {
|
|
|
+ const waitingDuration = Date.now() - this.waitingStartTime;
|
|
|
+ const timeSinceLastUpdate = Date.now() - this.lastVideoUpdateTime;
|
|
|
+
|
|
|
+ // 只有在等待超过5秒,且视频时间超过3秒没有更新时,才认为是真正的卡顿/黑屏
|
|
|
+ if (waitingDuration >= 5000 && timeSinceLastUpdate >= 3000) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '当前您的网络不稳定',
|
|
|
+ icon: 'loading',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ // 鸿蒙系统特殊处理:检测到黑屏时主动处理
|
|
|
+ if (this.isHarmonyOS) {
|
|
|
+ this.handleHarmonyOSBlackScreen();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 5000); // 延迟5秒检测
|
|
|
+ }
|
|
|
},
|
|
|
setVideoProgress() {
|
|
|
// 只有录播和回放需要设置进度
|
|
|
@@ -745,6 +864,18 @@
|
|
|
onVideoTimeUpdate(e) {
|
|
|
// 获取当前播放时间
|
|
|
this.videoCurrentTime = e.detail.currentTime;
|
|
|
+ // 更新视频最后更新时间(用于检测是否卡顿)
|
|
|
+ this.lastVideoUpdateTime = Date.now();
|
|
|
+
|
|
|
+ // 如果视频在更新,说明没有卡顿,清除等待状态
|
|
|
+ if (this.waitingStartTime && this.lastVideoUpdateTime - this.waitingStartTime < 1000) {
|
|
|
+ // 视频在1秒内恢复了,清除等待定时器
|
|
|
+ if (this.waitingTimer) {
|
|
|
+ clearTimeout(this.waitingTimer);
|
|
|
+ this.waitingTimer = null;
|
|
|
+ }
|
|
|
+ this.waitingStartTime = 0;
|
|
|
+ }
|
|
|
// 每隔10秒保存一次进度(避免频繁存储)
|
|
|
if (Math.floor(this.videoCurrentTime) % 10 === 0) {
|
|
|
this.saveVideoProgress();
|
|
|
@@ -779,8 +910,11 @@
|
|
|
开始时间: this.liveItem?.startTime
|
|
|
});
|
|
|
|
|
|
+ // 检测系统类型
|
|
|
+ this.detectSystemType();
|
|
|
+
|
|
|
this.uuId = generateRandomString(16);
|
|
|
- this.isAgreement = uni.getStorageSync('isAgreement');
|
|
|
+ this.localIsAgreement = uni.getStorageSync('isAgreement');
|
|
|
|
|
|
// 立即检查当前状态并启动相应功能
|
|
|
if (this.liveItem?.status === 1 && this.liveItem.startTime) {
|
|
|
@@ -794,6 +928,33 @@
|
|
|
this.startTimer();
|
|
|
this.hasInitialized = true;
|
|
|
},
|
|
|
+ // 检测系统类型
|
|
|
+ detectSystemType() {
|
|
|
+ try {
|
|
|
+ const systemInfo = uni.getSystemInfoSync();
|
|
|
+ console.log('系统信息:', systemInfo);
|
|
|
+ // 检测是否为鸿蒙系统
|
|
|
+ // 检查多个可能的字段
|
|
|
+ const isHarmony = (
|
|
|
+ systemInfo.platform === 'openharmony' ||
|
|
|
+ systemInfo.system?.toLowerCase().includes('harmony') ||
|
|
|
+ systemInfo.osName?.toLowerCase().includes('harmony') ||
|
|
|
+ systemInfo.platform?.toLowerCase().includes('harmony')
|
|
|
+ );
|
|
|
+ if (isHarmony) {
|
|
|
+ this.isHarmonyOS = true;
|
|
|
+ console.log('检测到鸿蒙系统');
|
|
|
+ } else {
|
|
|
+ console.log('非鸿蒙系统:', {
|
|
|
+ platform: systemInfo.platform,
|
|
|
+ system: systemInfo.system,
|
|
|
+ osName: systemInfo.osName
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取系统信息失败:', error);
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
// 启动直播倒计时 - 增强版本
|
|
|
startLiveCountdown() {
|
|
|
@@ -940,11 +1101,88 @@
|
|
|
clearInterval(this.lookTimer);
|
|
|
this.lookTimer = null;
|
|
|
}
|
|
|
+ // 清理等待定时器
|
|
|
+ if (this.waitingTimer) {
|
|
|
+ clearTimeout(this.waitingTimer);
|
|
|
+ this.waitingTimer = null;
|
|
|
+ }
|
|
|
if (this.liveItem && this.liveItem.timeTimer) {
|
|
|
clearInterval(this.liveItem.timeTimer);
|
|
|
this.liveItem.timeTimer = null;
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ // 重置视频状态 - 用于处理黑屏问题
|
|
|
+ resetVideoState() {
|
|
|
+ console.log('重置视频状态');
|
|
|
+ // 重置视频加载状态
|
|
|
+ this.videoLoaded = false;
|
|
|
+ this.videoLoading = false;
|
|
|
+ this.videoLoadError = false;
|
|
|
+ this.videoRetryCount = 0;
|
|
|
+ // 清理所有定时器
|
|
|
+ this.cleanup();
|
|
|
+ // 重新播放视频
|
|
|
+ if (this.liveItem) {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.playVideo();
|
|
|
+ }, 500);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 鸿蒙系统黑屏处理
|
|
|
+ handleHarmonyOSBlackScreen() {
|
|
|
+ if (!this.isHarmonyOS) return;
|
|
|
+ console.log('鸿蒙系统黑屏处理');
|
|
|
+ // 重置视频状态
|
|
|
+ this.resetVideoState();
|
|
|
+ // 显示加载提示
|
|
|
+ uni.showToast({
|
|
|
+ title: '视频加载中,请稍候...',
|
|
|
+ icon: 'loading',
|
|
|
+ duration: 3000
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 直播状态变化处理
|
|
|
+ onLiveStateChange(e) {
|
|
|
+ console.log('直播状态变化:', e);
|
|
|
+ // 获取直播状态
|
|
|
+ const state = e.detail.state;
|
|
|
+ console.log('直播状态:', state);
|
|
|
+ // 鸿蒙系统特殊处理
|
|
|
+ if (this.isHarmonyOS) {
|
|
|
+ console.log('鸿蒙系统直播状态变化:', state);
|
|
|
+ // 当状态为2(播放中)时,确保视频正常显示
|
|
|
+ if (state === 2) {
|
|
|
+ console.log('鸿蒙系统直播开始播放');
|
|
|
+ // 强制UI更新
|
|
|
+ this.$forceUpdate();
|
|
|
+ }
|
|
|
+ // 当状态为3(加载中)时,显示加载提示
|
|
|
+ else if (state === 3) {
|
|
|
+ console.log('鸿蒙系统直播加载中');
|
|
|
+ uni.showToast({
|
|
|
+ title: '直播加载中,请稍候...',
|
|
|
+ icon: 'loading',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 直播错误处理
|
|
|
+ onLiveError(e) {
|
|
|
+ console.error('直播错误:', e);
|
|
|
+ // 显示错误提示
|
|
|
+ uni.showToast({
|
|
|
+ title: '直播加载失败,请检查网络',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ // 鸿蒙系统特殊处理
|
|
|
+ if (this.isHarmonyOS) {
|
|
|
+ console.log('鸿蒙系统直播错误处理');
|
|
|
+ // 重置视频状态
|
|
|
+ this.resetVideoState();
|
|
|
+ }
|
|
|
+ },
|
|
|
}
|
|
|
};
|
|
|
</script>
|