diff --git a/app/pages/liveRoom/index.client.vue b/app/pages/liveRoom/index.client.vue index 40410a8..19446fa 100644 --- a/app/pages/liveRoom/index.client.vue +++ b/app/pages/liveRoom/index.client.vue @@ -23,7 +23,14 @@ const {quoteStatus, show, playerId, show1, auctionData, getSocketData, getLiveLi const pullLink = ref('') const handlePlayerError = (error) => { console.error('播放器错误:', error) - player.value?.play() + showConfirmDialog({ + message: t('live_room.error_mess'), + showCancelButton: true + }).then(() => { + initializePlayer() + }).catch(() => { + }) + // player.value?.play() } const loading1=ref(false) const initializePlayer = async () => { @@ -43,6 +50,8 @@ const initializePlayer = async () => { autoplay: true, // 改为 true muted: true, // 默认静音 diagnosisButtonVisible:false, + // vodRetry:10, + // liveRetry:10, autoplayPolicy: { fallbackToMute: true }, @@ -59,14 +68,11 @@ const initializePlayer = async () => { player.value = new AliyunPlayer(playerConfig, (playerInstance) => { // 在微信环境下,需要用户手动触发播放 if (isWechat) { - console.log('当前是微信浏览器环境') const startPlay = () => { - console.log('执行了startPlay') playerInstance?.play() document.removeEventListener('WeixinJSBridgeReady', startPlay) document.removeEventListener('touchstart', startPlay) } - document.addEventListener('WeixinJSBridgeReady', startPlay) document.addEventListener('touchstart', startPlay) } @@ -74,31 +80,25 @@ const initializePlayer = async () => { playerInstance?.play() }) player.value.on('playing', () => { - console.log('playing') loading1.value = false }) - + player.value.on('loading', () => { + console.log('loading') + }) player.value.on('error', handlePlayerError) } catch (error) { showConfirmDialog({ message: t('live_room.error_mess'), showCancelButton: true }).then(() => { - location.reload() + initializePlayer() }).catch(() => { }) console.error('播放器初始化失败:', error) } } -// 添加取消静音方法 -const unmutePlayer = () => { - if (player.value) { - player.value.muted = false - player.value.play() - } -} onMounted(async () => { pullLink.value = await getLiveLink() @@ -111,25 +111,6 @@ onBeforeUnmount(() => { player.value?.dispose() player.value = null }) -const createCountUp = (element, value, options = {}) => { - const defaultOptions = { - duration: 1.5, - separator: ',', - decimal: '.', - decimalPlaces: 0, - enableScrollSpy: true, - } - const countUp = new CountUp(element, Number(value), {...defaultOptions, ...options}) - - if (!countUp.error) { - countUp.start() - } else { - console.error(countUp.error) - } - - return countUp -} - watch(() => fullLive.value, async (newVal) => { if (!newVal) return @@ -154,8 +135,9 @@ const tipOpen = () => {