Эх сурвалжийг харах

Revert a player cache logic

Jimmy 1 жил өмнө
parent
commit
c59c66ae9e

+ 23 - 0
lib/view/player/buffer_waiter.dart

@@ -98,12 +98,35 @@ class VidBufferWaiter {
 
         waitCount++;
         final bufferedSize = channel.getBufferSize();
+
         if (bufferedSize >= needBufferSize) {
           // 缓存足够
+          logger.i("VidPlayer - buffer end since buffered enough");
+          logger.i("VidPlayer - BufferedSize: $bufferedSize.");
+          logger.i("VidPlayer - NeedBufferedSize: $needBufferSize.");
+          return finishFn();
+        }
+
+        if (channel.isBufferedDone) {
+          // 全部缓冲完成
+          var fileTotalSize = channel.getFileSize();
+          var fileDownloadedSize = channel.getBufferSize();
+          logger.i("VidPlayer - buffer end since all files are downloaded");
+          logger.i("VidPlayer - fileTotalSize: $fileTotalSize.");
+          logger.i("VidPlayer - filedownloaded: $fileDownloadedSize.");
           return finishFn();
         }
 
         if (waitCount >= waitCountLimit) {
+          //记录上方管理提前终止的逻辑未执行时的内存现场
+          var fileTotalSize = channel.getFileSize();
+          var fileDownloadedSize = channel.getBufferSize();
+          logger.i(
+              "VidPlayer - channel.isBufferedDone: ${channel.isBufferedDone}.");
+          logger.i("VidPlayer - BufferedSize: $bufferedSize.");
+          logger.i("VidPlayer - NeedBufferedSize: $needBufferSize.");
+          logger.i("VidPlayer - fileTotalSize: $fileTotalSize.");
+          logger.i("VidPlayer - filedownloaded: $fileDownloadedSize.");
           // 等待超时
           final bufferredSizeNow = channel.getBufferSize();
           if (bufferredSizeNow - bufferredSize < 1024) {