2026-03-06 18:05:51 +08:00
|
|
|
|
"use strict";const i=require("../../common/vendor.js"),e=require("../../config/api.js"),t={computed:{showLoadingOverlay(){return!this.hasVideoError&&(!this.videoEnded&&!this.pausedByAudioEnd&&(!this.localVideoPath||!this.isVideoPlaying&&(!(this.userPaused&&!this.videoHasStarted&&!this.isVideoDownloading&&!this.videoWaiting)&&(!(!this.isVideoDownloading||this.videoHasStarted)||(!this.videoHasStarted||!(this.lastVideoTime>0)&&!!this.videoWaiting)))))},shouldShowPlayButton(){return!this.videoHasStarted||!this.isLoopingRestart&&!this.videoWaiting&&(!this.isVideoPlaying&&!!this.userPaused)},loadingText(){return this.isVideoDownloading?this.downloadProgress>0?`下载中 ${this.downloadProgress}%`:"准备下载...":this.videoWaiting?"缓冲中...":"加载中..."},loadingHint(){return this.waitingNeedsUserAction?"点击屏幕重试":this.isVideoDownloading&&this.downloadProgress>0?"首次播放需要下载,请稍候":""},videoError(){return this.hasVideoError},errorMessage(){return this.videoErrorMessage||"请检查网络连接后重试"}},data:()=>({API_BASE:e.API_BASE,videoId:"",videoUrl:"",audioUrl:"",videoTitle:"视频播放",audioInVideo:!1,hasAudio:!1,audioContext:null,videoContext:null,audioDuration:0,videoDuration:0,isAudioPlaying:!1,videoLoopTimer:null,audioStarted:!1,audioReady:!1,audioEnded:!1,pendingAudioStart:!1,pendingVideoPlay:!1,audioStartDelaySec:1,lastVideoTime:0,enableSilencePause:!1,silenceSegments:[],silenceLoaded:!1,pausedBySilence:!1,lastAudioTime:0,isLoopingRestart:!1,userPaused:!1,pausedByAudioEnd:!1,videoEndedWaitingAudio:!1,videoWaiting:!1,videoEnded:!1,lastVideoTimeUpdateAt:0,playbackWatchdogTimer:null,lastWaitingRecoverAt:0,localVideoPath:"",isVideoDownloading:!1,isVideoReady:!1,downloadProgress:0,downloadTask:null,pendingCacheSaveTempPath:"",pendingCacheSaveTimer:null,waitingTimer:null,waitingSince:0,waitingNeedsUserAction:!1,videoHasStarted:!1,isVideoPlaying:!1,appNetworkFallbackTimer:null,appFallbackTriggered:!1,appNetworkFallbackDelayMs:900,hasShownStorageLimitToast:!1,cacheKey:"",audioCacheKey:"",audioStartTime:0,videoStartTime:0,audioPauseTime:0,hasVideoError:!1,videoErrorMessage:"",retryCount:0,maxRetryCount:3,isRestarting:!1}),onLoad(e){console.log("[VideoPlayer] 接收参数:",e),console.log("[VideoPlayer] BUILD_MARK_NO_EXTERNAL_AUDIO=2026-01-08-01");const t="1"===e.audioInVideo||"true"===e.audioInVideo;if(void 0!==e.id&&null!==e.id&&""!==String(e.id).trim()&&(this.videoId=String(e.id).trim()),e.videoUrl?this.videoUrl=decodeURIComponent(e.videoUrl):e.url&&(this.videoUrl=decodeURIComponent(e.url)),void 0!==e.audioDelay&&null!==e.audioDelay&&""!==String(e.audioDelay).trim()){const i=Number(e.audioDelay);!Number.isNaN(i)&&i>=0&&(this.audioStartDelaySec=i)}if(void 0!==e.silencePause&&null!==e.silencePause&&""!==String(e.silencePause).trim()){const i=String(e.silencePause).trim();this.enableSilencePause="1"===i||"true"===i}if(this.videoUrl=this.normalizeMediaUrl(this.videoUrl),this.videoEnded=!1,this.userPaused=!0,this.videoId)this.loadVideoFromDb(t,e);else{const i=!(!this.videoUrl||-1===this.videoUrl.indexOf("/static/videos/revival_")),e=t||i;this.audioInVideo=e,console.log("[VideoPlayer] audioInVideo判定: audioInVideoParam=",t,"matchInVideo=",i,"videoUrl=",this.videoUrl),this.cacheKey=this.generateCacheKey(this.videoUrl),this.loadVideo()}e.title&&(this.videoTitle=decodeURIComponent(e.title)),this.hasAudio=!1,this.audioUrl="",audioInVideo?(this.hasAudio=!0,console.log("[VideoPlayer] audioInVideo=1,使用视频自带音轨")):e.audioUrl&&console.log("[VideoPlayer] 已忽略外部 audioUrl 参数(禁用外部音频)"),this.$nextTick((()=>{this.videoContext=i.index.createVideoContext("videoPlayer",this)}))},onUnload(){this.stopVideoLoop(),this.stopPlaybackWatchdog(),this.pendingCacheSaveTimer&&(clearTimeout(this.pendingCacheSaveTimer),this.pendingCacheSaveTimer=null),this.waitingTimer&&(clearTimeout(this.waitingTimer),this.waitingTimer=null);try{this.downloadTask&&"function"==typeof this.downloadTask.abort&&this.downloadTask.abort()}catch(i){}this.downloadTask=null,this.audioContext&&(th
|