Просмотр исходного кода

修复webdav大概率加载不了情况
修复webdav更新封面list跳动问题
修复webdav随机模式下播放不了下一首
修复webdav随机播放下 播放上一首错误问题

onecold 6 месяцев назад
Родитель
Сommit
ddc5997e18

+ 4 - 1
entry/src/main/ets/common/network/BaiduFileCache.ets

@@ -137,7 +137,10 @@ async function ensureBaiduFileCachedInternal(
   let exists = await FileManager.isExist(cachePath);
   if (exists) {
     const size = await FileManager.getFileSize(cachePath);
-    if (size <= 0) {
+    // 检查文件是否有效:大小必须大于0且匹配预期大小(如果提供了预期大小)
+    const isValid = size > 0 && (fileSize === 0 || size === fileSize);
+    if (!isValid) {
+      Logger.warn(TAG, `缓存文件不完整,删除重试: path=${cachePath}, size=${size}, expect=${fileSize}`);
       await FileManager.deleteFile(cachePath);
       exists = false;
     }

+ 51 - 0
entry/src/main/ets/common/util/MediaTable.ets

@@ -1451,6 +1451,57 @@ export default  class MediaTable {
     return await this.getTotalCount(predicates);
   }
 
+  /**
+   * 更新歌曲的webdav_account_id
+   * @param filePath 歌曲文件路径
+   * @param accountId 新的账号ID
+   * @returns Promise<boolean> 更新是否成功
+   */
+  public async updateWebDavAccountId(filePath: string, accountId: string): Promise<boolean> {
+    const normalizedPath = normalizeFilePath(filePath);
+    return new Promise<boolean>((resolve, reject) => {
+      try {
+        // 先查询记录是否存在
+        const queryPredicates = new relationalStore.RdbPredicates(RdbUtils.MEDIA_TABLE.tableName);
+        queryPredicates.equalTo(DB_COLUMNS.FILE_PATH, normalizedPath);
+
+        this.accountTable.query(queryPredicates, (resultSet: relationalStore.ResultSet) => {
+          try {
+            if (resultSet.rowCount === 0) {
+              Logger.warn(RdbUtils.RDB_TAG, `updateWebDavAccountId: 未找到记录 ${normalizedPath}`);
+              resolve(false);
+              resultSet.close();
+              return;
+            }
+            resultSet.close();
+
+            // 更新webdav_account_id
+            const updatePredicates = new relationalStore.RdbPredicates(RdbUtils.MEDIA_TABLE.tableName);
+            updatePredicates.equalTo(DB_COLUMNS.FILE_PATH, normalizedPath);
+            const valueBucket: relationalStore.ValuesBucket = {
+              webdav_account_id: accountId
+            };
+
+            this.accountTable.updateData(updatePredicates, valueBucket, (success: boolean) => {
+              if (success) {
+                Logger.info(RdbUtils.RDB_TAG, `updateWebDavAccountId: 成功更新 ${normalizedPath} -> ${accountId}`);
+              } else {
+                Logger.error(RdbUtils.RDB_TAG, `updateWebDavAccountId: 更新失败 ${normalizedPath}`);
+              }
+              resolve(success);
+            });
+          } catch (err) {
+            Logger.error(RdbUtils.RDB_TAG, `updateWebDavAccountId error: ${(err as Error).message}`);
+            reject(err);
+          }
+        });
+      } catch (err) {
+        Logger.error(RdbUtils.RDB_TAG, `updateWebDavAccountId error: ${(err as Error).message}`);
+        reject(err);
+      }
+    });
+  }
+
 }
 
 function generateBucket(item: VideoItem): relationalStore.ValuesBucket {

+ 3 - 0
entry/src/main/ets/common/util/RemoteDriveManager.ets

@@ -1162,6 +1162,9 @@ export class RemoteDriveManager {
   // 从WebDAV加载文件列表
   public async loadFilesInfoFromWebdav(customPath?: string): Promise<void> {
     const account = await this.getActiveWebDavAccount();
+    if(account){
+      console.info('heanup 2'+account.name+'type '+account.webType)
+    }
     if (!account) {
       Logger.error(TAG, '没有激活的WebDAV账户');
       this.notifyObservers(RemoteDriveManagerStates.LoadFilesInfoFailed);

+ 21 - 11
entry/src/main/ets/pages/NewIndex.ets

@@ -1952,7 +1952,12 @@ struct NewIndex {
   selectWebDavAccount(account: WebDavAccount) {
     try {
       LogUtil.info('heanup NewIndex', '选择网盘账户:', account.name)
-      this.logAccount('info', `选择网盘账户: ${account.name} (id=${account.id ?? 'unknown'})`)
+      this.logAccount('info', `选择网盘账户: ${account.name} (id=${account.id ?? 'unknown'}, webType=${account.webType})`)
+
+      // 关键修复:立即设置 selectedAccount,确保后续使用的是正确的账户
+      this.selectedAccount = account
+      console.info('heanup selectWebDavAccount account.webType='+account.webType)
+
       // 如果账户未激活,先激活它
       if (!account.isActivate) {
         // 先将所有账户设为未激活
@@ -1960,30 +1965,35 @@ struct NewIndex {
           acc.isActivate = false
         })
 
-        // 激活选中的账户
+        // 立即激活选中的账户(不等待数据库)
         account.isActivate = true
-        // 更新数据库中的激活状态
-        this.webdavManager.editAccount(account).then(() => {
-          LogUtil.info('heanup NewIndex', '网盘账户编辑成功:', account.name)
-          this.logAccount('info', `网盘账户编辑成功: ${account.name}`)
 
+        // 异步更新数据库中的激活状态(不阻塞UI)
+        this.webdavManager.editAccount(account).then(() => {
+          LogUtil.info('heanup NewIndex', '网盘账户激活成功:', account.name)
+          this.logAccount('info', `网盘账户激活成功: ${account.name}`)
         }).catch((error: Error) => {
           LogUtil.error('heanup NewIndex', `编辑网盘账户失败: ${error.message}`)
-          ToastUtil.showToast('编辑账户失败')
+          // 不显示Toast,避免干扰用户
           this.logAccount('error', `编辑网盘账户失败: ${error.message}`)
         })
       }
-      this.selectedAccount = account
-      console.info('onecold selectWebDavAccount account.webType='+account.webType)
-      // 切换到WebDAV页面
+
+      // 根据账户类型切换到对应页面
       if (account.webType === RemoteDriveType.Navidrome
         || account.webType === RemoteDriveType.Jellyfin
         || account.webType === RemoteDriveType.Emby) {
         this.mType = 7
-      }else{
+        LogUtil.info('heanup NewIndex', `切换到 Navidrome/Jellyfin/Emby 页面,webType=${account.webType}`)
+      } else {
         this.mType = 6
+        LogUtil.info('heanup NewIndex', `切换到 WebDAV 页面,webType=${account.webType}`)
       }
+
       this.doShowDrawer()
+
+      // 打印最终确认
+      LogUtil.info('heanup NewIndex', `选择完成: selectedAccount=${this.selectedAccount.name}, webType=${this.selectedAccount.webType}, mType=${this.mType}`)
     } catch (error) {
       LogUtil.error('heanup NewIndex', `选择网盘账户失败: ${(error as Error).message}`)
       ToastUtil.showToast('选择账户失败')

+ 4 - 2
entry/src/main/ets/pages/PlaylistDetailPage.ets

@@ -1695,7 +1695,8 @@ export function emptyView(themeColor: string, isDarkMode: boolean = false) {
         .fontColor([themeColor])
     }
     .margin({ bottom: 32 })
-
+    .width('100%')
+    .alignContent(Alignment.Center)
     // 空状态标题
     Text('歌曲还是空的')
       .fontSize(22)
@@ -1715,7 +1716,8 @@ export function emptyView(themeColor: string, isDarkMode: boolean = false) {
       .maxLines(2)
 
   }
-
+  .alignItems(HorizontalAlign.Center)
+  .width('100%')
 
 }
 

+ 10 - 13
entry/src/main/ets/pages/WebDavMainPage.ets

@@ -123,7 +123,7 @@ export struct WebDavMainPage {
   private readonly metadataUpdateEvent: emitter.InnerEvent = { eventId: EventConstants.EVENT_WEBDAV_METADATA_UPDATED };
 
   async onSwitchAccount(){
-    console.log('onecold 切换账户:', this.selectedAccount.name);
+    console.log('heanup 切换账户:', this.selectedAccount.name);
     this.songs = [];
     this.visibleFoldersState = [];
     this.updateListData(this.songs)
@@ -467,12 +467,8 @@ export struct WebDavMainPage {
       Logger.info(TAG, 'handleWebDavMetadataUpdates no changes detected');
       return;
     }
-    const clonedSongs: VideoItem[] = [];
-    for (let i = 0; i < this.songs.length; i++) {
-      clonedSongs.push(this.cloneSong(this.songs[i]));
-    }
-    this.songs = clonedSongs;
-    this.dataSource.pushArrayData(clonedSongs);
+    // 更新dataSource的数据,不滚动,只触发刷新
+    this.dataSource.pushArrayData(this.songs);
     this.listRefreshKey++;
     Logger.info(TAG, 'handleWebDavMetadataUpdates trigger refresh');
   }
@@ -580,7 +576,8 @@ export struct WebDavMainPage {
     }
 
     this.isLoading = true;
-    this.webdavManager.loadFilesInfoFromWebdav()
+    console.info('heanup '+this.selectedAccount.name+'type '+this.selectedAccount.webType)
+    this.webdavManager.loadFilesInfoFromAccount(this.selectedAccount)
       .catch((error: Error) => {
         Logger.error(TAG, '加载文件失败: ' + error.message);
         this.isLoading = false;
@@ -1338,8 +1335,8 @@ export struct WebDavMainPage {
             ListItem() {
               this.buildFolderItem(folder)
             }
-            .transition(TransitionEffect.asymmetric(TransitionEffect.scale({ x: 1.2, y: 1.2 }).animation({ duration: 600 }),
-              TransitionEffect.scale({ x: 0, y: 0 })))
+            // .transition(TransitionEffect.asymmetric(TransitionEffect.scale({ x: 1.2, y: 1.2 }).animation({ duration: 600 }),
+            //   TransitionEffect.scale({ x: 0, y: 0 })))
             .clickEffect({ level: ClickEffectLevel.MIDDLE })
           }, (folder: FileInfo) =>  folder.name+folder.fileName)
 
@@ -1348,10 +1345,10 @@ export struct WebDavMainPage {
             ListItem() {
               this.buildSongItem(song, index)
             }
-            .transition(TransitionEffect.asymmetric(TransitionEffect.scale({ x: 1.2, y: 1.2 }).animation({ duration: 600 }),
-              TransitionEffect.scale({ x: 0, y: 0 })))
+            // .transition(TransitionEffect.asymmetric(TransitionEffect.scale({ x: 1.2, y: 1.2 }).animation({ duration: 600 }),
+            //   TransitionEffect.scale({ x: 0, y: 0 })))
             .clickEffect({ level: ClickEffectLevel.MIDDLE })
-          }, (item: VideoItem) =>  item.filePath + '_' + this.listRefreshKey)
+          }, (item: VideoItem, index: number) =>  item.filePath + '_' + index+this.listRefreshKey)
         }
         .scrollBar(BarState.Off)
         .onScrollFrameBegin((offset: number) => {

+ 178 - 32
entry/src/main/ets/view/LocalMusic.ets

@@ -123,6 +123,7 @@ import { showCreatePlaylistDialog } from '../dialog/PlaylistDialog';
 import { convertPlaylistSongsToVideoItems, emptyView,updateAllSongsSortOrder } from '../pages/PlaylistDetailPage';
 import { Playlist, PlaylistSong } from '../viewmodel/Playlist';
 import { Song } from '../viewmodel/Song';
+import { WebDavAccount } from '../viewmodel/WebDavAccount';
 import { SongType } from '../common/enums/SongType';
 import { RemoteDriveManager, WebDavAuthInfo as WebDavManagerAuthInfo,
   buildHttpHeadersWithWebDav,
@@ -869,8 +870,64 @@ export struct LocalMusic {
     let eventSetting: emitter.InnerEvent = { eventId: EventConstants.EVENT_SETTING_UPDATE }
     // 监听广播事件(通用设置配置更新)
     emitter.on(eventSetting, (eventData: emitter.EventData) => {
-      this.doChangeSetting()
+      this.initSetting()
+    });
+
+    // 监听 WebDAV 元数据更新事件
+    let eventWebDavMetadata: emitter.InnerEvent = { eventId: EventConstants.EVENT_WEBDAV_METADATA_UPDATED }
+    emitter.on(eventWebDavMetadata, (eventData: emitter.EventData) => {
+      const payloads = eventData?.data as WebDavMetadataUpdatePayload[] | undefined;
+      if (!payloads || payloads.length === 0) {
+        Logger.info(TAG, 'LocalMusic: WebDav metadata event received but payload empty');
+        return;
+      }
+      Logger.info(TAG, `LocalMusic: WebDav metadata event payload count: ${payloads.length}`);
+
+      // 处理每个元数据更新
+      for (let i = 0; i < payloads.length; i++) {
+        const payload = payloads[i];
+        if (!payload || !payload.filePath) {
+          continue;
+        }
+
+        // 重要:只更新当前正在播放的歌曲
+        // 如果 filePath 不匹配,说明是其他歌曲的元数据更新,忽略不做处理
+        if (this.currentSong && this.currentSong.filePath === payload.filePath) {
+          Logger.info(TAG, `LocalMusic: 更新当前播放歌曲的元数据: ${payload.filePath}`);
+
+          if (payload.name && payload.name.length > 0) {
+            this.name = payload.name;
+            if (this.currentSong) {
+              this.currentSong.name = payload.name;
+            }
+          }
+
+          if (payload.artist && payload.artist.length > 0) {
+            this.artist = payload.artist;
+            if (this.currentSong) {
+              this.currentSong.artist = payload.artist;
+            }
+          }
+
+          if (payload.pixelMapPath && payload.pixelMapPath.length > 0) {
+            this.cover = payload.pixelMapPath;
+            if (this.currentSong) {
+              this.currentSong.pixelMapPath = payload.pixelMapPath;
+            }
+            Logger.info(TAG, `LocalMusic: 封面已更新: ${payload.pixelMapPath}`);
+          }
 
+          // 同步更新 AppStorage
+          AppStorage.setOrCreate('currentSong', this.currentSong);
+        } else {
+          Logger.info(TAG, `LocalMusic: 跳过非当前播放歌曲的元数据更新: ${payload.filePath}, 当前: ${this.currentSong?.filePath}`);
+        }
+      }
+    });
+
+    // 监听广播事件(通用设置配置更新)
+    emitter.on(eventSetting, (eventData: emitter.EventData) => {
+      this.doChangeSetting()
     });
 
     let event: Callback<InterruptEvent> = (event) => {
@@ -1787,6 +1844,7 @@ export struct LocalMusic {
     emitter.off(EventConstants.EVENT_SCAN_UPDATE);
     emitter.off(EventConstants.EVENT_SWIPE_BACK_UPDATE);
     emitter.off(EventConstants.EVENT_SETTING_UPDATE);
+    emitter.off(EventConstants.EVENT_WEBDAV_METADATA_UPDATED);
     this.mDestroyPage = true;
     this.mIjkMediaPlayer.setScreenOnWhilePlaying(false);
     if (this.CONTROL_PlayStatus != PlayStatus.INIT) {
@@ -3030,9 +3088,11 @@ export struct LocalMusic {
                 Column() {
                   emptyView(this.themeColor)
                 }
+                .padding({ right:25 })
                 .onClick(()=>{
                   this.asyncCurrentPathOnlyFile()
                 })
+                .alignItems(HorizontalAlign.Center)
                 .position({ top: 200 })
                 .justifyContent(FlexAlign.Center)
                 .opacity(this.isZero ? 1 : 0)
@@ -15064,6 +15124,8 @@ export struct LocalMusic {
   private playedIndices: Set<number> = new Set();
   // 存储已播放的本地歌曲路径(随机播放去重用)
   private playedLocalFilePaths: Set<string> = new Set();
+  // 随机播放模式下的播放历史栈(记录实际播放顺序,用于"上一首"功能)
+  private randomPlayHistory: VideoItem[] = [];
 
   //随机播放
   private async randomPlay() {
@@ -15071,6 +15133,14 @@ export struct LocalMusic {
     //   return;
     // }
     if (this.currentSong) {
+      // 将当前歌加入到随机播放历史栈(在切换到新歌之前)
+      this.randomPlayHistory.unshift(this.currentSong);
+      // 限制历史栈大小,避免无限增长
+      if (this.randomPlayHistory.length > 50) {
+        this.randomPlayHistory = this.randomPlayHistory.slice(0, 50);
+      }
+      Logger.info(TAG, `randomPlay: 将当前歌加入历史栈, 栈大小: ${this.randomPlayHistory.length}`);
+
       const isCurrentRemote = isRemoteCloudType(this.currentSong.type);
       const currentFilePath = this.currentSong.filePath;
       if (isCurrentRemote) {
@@ -15080,6 +15150,33 @@ export struct LocalMusic {
         };
         const randomRemoteSong = await this.table.queryRandomSong(remoteOptions);
         if (randomRemoteSong) {
+          // 验证并修正webdav_account_id
+          if (randomRemoteSong.webdav_account_id) {
+            const manager = RemoteDriveManager.getInstance();
+            const account = await manager.getWebDavAccountById(randomRemoteSong.webdav_account_id);
+            if (!account) {
+              Logger.warn(TAG, `随机播放的歌曲账号ID无效: ${randomRemoteSong.webdav_account_id}, 尝试查找同类型账号`);
+              // 获取所有账号,查找相同类型的账号
+              const allAccounts = manager.getAllWebDavAccounts();
+              let foundAccount: WebDavAccount | null = null;
+              for (let i = 0; i < allAccounts.length; i++) {
+                if (allAccounts[i].webType === randomRemoteSong.type) {
+                  foundAccount = allAccounts[i];
+                  break;
+                }
+              }
+              if (foundAccount && foundAccount.id) {
+                Logger.info(TAG, `找到同类型账号,更新webdav_account_id: ${randomRemoteSong.webdav_account_id} -> ${foundAccount.id}`);
+                randomRemoteSong.webdav_account_id = foundAccount.id.toString();
+                // 更新数据库记录
+                await this.table.updateWebDavAccountId(randomRemoteSong.filePath, foundAccount.id.toString());
+              } else {
+                Logger.error(TAG, `无法找到类型为${randomRemoteSong.type}的账号,跳过此歌曲`);
+                return;
+              }
+            }
+          }
+
           let nextIndex = this.songList.findIndex(song => song.filePath === randomRemoteSong.filePath);
           if (nextIndex < 0) {
             this.songList = [...this.songList, randomRemoteSong];
@@ -15269,6 +15366,39 @@ export struct LocalMusic {
     this.currentSong = this.songList[this.curIndex];
     Logger.info('heanup playPrevious', `直接使用歌曲列表中的信息: ${this.currentSong.name}, type: ${this.currentSong.type}`);
 
+    // 验证并修正webdav_account_id(针对远程类型歌曲)
+    if (isRemoteCloudType(this.currentSong.type) && this.currentSong.webdav_account_id) {
+      const manager = RemoteDriveManager.getInstance();
+      const account = await manager.getWebDavAccountById(this.currentSong.webdav_account_id);
+      if (!account) {
+        Logger.warn(TAG, `playPrevious: 歌曲账号ID无效: ${this.currentSong.webdav_account_id}, 尝试查找同类型账号`);
+        // 获取所有账号,查找相同类型的账号
+        const allAccounts = manager.getAllWebDavAccounts();
+        let foundAccount: WebDavAccount | null = null;
+        for (let i = 0; i < allAccounts.length; i++) {
+          if (allAccounts[i].webType === this.currentSong.type) {
+            foundAccount = allAccounts[i];
+            break;
+          }
+        }
+        if (foundAccount && foundAccount.id) {
+          Logger.info(TAG, `playPrevious: 找到同类型账号,更新webdav_account_id: ${this.currentSong.webdav_account_id} -> ${foundAccount.id}`);
+          this.currentSong.webdav_account_id = foundAccount.id.toString();
+          // 更新数据库记录
+          await this.table.updateWebDavAccountId(this.currentSong.filePath, foundAccount.id.toString());
+        } else {
+          Logger.error(TAG, `playPrevious: 无法找到类型为${this.currentSong.type}的账号,跳过此歌曲`);
+          // 跳过无效账号的歌曲,继续查找上一首
+          if (this.curIndex == 0) {
+            this.curIndex = this.songList.length - 1;
+          } else {
+            this.curIndex--;
+          }
+          this.currentSong = this.songList[this.curIndex];
+        }
+      }
+    }
+
     // 设置videoUrl,WebDAV歌曲会通过webdav_account_id构建完整URL
     this.videoUrl = await setVideoUrlForSong(this.currentSong, {
       context: this.context,
@@ -15306,51 +15436,67 @@ export struct LocalMusic {
     this.changeImageAnimation()
   }
 
-  //随机播放模式下点击上一首: 上一首应该应该播放历史记录的第二
+  //随机播放模式下点击上一首: 播放刚刚播放过的那一
   private async randomModePlayFromHistory() {
-    if (this.historyList.length >= 2) {
-      // 播放历史记录的第二首
-      const prevSong = this.historyList[1];
+    if (this.randomPlayHistory.length >= 1) {
+      // 播放历史栈的第一首(刚刚播放过的)
+      const prevSong = this.randomPlayHistory[0];
+      Logger.info('heanup randomModePlayFromHistory', `从随机播放历史栈获取歌曲: ${prevSong.name}, type: ${prevSong.type}, 栈大小: ${this.randomPlayHistory.length}`);
+
+      // 从栈中移除这首歌(因为即将播放它,它应该成为当前歌,而不是历史)
+      this.randomPlayHistory.shift();
+
       this.curIndex = this.songList.findIndex(song => song.filePath === prevSong.filePath);
       this.CONTROL_PlayStatus = PlayStatus.INIT;
       this.stop();
 
-      // 直接使用历史记录中的歌曲信息,历史记录中的数据应该是完整的
+      // 验证并修正webdav_account_id(针对远程类型歌曲)
+      if (isRemoteCloudType(prevSong.type) && prevSong.webdav_account_id) {
+        const manager = RemoteDriveManager.getInstance();
+        const account = await manager.getWebDavAccountById(prevSong.webdav_account_id);
+        if (!account) {
+          Logger.warn(TAG, `randomModePlayFromHistory: 歌曲账号ID无效: ${prevSong.webdav_account_id}, 尝试查找同类型账号`);
+          const allAccounts = manager.getAllWebDavAccounts();
+          let foundAccount: WebDavAccount | null = null;
+          for (let i = 0; i < allAccounts.length; i++) {
+            if (allAccounts[i].webType === prevSong.type) {
+              foundAccount = allAccounts[i];
+              break;
+            }
+          }
+          if (foundAccount && foundAccount.id) {
+            Logger.info(TAG, `randomModePlayFromHistory: 找到同类型账号,更新webdav_account_id: ${prevSong.webdav_account_id} -> ${foundAccount.id}`);
+            prevSong.webdav_account_id = foundAccount.id.toString();
+            await this.table.updateWebDavAccountId(prevSong.filePath, foundAccount.id.toString());
+          } else {
+            Logger.error(TAG, `randomModePlayFromHistory: 无法找到类型为${prevSong.type}的账号`);
+            // 无法播放这首歌,继续尝试下一首历史记录
+            if (this.randomPlayHistory.length >= 1) {
+              this.randomModePlayFromHistory();
+              return;
+            } else {
+              // 历史记录为空,无法继续
+              ToastUtil.showToast('没有更多历史记录');
+              return;
+            }
+          }
+        }
+      }
+
       this.currentSong = prevSong;
-      Logger.info('heanup randomModePlayFromHistory', `直接使用历史歌曲信息: ${prevSong.name}, type: ${prevSong.type}`);
 
       // 设置videoUrl,WebDAV歌曲会通过webdav_account_id构建完整URL
       this.videoUrl = await setVideoUrlForSong(this.currentSong, {
         context: this.context,
         autoParseMusicName: this.autoParseMusicName
       });
-      this.cover = prevSong.pixelMapPath
-      this.artist = prevSong.artist
-      this.name = prevSong.name;
-      console.info('onecold startPlayOrResumePlay 11434')
+      this.cover = this.currentSong.pixelMapPath
+      this.artist = this.currentSong.artist
+      this.name = this.currentSong.name;
+      console.info('onecold startPlayOrResumePlay randomModePlayFromHistory')
       this.startPlayOrResumePlay();
     } else {
-      // 如果历史记录不足两首,可根据需求处理,这里简单按普通逻辑处理
-      if (this.curIndex === 0) {
-        this.curIndex = this.songList.length - 1;
-      } else {
-        this.curIndex--;
-      }
-      this.CONTROL_PlayStatus = PlayStatus.INIT;
-      this.stop();
-
-      // 直接使用歌曲列表中的歌曲信息,songList中的数据已经是完整的
-      this.currentSong = this.songList[this.curIndex];
-      Logger.info('heanup randomModePlayFromHistory', `直接使用歌曲列表中的信息: ${this.currentSong.name}, type: ${this.currentSong.type}`);
-
-      // 设置videoUrl,WebDAV歌曲会通过webdav_account_id构建完整URL
-      this.videoUrl = await setVideoUrlForSong(this.currentSong, {
-        context: this.context,
-        autoParseMusicName: this.autoParseMusicName
-      });
-      this.artist = this.songList[this.curIndex].artist
-      this.name = this.songList[this.curIndex].name;
-      this.changeImageAnimation()
+      ToastUtil.showToast('随机播放模式暂无历史记录');
     }
   }