Răsfoiți Sursa

百度网盘时长没显示问题

onecold 8 luni în urmă
părinte
comite
35e2a1bcf9
1 a modificat fișierele cu 26 adăugiri și 16 ștergeri
  1. 26 16
      entry/src/main/ets/view/LocalMusic.ets

+ 26 - 16
entry/src/main/ets/view/LocalMusic.ets

@@ -5579,10 +5579,10 @@ export struct LocalMusic {
             const currentOffsetY = this.waterScroller.currentOffset().yOffset;
             const currentOffsetY = this.waterScroller.currentOffset().yOffset;
             // 判断滚动方向
             // 判断滚动方向
             if (currentOffsetY > this.prevOffsetY) {
             if (currentOffsetY > this.prevOffsetY) {
-              console.log("onecold 向上滚动");
+              // console.log("onecold 向上滚动");
               this.isShowTitleBar = false
               this.isShowTitleBar = false
             } else if (currentOffsetY < this.prevOffsetY) {
             } else if (currentOffsetY < this.prevOffsetY) {
-              console.log("onecold 向下滚动");
+              // console.log("onecold 向下滚动");
               this.isShowTitleBar = true
               this.isShowTitleBar = true
             }
             }
             // 更新前一次偏移量
             // 更新前一次偏移量
@@ -5926,10 +5926,10 @@ export struct LocalMusic {
         const currentOffsetY = this.scroller.currentOffset().yOffset;
         const currentOffsetY = this.scroller.currentOffset().yOffset;
         // 判断滚动方向
         // 判断滚动方向
         if (currentOffsetY > this.prevOffsetY) {
         if (currentOffsetY > this.prevOffsetY) {
-          console.log("onecold 向上滚动");
+          // console.log("onecold 向上滚动");
           this.isShowTitleBar = false
           this.isShowTitleBar = false
         } else if (currentOffsetY < this.prevOffsetY) {
         } else if (currentOffsetY < this.prevOffsetY) {
-          console.log("onecold 向下滚动");
+          // console.log("onecold 向下滚动");
           this.isShowTitleBar = true
           this.isShowTitleBar = true
         }
         }
         // 更新前一次偏移量
         // 更新前一次偏移量
@@ -6750,10 +6750,10 @@ export struct LocalMusic {
         const currentOffsetY = this.listScroller.currentOffset().yOffset;
         const currentOffsetY = this.listScroller.currentOffset().yOffset;
         // 判断滚动方向
         // 判断滚动方向
         if (currentOffsetY > this.prevOffsetY) {
         if (currentOffsetY > this.prevOffsetY) {
-          console.log("onecold 向上滚动");
+          // console.log("onecold 向上滚动");
           this.isShowTitleBar = false
           this.isShowTitleBar = false
         } else if (currentOffsetY < this.prevOffsetY) {
         } else if (currentOffsetY < this.prevOffsetY) {
-          console.log("onecold 向下滚动");
+          // console.log("onecold 向下滚动");
           this.isShowTitleBar = true
           this.isShowTitleBar = true
         }
         }
         // 更新前一次偏移量
         // 更新前一次偏移量
@@ -13216,8 +13216,6 @@ export struct LocalMusic {
       this.stopProgressTask();
       this.stopProgressTask();
       this.startProgressTask();
       this.startProgressTask();
       this.play(this.videoUrl.toString(),startOffset);
       this.play(this.videoUrl.toString(),startOffset);
-
-
     }
     }
     if (this.CONTROL_PlayStatus == PlayStatus.PAUSE) {
     if (this.CONTROL_PlayStatus == PlayStatus.PAUSE) {
       this.mIjkMediaPlayer.start();
       this.mIjkMediaPlayer.start();
@@ -13522,14 +13520,7 @@ export struct LocalMusic {
     //使用精确寻帧 例如,拖动播放后,会寻找最近的关键帧进行播放,很有可能关键帧的位置不是拖动后的位置,而是较前的位置.可以设置这个参数来解决问题
     //使用精确寻帧 例如,拖动播放后,会寻找最近的关键帧进行播放,很有可能关键帧的位置不是拖动后的位置,而是较前的位置.可以设置这个参数来解决问题
     this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "enable-accurate-seek", "1");
     this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "enable-accurate-seek", "1");
 
 
-    const fileSize = await this.getFileSize(this.videoUrl);
-    let bufferSize = 100 * 1024 ; // 默认缓冲区大小为1MB
-
-    // 使用软件解码(通常比硬件解码更节省内存)
-    // this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER,  "mediacodec-auto-rotate", '0');
-    // this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER,  "mediacodec-handle-resolution-change", '0');
-    // this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT,  "probesize", '1024');
-    // this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT,  "analyzeduration", '500000');
+    let bufferSize = 50 * 1024 ; // 默认缓冲区大小为1MB
 
 
     //预读数据的缓冲区大小.修复大文件播放前几秒挂掉的bug,太大了会导致倍数播放失效
     //预读数据的缓冲区大小.修复大文件播放前几秒挂掉的bug,太大了会导致倍数播放失效
     this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max-buffer-size", bufferSize + '');
     this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max-buffer-size", bufferSize + '');
@@ -13555,6 +13546,9 @@ export struct LocalMusic {
     this.mIjkMediaPlayer.setOptionLong(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "infbuf", "1")
     this.mIjkMediaPlayer.setOptionLong(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "infbuf", "1")
     // 屏幕常亮
     // 屏幕常亮
     this.mIjkMediaPlayer.setScreenOnWhilePlaying(true);
     this.mIjkMediaPlayer.setScreenOnWhilePlaying(true);
+
+    // 开启hls起播优化 默认是关闭的
+    this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "fetch_first", "on");
     // 设置超时
     // 设置超时
     this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "timeout", "10000000");
     this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "timeout", "10000000");
     this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "connect_timeout", "10000000");
     this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "connect_timeout", "10000000");
@@ -13601,10 +13595,26 @@ export struct LocalMusic {
           await this.initLyric(lyricPath);
           await this.initLyric(lyricPath);
 
 
           const preparedDuration = this.mIjkMediaPlayer.getDuration();
           const preparedDuration = this.mIjkMediaPlayer.getDuration();
+          console.info("onecold preparedDuration--" + preparedDuration)
           if (preparedDuration > 0) {
           if (preparedDuration > 0) {
             this.duration = preparedDuration;
             this.duration = preparedDuration;
             this.durationTime = Math.floor(preparedDuration / 1000);
             this.durationTime = Math.floor(preparedDuration / 1000);
             this.durationStringTime = secondToTime(this.durationTime);
             this.durationStringTime = secondToTime(this.durationTime);
+            console.info("onecold durationTime--" + this.durationTime)
+            console.info("onecold durationStringTime--" + this.durationStringTime)
+          }else{
+            setTimeout( ()=>{
+              this.duration  = this.mIjkMediaPlayer.getDuration();
+              this.durationTime = Math.floor(preparedDuration / 1000);
+              this.durationStringTime = secondToTime(this.durationTime);
+              console.info("onecold duration3--" + this.duration)
+              console.info("onecold durationStringTime3--" + this.durationStringTime)
+            },200)
+            this.duration  = this.mIjkMediaPlayer.getDuration();
+            this.durationTime = Math.floor(preparedDuration / 1000);
+            this.durationStringTime = secondToTime(this.durationTime);
+            console.info("onecold duration2--" + this.duration)
+            console.info("onecold durationStringTim2e--" + this.durationStringTime)
           }
           }
 
 
           setTimeout(() => {
           setTimeout(() => {