|
@@ -8935,7 +8935,7 @@ export struct LocalMusic {
|
|
|
.aspectRatio(CommonConstants.ASPECT_RATIO)
|
|
.aspectRatio(CommonConstants.ASPECT_RATIO)
|
|
|
}
|
|
}
|
|
|
.onClick(async () => {
|
|
.onClick(async () => {
|
|
|
- this.playPrevious()
|
|
|
|
|
|
|
+ await this.playPrevious()
|
|
|
})
|
|
})
|
|
|
.clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
|
|
.clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
|
|
|
.backgroundColor(Color.Transparent)
|
|
.backgroundColor(Color.Transparent)
|
|
@@ -8971,9 +8971,9 @@ export struct LocalMusic {
|
|
|
.width(33)
|
|
.width(33)
|
|
|
.clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
|
|
.clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
|
|
|
.aspectRatio(CommonConstants.ASPECT_RATIO)
|
|
.aspectRatio(CommonConstants.ASPECT_RATIO)
|
|
|
- .onClick(() => {
|
|
|
|
|
|
|
+ .onClick(async () => {
|
|
|
|
|
|
|
|
- this.playNext();
|
|
|
|
|
|
|
+ await this.playNext();
|
|
|
|
|
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -11279,15 +11279,21 @@ export struct LocalMusic {
|
|
|
break;
|
|
break;
|
|
|
case 'nextVideo':
|
|
case 'nextVideo':
|
|
|
// 切换到下一个视频
|
|
// 切换到下一个视频
|
|
|
- this.playNext()
|
|
|
|
|
|
|
+ this.playNext().catch(() => {
|
|
|
|
|
+ Logger.error('heanup onActionEvent playNext', `播放下一首失败`);
|
|
|
|
|
+ });
|
|
|
break;
|
|
break;
|
|
|
case 'previousVideo':
|
|
case 'previousVideo':
|
|
|
// 切换到上一个视频
|
|
// 切换到上一个视频
|
|
|
- this.playPrevious()
|
|
|
|
|
|
|
+ this.playPrevious().catch(() => {
|
|
|
|
|
+ Logger.error('heanup onActionEvent playPrevious', `播放上一首失败`);
|
|
|
|
|
+ });
|
|
|
break;
|
|
break;
|
|
|
case 'previousVideo':
|
|
case 'previousVideo':
|
|
|
// 切换到上一个视频
|
|
// 切换到上一个视频
|
|
|
- this.playPrevious()
|
|
|
|
|
|
|
+ this.playPrevious().catch(() => {
|
|
|
|
|
+ Logger.error('heanup onActionEvent playPrevious', `播放上一首失败:`);
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
@@ -11760,7 +11766,9 @@ export struct LocalMusic {
|
|
|
this.stop();
|
|
this.stop();
|
|
|
// ToastUtil.showToast('开始重新播放')
|
|
// ToastUtil.showToast('开始重新播放')
|
|
|
}else{
|
|
}else{
|
|
|
- this.playNext()
|
|
|
|
|
|
|
+ this.playNext().catch(() => {
|
|
|
|
|
+ Logger.error('heanup setProgress playNext', `播放下一首失败`);
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -12117,7 +12125,10 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
LogUtils.getInstance().LOGI("OnCompletionListener-->go")
|
|
LogUtils.getInstance().LOGI("OnCompletionListener-->go")
|
|
|
if (this.playType == 0) { //0:连续播放 1:单片重复播放 2:正常播放
|
|
if (this.playType == 0) { //0:连续播放 1:单片重复播放 2:正常播放
|
|
|
- this.playNext()
|
|
|
|
|
|
|
+ // 异步调用playNext
|
|
|
|
|
+ this.playNext().catch(() => {
|
|
|
|
|
+ Logger.error('heanup OnCompletionListener playNext', `播放下一首失败`);
|
|
|
|
|
+ });
|
|
|
} else if (this.playType == 1) { //1:单片重复播放
|
|
} else if (this.playType == 1) { //1:单片重复播放
|
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT
|
|
|
console.info('onecold startPlayOrResumePlay 10592')
|
|
console.info('onecold startPlayOrResumePlay 10592')
|
|
@@ -12190,7 +12201,7 @@ export struct LocalMusic {
|
|
|
let mOnErrorListener: OnErrorListener = {
|
|
let mOnErrorListener: OnErrorListener = {
|
|
|
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("heanup OnErrorListener-->go:" + what + "===" + extra + " this.videoUrl=" + this.videoUrl)
|
|
|
LogUtils.getInstance().LOGI('heanup 播放错误,歌曲详情:' + JSON.stringify(this.currentSong))
|
|
LogUtils.getInstance().LOGI('heanup 播放错误,歌曲详情:' + JSON.stringify(this.currentSong))
|
|
|
// 检查是否为WebDAV播放错误
|
|
// 检查是否为WebDAV播放错误
|
|
|
let isWebDavError = false;
|
|
let isWebDavError = false;
|
|
@@ -12573,10 +12584,14 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
};
|
|
};
|
|
|
public playNextCallback = (): void => {
|
|
public playNextCallback = (): void => {
|
|
|
- this.playNext()
|
|
|
|
|
|
|
+ this.playNext().catch(() => {
|
|
|
|
|
+ Logger.error('heanup playNextCallback', `播放下一首失败`);
|
|
|
|
|
+ });
|
|
|
};
|
|
};
|
|
|
public playPreviousCallback = (): void => {
|
|
public playPreviousCallback = (): void => {
|
|
|
- this.playPrevious()
|
|
|
|
|
|
|
+ this.playPrevious().catch(() => {
|
|
|
|
|
+ Logger.error('heanup playNextCallback', `播放上一首失败`);
|
|
|
|
|
+ });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
async prepare() {
|
|
async prepare() {
|
|
@@ -12656,10 +12671,14 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private sessionPlayNextCallback = (): void => {
|
|
private sessionPlayNextCallback = (): void => {
|
|
|
- this.playNext()
|
|
|
|
|
|
|
+ this.playNext().catch(() => {
|
|
|
|
|
+ Logger.error('heanup sessionPlayPreviousCallback', `播放下 一首失败`);
|
|
|
|
|
+ });
|
|
|
};
|
|
};
|
|
|
private sessionPlayPreviousCallback = (): void => {
|
|
private sessionPlayPreviousCallback = (): void => {
|
|
|
- this.playPrevious()
|
|
|
|
|
|
|
+ this.playPrevious().catch(() => {
|
|
|
|
|
+ Logger.error('heanup sessionPlayPreviousCallback', `播放上一首失败`);
|
|
|
|
|
+ });
|
|
|
};
|
|
};
|
|
|
private sessionStopCallback = (): void => {
|
|
private sessionStopCallback = (): void => {
|
|
|
this.stop()
|
|
this.stop()
|
|
@@ -12863,7 +12882,7 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//下一个
|
|
//下一个
|
|
|
- private playNext() {
|
|
|
|
|
|
|
+ private async playNext() {
|
|
|
if (!this.debounce()) {
|
|
if (!this.debounce()) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -12880,9 +12899,34 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT;
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT;
|
|
|
this.stop();
|
|
this.stop();
|
|
|
- this.currentSong = this.songList[this.curIndex]
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 参考歌单详情页的方式,从数据库重新查询完整的歌曲信息
|
|
|
|
|
+ const songFilePath = this.songList[this.curIndex].filePath;
|
|
|
|
|
+ const freshSong = await this.table.queryVideoByFilePath(songFilePath);
|
|
|
|
|
+
|
|
|
|
|
+ if (freshSong) {
|
|
|
|
|
+ this.currentSong = freshSong;
|
|
|
|
|
+ Logger.info('heanup playNext', `重新查询歌曲信息: ${freshSong.name}, type: ${freshSong.type}`);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 如果查询失败,使用原有的对象
|
|
|
|
|
+ this.currentSong = this.songList[this.curIndex];
|
|
|
|
|
+ Logger.warn('heanup playNext', `重新查询歌曲失败,使用原有对象: ${songFilePath}`);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 设置videoUrl,WebDAV歌曲会通过VideoItem本身的数据构建完整URL
|
|
|
if(this.currentSong.type==CommonConstants.TYPE_WEBDAV){
|
|
if(this.currentSong.type==CommonConstants.TYPE_WEBDAV){
|
|
|
- this.videoUrl = this.currentSong.filePath.replace(/ /g, '%20');
|
|
|
|
|
|
|
+ if (this.currentSong.webdav_account_id) {
|
|
|
|
|
+ // 如果有webdav_account_id,优先使用remote_rel_path,否则使用filePath
|
|
|
|
|
+ const relativePath = this.currentSong.remote_rel_path || this.currentSong.filePath;
|
|
|
|
|
+ this.videoUrl = await WebDavUrlUtil.buildFullUrlByAccountId(
|
|
|
|
|
+ this.currentSong.webdav_account_id,
|
|
|
|
|
+ relativePath
|
|
|
|
|
+ );
|
|
|
|
|
+ Logger.info('heanup WebDAV playNext', `构建WebDAV URL: ${this.videoUrl}`);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Logger.warn('heanup WebDAV playNext', `缺少webdav_account_id,使用filePath`);
|
|
|
|
|
+ this.videoUrl = this.currentSong.filePath.replace(/ /g, '%20');
|
|
|
|
|
+ }
|
|
|
}else{
|
|
}else{
|
|
|
this.videoUrl = this.currentSong.filePath
|
|
this.videoUrl = this.currentSong.filePath
|
|
|
}
|
|
}
|
|
@@ -13010,7 +13054,7 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
|
|
|
|
|
//上一个
|
|
//上一个
|
|
|
- private playPrevious() {
|
|
|
|
|
|
|
+ private async playPrevious() {
|
|
|
if (!this.debounce()) {
|
|
if (!this.debounce()) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -13026,9 +13070,34 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT;
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT;
|
|
|
this.stop();
|
|
this.stop();
|
|
|
- this.currentSong = this.songList[this.curIndex]
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 参考歌单详情页的方式,从数据库重新查询完整的歌曲信息
|
|
|
|
|
+ const songFilePath = this.songList[this.curIndex].filePath;
|
|
|
|
|
+ const freshSong = await this.table.queryVideoByFilePath(songFilePath);
|
|
|
|
|
+
|
|
|
|
|
+ if (freshSong) {
|
|
|
|
|
+ this.currentSong = freshSong;
|
|
|
|
|
+ Logger.info('heanup playPrevious', `重新查询歌曲信息: ${freshSong.name}, type: ${freshSong.type}`);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 如果查询失败,使用原有的对象
|
|
|
|
|
+ this.currentSong = this.songList[this.curIndex];
|
|
|
|
|
+ Logger.warn('heanup playPrevious', `重新查询歌曲失败,使用原有对象: ${songFilePath}`);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 设置videoUrl,WebDAV歌曲会通过VideoItem本身的数据构建完整URL
|
|
|
if(this.currentSong.type==CommonConstants.TYPE_WEBDAV){
|
|
if(this.currentSong.type==CommonConstants.TYPE_WEBDAV){
|
|
|
- this.videoUrl = this.songList[this.curIndex].filePath.replace(/ /g, '%20');
|
|
|
|
|
|
|
+ if (this.currentSong.webdav_account_id) {
|
|
|
|
|
+ // 如果有webdav_account_id,优先使用remote_rel_path,否则使用filePath
|
|
|
|
|
+ const relativePath = this.currentSong.remote_rel_path || this.currentSong.filePath;
|
|
|
|
|
+ this.videoUrl = await WebDavUrlUtil.buildFullUrlByAccountId(
|
|
|
|
|
+ this.currentSong.webdav_account_id,
|
|
|
|
|
+ relativePath
|
|
|
|
|
+ );
|
|
|
|
|
+ Logger.info('heanup WebDAV playPrevious', `构建WebDAV URL: ${this.videoUrl}`);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Logger.warn('heanup WebDAV playPrevious', `缺少webdav_account_id,使用filePath`);
|
|
|
|
|
+ this.videoUrl = this.songList[this.curIndex].filePath.replace(/ /g, '%20');
|
|
|
|
|
+ }
|
|
|
}else{
|
|
}else{
|
|
|
this.videoUrl = this.songList[this.curIndex].filePath
|
|
this.videoUrl = this.songList[this.curIndex].filePath
|
|
|
}
|
|
}
|
|
@@ -13038,16 +13107,41 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//随机播放模式下点击上一首: 上一首应该应该播放历史记录的第二首
|
|
//随机播放模式下点击上一首: 上一首应该应该播放历史记录的第二首
|
|
|
- private randomModePlayFromHistory() {
|
|
|
|
|
|
|
+ private async randomModePlayFromHistory() {
|
|
|
if (this.historyList.length >= 2) {
|
|
if (this.historyList.length >= 2) {
|
|
|
// 播放历史记录的第二首
|
|
// 播放历史记录的第二首
|
|
|
const prevSong = this.historyList[1];
|
|
const prevSong = this.historyList[1];
|
|
|
this.curIndex = this.songList.findIndex(song => song.filePath === prevSong.filePath);
|
|
this.curIndex = this.songList.findIndex(song => song.filePath === prevSong.filePath);
|
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT;
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT;
|
|
|
this.stop();
|
|
this.stop();
|
|
|
- this.currentSong = prevSong;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 参考歌单详情页的方式,从数据库重新查询完整的歌曲信息
|
|
|
|
|
+ const songFilePath = prevSong.filePath;
|
|
|
|
|
+ const freshSong = await this.table.queryVideoByFilePath(songFilePath);
|
|
|
|
|
+
|
|
|
|
|
+ if (freshSong) {
|
|
|
|
|
+ this.currentSong = freshSong;
|
|
|
|
|
+ Logger.info('heanup randomModePlayFromHistory', `重新查询歌曲信息: ${freshSong.name}, type: ${freshSong.type}`);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 如果查询失败,使用原有的对象
|
|
|
|
|
+ this.currentSong = prevSong;
|
|
|
|
|
+ Logger.warn('heanup randomModePlayFromHistory', `重新查询歌曲失败,使用原有对象: ${songFilePath}`);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 设置videoUrl
|
|
|
if(this.currentSong.type==CommonConstants.TYPE_WEBDAV){
|
|
if(this.currentSong.type==CommonConstants.TYPE_WEBDAV){
|
|
|
- this.videoUrl = prevSong.filePath.replace(/ /g, '%20');
|
|
|
|
|
|
|
+ if (this.currentSong.webdav_account_id) {
|
|
|
|
|
+ // 如果有webdav_account_id,优先使用remote_rel_path,否则使用filePath
|
|
|
|
|
+ const relativePath = this.currentSong.remote_rel_path || this.currentSong.filePath;
|
|
|
|
|
+ this.videoUrl = await WebDavUrlUtil.buildFullUrlByAccountId(
|
|
|
|
|
+ this.currentSong.webdav_account_id,
|
|
|
|
|
+ relativePath
|
|
|
|
|
+ );
|
|
|
|
|
+ Logger.info('heanup WebDAV randomModePlayFromHistory', `构建WebDAV URL: ${this.videoUrl}`);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Logger.warn('heanup WebDAV randomModePlayFromHistory', `缺少webdav_account_id,使用filePath`);
|
|
|
|
|
+ this.videoUrl = prevSong.filePath.replace(/ /g, '%20');
|
|
|
|
|
+ }
|
|
|
}else{
|
|
}else{
|
|
|
this.videoUrl = prevSong.filePath
|
|
this.videoUrl = prevSong.filePath
|
|
|
}
|
|
}
|
|
@@ -13065,9 +13159,34 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT;
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT;
|
|
|
this.stop();
|
|
this.stop();
|
|
|
- this.currentSong = this.songList[this.curIndex];
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 参考歌单详情页的方式,从数据库重新查询完整的歌曲信息
|
|
|
|
|
+ const songFilePath = this.songList[this.curIndex].filePath;
|
|
|
|
|
+ const freshSong = await this.table.queryVideoByFilePath(songFilePath);
|
|
|
|
|
+
|
|
|
|
|
+ if (freshSong) {
|
|
|
|
|
+ this.currentSong = freshSong;
|
|
|
|
|
+ Logger.info('heanup randomModePlayFromHistory', `重新查询歌曲信息: ${freshSong.name}, type: ${freshSong.type}`);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 如果查询失败,使用原有的对象
|
|
|
|
|
+ this.currentSong = this.songList[this.curIndex];
|
|
|
|
|
+ Logger.warn('heanup randomModePlayFromHistory', `重新查询歌曲失败,使用原有对象: ${songFilePath}`);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 设置videoUrl
|
|
|
if(this.currentSong.type==CommonConstants.TYPE_WEBDAV){
|
|
if(this.currentSong.type==CommonConstants.TYPE_WEBDAV){
|
|
|
- this.videoUrl = this.songList[this.curIndex].filePath.replace(/ /g, '%20');
|
|
|
|
|
|
|
+ if (this.currentSong.webdav_account_id) {
|
|
|
|
|
+ // 如果有webdav_account_id,优先使用remote_rel_path,否则使用filePath
|
|
|
|
|
+ const relativePath = this.currentSong.remote_rel_path || this.currentSong.filePath;
|
|
|
|
|
+ this.videoUrl = await WebDavUrlUtil.buildFullUrlByAccountId(
|
|
|
|
|
+ this.currentSong.webdav_account_id,
|
|
|
|
|
+ relativePath
|
|
|
|
|
+ );
|
|
|
|
|
+ Logger.info('heanup WebDAV randomModePlayFromHistory', `构建WebDAV URL: ${this.videoUrl}`);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Logger.warn('heanup WebDAV randomModePlayFromHistory', `缺少webdav_account_id,使用filePath`);
|
|
|
|
|
+ this.videoUrl = this.songList[this.curIndex].filePath.replace(/ /g, '%20');
|
|
|
|
|
+ }
|
|
|
}else{
|
|
}else{
|
|
|
this.videoUrl = this.songList[this.curIndex].filePath
|
|
this.videoUrl = this.songList[this.curIndex].filePath
|
|
|
}
|
|
}
|