|
@@ -1,18 +1,16 @@
|
|
|
import TitleBar from './TitleBar'
|
|
import TitleBar from './TitleBar'
|
|
|
import { curves, display, PiPWindow, promptAction, router, SymbolGlyphModifier, window } from '@kit.ArkUI';
|
|
import { curves, display, PiPWindow, promptAction, router, SymbolGlyphModifier, window } from '@kit.ArkUI';
|
|
|
import { VideoItem } from '../viewmodel/VideoItem';
|
|
import { VideoItem } from '../viewmodel/VideoItem';
|
|
|
-import { LengthMetrics, SegmentButton,borderRadiuses, SegmentButtonOptions } from '@kit.ArkUI';
|
|
|
|
|
-import { getWebdavVideoItems, getWebdavCurrentPlayIndex, clearWebdavVideoItems } from '../pages/WebDavMainPage';
|
|
|
|
|
|
|
+import { LengthMetrics, SegmentButton,SegmentButtonOptions } from '@kit.ArkUI';
|
|
|
|
|
+import { getWebdavVideoItems, getWebdavCurrentPlayIndex } from '../pages/WebDavMainPage';
|
|
|
import {
|
|
import {
|
|
|
AppUtil,
|
|
AppUtil,
|
|
|
ArrayUtil,
|
|
ArrayUtil,
|
|
|
Base64Util,
|
|
Base64Util,
|
|
|
DateUtil,
|
|
DateUtil,
|
|
|
DeviceUtil,
|
|
DeviceUtil,
|
|
|
- DisplayUtil,
|
|
|
|
|
FileUtil,
|
|
FileUtil,
|
|
|
GlobalContext,
|
|
GlobalContext,
|
|
|
- ImageUtil,
|
|
|
|
|
LogUtil,
|
|
LogUtil,
|
|
|
MD5,
|
|
MD5,
|
|
|
PreferencesUtil,
|
|
PreferencesUtil,
|
|
@@ -33,7 +31,6 @@ import { common, ConfigurationConstant } from '@kit.AbilityKit';
|
|
|
import { AnimationHelper, DialogAction, DialogHelper } from '@pura/harmony-dialog';
|
|
import { AnimationHelper, DialogAction, DialogHelper } from '@pura/harmony-dialog';
|
|
|
import { fileIo, fileUri, picker } from '@kit.CoreFileKit';
|
|
import { fileIo, fileUri, picker } from '@kit.CoreFileKit';
|
|
|
import { MessageEvents, util, worker, ErrorEvent } from '@kit.ArkTS';
|
|
import { MessageEvents, util, worker, ErrorEvent } from '@kit.ArkTS';
|
|
|
-import Base64 from '@ohos.util';
|
|
|
|
|
import { Verify } from './Verify';
|
|
import { Verify } from './Verify';
|
|
|
import { taskpool } from '@kit.ArkTS';
|
|
import { taskpool } from '@kit.ArkTS';
|
|
|
import { RotatingCover } from './RotatingCover';
|
|
import { RotatingCover } from './RotatingCover';
|
|
@@ -45,7 +42,6 @@ import { AvSessionController } from '../controller/AvSessionController';
|
|
|
import { repairAudioMetadata, convertDsfToWav, getApiLyric,changeMusicCover} from '../common/util/MusicTagUtils';
|
|
import { repairAudioMetadata, convertDsfToWav, getApiLyric,changeMusicCover} from '../common/util/MusicTagUtils';
|
|
|
import { FFMpegTags,Utility } from '../common/util/Utility';
|
|
import { FFMpegTags,Utility } from '../common/util/Utility';
|
|
|
import { TagsContentCover } from '../view/TagsContentCover';
|
|
import { TagsContentCover } from '../view/TagsContentCover';
|
|
|
-import { ImageFancyModifier } from '../common/util/AttributeModifierUtil'
|
|
|
|
|
import {
|
|
import {
|
|
|
// DeviceChangeReason,
|
|
// DeviceChangeReason,
|
|
|
IjkMediaPlayer,
|
|
IjkMediaPlayer,
|
|
@@ -71,7 +67,7 @@ import { secondToTime,getTransverterText } from '../common/util/CommUtils';
|
|
|
import { CommonConstants2 } from '../common/util/CommonConstants2';
|
|
import { CommonConstants2 } from '../common/util/CommonConstants2';
|
|
|
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
|
import { LazyDataSource } from '../common/util/LazyDataSource';
|
|
import { LazyDataSource } from '../common/util/LazyDataSource';
|
|
|
-import MediaTable from '../common/util/MediaTable';
|
|
|
|
|
|
|
+import MediaTable from '../common/util/MediaTable';
|
|
|
import NetAxiosUtil from '../common/util/NetAxiosUtil';
|
|
import NetAxiosUtil from '../common/util/NetAxiosUtil';
|
|
|
import ImageUtils from '../common/util/ImageUtils';
|
|
import ImageUtils from '../common/util/ImageUtils';
|
|
|
import { ringtone } from '@kit.RingtoneKit';
|
|
import { ringtone } from '@kit.RingtoneKit';
|
|
@@ -95,11 +91,8 @@ import { showAddToPlaylistDialog } from '../dialog/AddToPlaylistDialog';
|
|
|
import { showCreatePlaylistDialog } from '../dialog/PlaylistDialog';
|
|
import { showCreatePlaylistDialog } from '../dialog/PlaylistDialog';
|
|
|
import { convertPlaylistSongsToVideoItems, emptyView } from '../pages/PlaylistDetailPage';
|
|
import { convertPlaylistSongsToVideoItems, emptyView } from '../pages/PlaylistDetailPage';
|
|
|
import { Playlist, PlaylistSong } from '../viewmodel/Playlist';
|
|
import { Playlist, PlaylistSong } from '../viewmodel/Playlist';
|
|
|
-import { Song } from '../viewmodel/Song';
|
|
|
|
|
-import { SongType } from '../common/enums/SongType';
|
|
|
|
|
-import { WebdavManager, WebDavAuthInfo as WebDavManagerAuthInfo,
|
|
|
|
|
- buildHttpHeadersWithWebDav,
|
|
|
|
|
- WebDavAuthItem} from '../common/util/WebdavManager';
|
|
|
|
|
|
|
+import { WebdavManager, WebDavAuthItem} from '../common/util/WebdavManager';
|
|
|
|
|
+import { WebDavUrlUtil } from '../common/util/WebDavUrlUtil';
|
|
|
const TAG = 'LocalMusic';
|
|
const TAG = 'LocalMusic';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -134,6 +127,43 @@ function getTypeOrder(type: number) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 异步设置videoUrl的辅助方法,处理WebDAV URL的构建
|
|
|
|
|
+ * @param song 歌曲对象
|
|
|
|
|
+ * @returns Promise<string> 完整的URL
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 设置videoUrl,通过webdav_account_id设置完整的 URL
|
|
|
|
|
+ * @param song 歌曲对象
|
|
|
|
|
+ * @returns Promise<string> 完整的URL
|
|
|
|
|
+ */
|
|
|
|
|
+async function setVideoUrlForSong(song: VideoItem): Promise<string> {
|
|
|
|
|
+ if (song.type === CommonConstants.TYPE_WEBDAV && song.webdav_account_id) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const fullUrl = await WebDavUrlUtil.buildFullUrlByAccountId(song.webdav_account_id, song.filePath);
|
|
|
|
|
+ if (fullUrl) {
|
|
|
|
|
+ Logger.info(TAG, `WebDAV完整URL构建成功: ${fullUrl}`);
|
|
|
|
|
+ return fullUrl.replace(/ /g, '%20');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Logger.error(TAG, `WebDAV URL构建失败,使用原始路径: ${song.filePath}`);
|
|
|
|
|
+ return song.filePath.replace(/ /g, '%20');
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ Logger.error(TAG, `WebDAV URL构建出错: ${(error as Error).message}`);
|
|
|
|
|
+ return song.filePath.replace(/ /g, '%20');
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 非WebDAV文件或缺少webdav_account_id,直接使用原始路径
|
|
|
|
|
+ if (song.type === CommonConstants.TYPE_WEBDAV) {
|
|
|
|
|
+ Logger.warn(TAG, `WebDAV歌曲缺少webdav_account_id,使用原始路径: ${song.filePath}`);
|
|
|
|
|
+ }
|
|
|
|
|
+ return song.type === CommonConstants.TYPE_WEBDAV ?
|
|
|
|
|
+ song.filePath.replace(/ /g, '%20') :
|
|
|
|
|
+ song.filePath;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const workerInstance = new worker.ThreadWorker("entry/ets/workers/Worker.ets");
|
|
const workerInstance = new worker.ThreadWorker("entry/ets/workers/Worker.ets");
|
|
|
// 定义接口
|
|
// 定义接口
|
|
|
interface HiCarAspectRatio {
|
|
interface HiCarAspectRatio {
|
|
@@ -1095,7 +1125,7 @@ export struct LocalMusic {
|
|
|
FileUtil.mkdirSync(this.historyPath)
|
|
FileUtil.mkdirSync(this.historyPath)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this.getSortedFiles(this.rootPath).then(() => {
|
|
|
|
|
|
|
+ this.getSortedFiles(this.rootPath).then(async () => {
|
|
|
this.isFavMusic = false
|
|
this.isFavMusic = false
|
|
|
//穿山甲
|
|
//穿山甲
|
|
|
// this.loadBannerAd(CSJUtil.getBannerID())
|
|
// this.loadBannerAd(CSJUtil.getBannerID())
|
|
@@ -1114,11 +1144,9 @@ export struct LocalMusic {
|
|
|
this.isFirstStartPlay = false
|
|
this.isFirstStartPlay = false
|
|
|
this.currentSong = this.songList[0]
|
|
this.currentSong = this.songList[0]
|
|
|
}
|
|
}
|
|
|
- if(this.currentSong.type==CommonConstants.TYPE_WEBDAV){
|
|
|
|
|
- this.videoUrl = this.currentSong.filePath.replace(/ /g, '%20');
|
|
|
|
|
- }else{
|
|
|
|
|
- this.videoUrl = this.currentSong.filePath
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 使用辅助方法设置videoUrl,等待WebDAV URL构建完成
|
|
|
|
|
+ this.videoUrl = await setVideoUrlForSong(this.currentSong);
|
|
|
|
|
+ Logger.info(TAG, `WebDAV URL同步构建完成: ${this.videoUrl}`);
|
|
|
this.name = this.currentSong.name
|
|
this.name = this.currentSong.name
|
|
|
this.cover = this.currentSong.pixelMapPath
|
|
this.cover = this.currentSong.pixelMapPath
|
|
|
AppStorage.setOrCreate('currentSong',this.currentSong) ;
|
|
AppStorage.setOrCreate('currentSong',this.currentSong) ;
|
|
@@ -5548,13 +5576,16 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
AppStorage.setOrCreate('currentSong', this.currentSong);
|
|
AppStorage.setOrCreate('currentSong', this.currentSong);
|
|
|
- // 对WebDAV URL进行编码处理,确保空格等特殊字符被正确编码
|
|
|
|
|
- this.videoUrl = this.currentSong.filePath.replace(/ /g, '%20');
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 使用辅助方法设置videoUrl,等待WebDAV URL构建完成
|
|
|
|
|
+ this.videoUrl = await setVideoUrlForSong(this.currentSong);
|
|
|
|
|
+ Logger.info(TAG, `WebDAV URL同步构建完成(分支2): ${this.videoUrl}`);
|
|
|
|
|
+
|
|
|
this.name = this.currentSong.name
|
|
this.name = this.currentSong.name
|
|
|
this.cover = this.currentSong.pixelMapPath
|
|
this.cover = this.currentSong.pixelMapPath
|
|
|
this.artist = this.currentSong.artist
|
|
this.artist = this.currentSong.artist
|
|
|
|
|
|
|
|
- Logger.info(`heanup 准备播放网络音频 - 歌名: ${this.name}, 艺术家: ${this.artist}, 编码后URL: ${this.videoUrl}`)
|
|
|
|
|
|
|
+ Logger.info(`heanup 准备播放网络音频 - 歌名: ${this.name}, 艺术家: ${this.artist}, 完整URL: ${this.videoUrl}`)
|
|
|
|
|
|
|
|
this.startPlayOrResumePlay()
|
|
this.startPlayOrResumePlay()
|
|
|
break;
|
|
break;
|
|
@@ -12074,7 +12105,7 @@ export struct LocalMusic {
|
|
|
onError: (what: number, extra: number) => {
|
|
onError: (what: number, extra: number) => {
|
|
|
this.stopProgressTask();
|
|
this.stopProgressTask();
|
|
|
LogUtils.getInstance().LOGI("OnErrorListener-->go:" + what + "===" + extra + " this.videoUrl=" + this.videoUrl)
|
|
LogUtils.getInstance().LOGI("OnErrorListener-->go:" + what + "===" + extra + " this.videoUrl=" + this.videoUrl)
|
|
|
-
|
|
|
|
|
|
|
+ LogUtils.getInstance().LOGI('heanup 播放错误,歌曲详情:' + JSON.stringify(this.currentSong))
|
|
|
// 检查是否为WebDAV播放错误
|
|
// 检查是否为WebDAV播放错误
|
|
|
let isWebDavError = false;
|
|
let isWebDavError = false;
|
|
|
if (this.currentSong && this.currentSong.type === CommonConstants.TYPE_WEBDAV && this.currentSong.filePath) {
|
|
if (this.currentSong && this.currentSong.type === CommonConstants.TYPE_WEBDAV && this.currentSong.filePath) {
|
|
@@ -13404,27 +13435,27 @@ export struct LocalMusic {
|
|
|
for (let i = 0; i < songFilePaths.length; i++) {
|
|
for (let i = 0; i < songFilePaths.length; i++) {
|
|
|
const filePath = songFilePaths[i]
|
|
const filePath = songFilePaths[i]
|
|
|
const index = i
|
|
const index = i
|
|
|
- Logger.info(`heanup 正在查询歌曲[${index}]: ${filePath}`)
|
|
|
|
|
|
|
+ // Logger.info(`heanup 正在查询歌曲[${index}]: ${filePath}`)
|
|
|
|
|
|
|
|
// 使用已初始化的MediaTable实例从数据库查询歌曲信息
|
|
// 使用已初始化的MediaTable实例从数据库查询歌曲信息
|
|
|
const queryPromise = this.table.queryVideoByFilePath(filePath)
|
|
const queryPromise = this.table.queryVideoByFilePath(filePath)
|
|
|
- Logger.info(`heanup 创建了查询Promise,开始等待结果[${index}]: ${filePath}`)
|
|
|
|
|
|
|
+ // Logger.info(`heanup 创建了查询Promise,开始等待结果[${index}]: ${filePath}`)
|
|
|
|
|
|
|
|
queryPromise.then((videoItem) => {
|
|
queryPromise.then((videoItem) => {
|
|
|
completedQueries++
|
|
completedQueries++
|
|
|
- Logger.info(`heanup 查询Promise返回结果[${index}]: ${filePath}, 找到歌曲: ${videoItem ? videoItem.name : 'null'}`)
|
|
|
|
|
|
|
+ // Logger.info(`heanup 查询Promise返回结果[${index}]: ${filePath}, 找到歌曲: ${videoItem ? videoItem.name : 'null'}`)
|
|
|
|
|
|
|
|
if (videoItem) {
|
|
if (videoItem) {
|
|
|
// 使用索引作为key保存到Map中,保持原始顺序
|
|
// 使用索引作为key保存到Map中,保持原始顺序
|
|
|
songMap.set(index, videoItem)
|
|
songMap.set(index, videoItem)
|
|
|
- Logger.info(`heanup 从数据库找到歌曲[${index}]: ${videoItem.name} (${completedQueries}/${songFilePaths.length})`)
|
|
|
|
|
|
|
+ // Logger.info(`heanup 从数据库找到歌曲[${index}]: ${videoItem.name} (${completedQueries}/${songFilePaths.length})`)
|
|
|
} else {
|
|
} else {
|
|
|
Logger.warn(`heanup 数据库中未找到歌曲[${index}]: ${filePath} (${completedQueries}/${songFilePaths.length})`)
|
|
Logger.warn(`heanup 数据库中未找到歌曲[${index}]: ${filePath} (${completedQueries}/${songFilePaths.length})`)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 检查是否所有歌曲都已加载完成
|
|
// 检查是否所有歌曲都已加载完成
|
|
|
if (completedQueries === songFilePaths.length) {
|
|
if (completedQueries === songFilePaths.length) {
|
|
|
- Logger.info(`heanup 所有数据库查询完成,共找到 ${songMap.size} 首歌曲`)
|
|
|
|
|
|
|
+ // Logger.info(`heanup 所有数据库查询完成,共找到 ${songMap.size} 首歌曲`)
|
|
|
|
|
|
|
|
// 按照索引顺序重建歌曲数组
|
|
// 按照索引顺序重建歌曲数组
|
|
|
const songs: VideoItem[] = []
|
|
const songs: VideoItem[] = []
|
|
@@ -13432,7 +13463,7 @@ export struct LocalMusic {
|
|
|
const song = songMap.get(j)
|
|
const song = songMap.get(j)
|
|
|
if (song) {
|
|
if (song) {
|
|
|
songs.push(song)
|
|
songs.push(song)
|
|
|
- Logger.info(`heanup 按顺序添加歌曲[${j}]: ${song.name}`)
|
|
|
|
|
|
|
+ // Logger.info(`heanup 按顺序添加歌曲[${j}]: ${song.name}`)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|