|
@@ -144,7 +144,16 @@ import { KnockController } from '../controller/KnockController';
|
|
|
import { DeleteComptent } from '../view/DeleteComptent';
|
|
import { DeleteComptent } from '../view/DeleteComptent';
|
|
|
import { ABLoopComptent } from '../view/ABLoopComptent';
|
|
import { ABLoopComptent } from '../view/ABLoopComptent';
|
|
|
import { FixMessyView } from '../view/FixMessyView';
|
|
import { FixMessyView } from '../view/FixMessyView';
|
|
|
-import { parseCueFile,CueTrack,CueInfo } from '../common/util/CueUtils';
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ parseCueFile,
|
|
|
|
|
+ CueTrack,
|
|
|
|
|
+ CueInfo,
|
|
|
|
|
+ getCueTrackDuration,
|
|
|
|
|
+ getCueTrackEndOffset,
|
|
|
|
|
+ getCueTrackStartOffset,
|
|
|
|
|
+ importCueTracks,
|
|
|
|
|
+ isCueSplitItem
|
|
|
|
|
+} from '../common/util/CueUtils';
|
|
|
import { CueComptent } from '../view/CueComptent';
|
|
import { CueComptent } from '../view/CueComptent';
|
|
|
import PlaylistTable from '../common/util/PlaylistTable';
|
|
import PlaylistTable from '../common/util/PlaylistTable';
|
|
|
import { showAddToPlaylistDialog } from '../dialog/AddToPlaylistDialog';
|
|
import { showAddToPlaylistDialog } from '../dialog/AddToPlaylistDialog';
|
|
@@ -7433,7 +7442,13 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
AppStorage.setOrCreate('currentSong',this.currentSong) ;
|
|
AppStorage.setOrCreate('currentSong',this.currentSong) ;
|
|
|
- this.videoUrl = this.currentSong.filePath
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ const localUrl = await this.resolvePlaybackUrlForCurrentSong('doPlay-local');
|
|
|
|
|
+ this.videoUrl = localUrl || this.currentSong.filePath
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ Logger.error(TAG, `本地歌曲构建播放地址失败: ${(error as Error).message}`);
|
|
|
|
|
+ this.videoUrl = this.currentSong.filePath
|
|
|
|
|
+ }
|
|
|
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
|
|
@@ -7520,6 +7535,28 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private cueComponentId: number = 0
|
|
private cueComponentId: number = 0
|
|
|
|
|
+ private async handleCueTrackImport(cueinfo: CueInfo): Promise<void> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ let sourceItem = Utility.getItemByFilePath(this.videoLocalList, cueinfo.filePath);
|
|
|
|
|
+ if (!sourceItem) {
|
|
|
|
|
+ sourceItem = await this.table.queryVideoByFilePath(cueinfo.filePath) || undefined;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const importedItems = await importCueTracks(this.context, this.table, cueinfo, sourceItem);
|
|
|
|
|
+ if (ArrayUtil.isEmpty(importedItems)) {
|
|
|
|
|
+ ToastUtil.showToast('未导入到任何分轨');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.getUIContext().getPromptAction().closeCustomDialog(this.cueComponentId);
|
|
|
|
|
+ await this.resetAndLoadFirstPage();
|
|
|
|
|
+ ToastUtil.showToast(`分轨完成,已入库 ${importedItems.length} 首`);
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ Logger.error(TAG, `CUE 分轨入库失败: ${(error as Error).message}`);
|
|
|
|
|
+ ToastUtil.showToast('分轨失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//显示cue分轨列表对话框
|
|
//显示cue分轨列表对话框
|
|
|
showCueDialog(cueTracks:CueTrack[],cueinfo:CueInfo){
|
|
showCueDialog(cueTracks:CueTrack[],cueinfo:CueInfo){
|
|
|
this.getUIContext().getPromptAction().openCustomDialog({
|
|
this.getUIContext().getPromptAction().openCustomDialog({
|
|
@@ -7554,6 +7591,9 @@ export struct LocalMusic {
|
|
|
onCancel:()=>{
|
|
onCancel:()=>{
|
|
|
this.getUIContext().getPromptAction().closeCustomDialog(this.cueComponentId)
|
|
this.getUIContext().getPromptAction().closeCustomDialog(this.cueComponentId)
|
|
|
},
|
|
},
|
|
|
|
|
+ onSplitTracks: async ()=>{
|
|
|
|
|
+ await this.handleCueTrackImport(cueinfo)
|
|
|
|
|
+ },
|
|
|
onDoItemClick: async (item: CueTrack, index: number)=>{
|
|
onDoItemClick: async (item: CueTrack, index: number)=>{
|
|
|
//获取cueinfo对应的filePath
|
|
//获取cueinfo对应的filePath
|
|
|
let globalVideoList = Utility.getGlobalList(this.videoLocalList, CommonConstants.TYPE_LOCAL) as VideoItem[];
|
|
let globalVideoList = Utility.getGlobalList(this.videoLocalList, CommonConstants.TYPE_LOCAL) as VideoItem[];
|
|
@@ -8191,7 +8231,7 @@ export struct LocalMusic {
|
|
|
return this.favList;
|
|
return this.favList;
|
|
|
}
|
|
}
|
|
|
this.playQueueScope = 'view';
|
|
this.playQueueScope = 'view';
|
|
|
- return this.videoLocalList.filter((item: VideoItem) => item.type === CommonConstants.TYPE_LOCAL);
|
|
|
|
|
|
|
+ return Utility.getGlobalList(this.videoLocalList, CommonConstants.TYPE_LOCAL);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private async tryLoadNextPageForPlayback(): Promise<void> {
|
|
private async tryLoadNextPageForPlayback(): Promise<void> {
|
|
@@ -8205,7 +8245,7 @@ export struct LocalMusic {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
await this.loadNextPage();
|
|
await this.loadNextPage();
|
|
|
- const nextList = this.videoLocalList.filter((item: VideoItem) => item.type === CommonConstants.TYPE_LOCAL);
|
|
|
|
|
|
|
+ const nextList = Utility.getGlobalList(this.videoLocalList, CommonConstants.TYPE_LOCAL);
|
|
|
if (nextList.length > this.songList.length) {
|
|
if (nextList.length > this.songList.length) {
|
|
|
this.songList = nextList;
|
|
this.songList = nextList;
|
|
|
this.sonDataSource.pushArrayData(this.songList);
|
|
this.sonDataSource.pushArrayData(this.songList);
|
|
@@ -15411,6 +15451,10 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
//startOffset 从cue分轨时间开始播
|
|
//startOffset 从cue分轨时间开始播
|
|
|
private startPlayOrResumePlay(startOffset?:number) {
|
|
private startPlayOrResumePlay(startOffset?:number) {
|
|
|
|
|
+ let finalStartOffset = startOffset
|
|
|
|
|
+ if ((finalStartOffset === undefined || finalStartOffset === null) && this.currentSong && isCueSplitItem(this.currentSong)) {
|
|
|
|
|
+ finalStartOffset = 0
|
|
|
|
|
+ }
|
|
|
//新版本ijkplayer可以直接播放dsf歌,不需要转格式了。所以注释掉代码
|
|
//新版本ijkplayer可以直接播放dsf歌,不需要转格式了。所以注释掉代码
|
|
|
//针对dsf文件高采样率,统一转wav播放
|
|
//针对dsf文件高采样率,统一转wav播放
|
|
|
// const sampleRate = this.currentSong?.sampleRate||0
|
|
// const sampleRate = this.currentSong?.sampleRate||0
|
|
@@ -15434,7 +15478,7 @@ export struct LocalMusic {
|
|
|
// }else{
|
|
// }else{
|
|
|
// this.startPlay(startOffset)
|
|
// this.startPlay(startOffset)
|
|
|
// }
|
|
// }
|
|
|
- this.startPlay(startOffset)
|
|
|
|
|
|
|
+ this.startPlay(finalStartOffset)
|
|
|
// 仅当前播放的是网盘歌曲时,才提前缓存下一首
|
|
// 仅当前播放的是网盘歌曲时,才提前缓存下一首
|
|
|
// 排除用户拖动进度条的情况
|
|
// 排除用户拖动进度条的情况
|
|
|
if (this.currentSong && isRemoteCloudType(this.currentSong.type) && !this.isSeekTo) {
|
|
if (this.currentSong && isRemoteCloudType(this.currentSong.type) && !this.isSeekTo) {
|
|
@@ -15488,8 +15532,9 @@ export struct LocalMusic {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ const targetFilePath = this.currentSong?.filePath || filePath;
|
|
|
let lastPlayTime = DateUtil.getTodayStr('yyyy-MM-dd HH:mm:ss')
|
|
let lastPlayTime = DateUtil.getTodayStr('yyyy-MM-dd HH:mm:ss')
|
|
|
- this.table.updateLastPlayedStrByFilePath(filePath, lastPlayTime, (success: boolean, error?: string) => {
|
|
|
|
|
|
|
+ this.table.updateLastPlayedStrByFilePath(targetFilePath, lastPlayTime, (success: boolean, error?: string) => {
|
|
|
if (success) {
|
|
if (success) {
|
|
|
this.getHistoryList(false)
|
|
this.getHistoryList(false)
|
|
|
console.log(" onecold 更新最近播放时间成功,数据库已同步");
|
|
console.log(" onecold 更新最近播放时间成功,数据库已同步");
|
|
@@ -15690,8 +15735,27 @@ export struct LocalMusic {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
const shouldRefreshUi = this.isAppForeground && this.isPageVisible;
|
|
const shouldRefreshUi = this.isAppForeground && this.isPageVisible;
|
|
|
- let position = this.mIjkMediaPlayer.getCurrentPosition();
|
|
|
|
|
- let duration = this.mIjkMediaPlayer.getDuration();
|
|
|
|
|
|
|
+ const rawPosition = this.mIjkMediaPlayer.getCurrentPosition();
|
|
|
|
|
+ const rawDuration = this.mIjkMediaPlayer.getDuration();
|
|
|
|
|
+ const cueTrackItem = this.currentSong && isCueSplitItem(this.currentSong) ? this.currentSong : undefined;
|
|
|
|
|
+ const cueTrackStartOffset = cueTrackItem ? getCueTrackStartOffset(cueTrackItem) : 0;
|
|
|
|
|
+ const cueTrackEndOffset = cueTrackItem ? getCueTrackEndOffset(cueTrackItem) : 0;
|
|
|
|
|
+ const cueTrackDuration = cueTrackItem ? getCueTrackDuration(cueTrackItem) : 0;
|
|
|
|
|
+ let position = rawPosition;
|
|
|
|
|
+ let duration = rawDuration;
|
|
|
|
|
+ if (cueTrackItem) {
|
|
|
|
|
+ position = Math.max(0, rawPosition - cueTrackStartOffset);
|
|
|
|
|
+ if (cueTrackDuration > 0) {
|
|
|
|
|
+ duration = cueTrackDuration;
|
|
|
|
|
+ } else if (cueTrackEndOffset > cueTrackStartOffset) {
|
|
|
|
|
+ duration = cueTrackEndOffset - cueTrackStartOffset;
|
|
|
|
|
+ } else if (rawDuration > cueTrackStartOffset) {
|
|
|
|
|
+ duration = rawDuration - cueTrackStartOffset;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (duration > 0 && position > duration) {
|
|
|
|
|
+ position = duration;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
if (duration <= 0 && this.duration > 0) {
|
|
if (duration <= 0 && this.duration > 0) {
|
|
|
duration = this.duration;
|
|
duration = this.duration;
|
|
|
}
|
|
}
|
|
@@ -15720,7 +15784,7 @@ export struct LocalMusic {
|
|
|
position = duration;
|
|
position = duration;
|
|
|
}
|
|
}
|
|
|
if (shouldRefreshUi) {
|
|
if (shouldRefreshUi) {
|
|
|
- const lyricPosition = position + this.timeOffset * 1000;
|
|
|
|
|
|
|
+ const lyricPosition = (cueTrackItem ? rawPosition : position) + this.timeOffset * 1000;
|
|
|
this.isCurrentTime = true;
|
|
this.isCurrentTime = true;
|
|
|
this.updateLyricPosition(lyricPosition);
|
|
this.updateLyricPosition(lyricPosition);
|
|
|
|
|
|
|
@@ -15745,6 +15809,9 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.mIjkMediaPlayer.isPlaying()) {
|
|
if (this.mIjkMediaPlayer.isPlaying()) {
|
|
|
|
|
+ const isCueTrackCompleted = cueTrackItem &&
|
|
|
|
|
+ cueTrackEndOffset > cueTrackStartOffset &&
|
|
|
|
|
+ rawPosition >= cueTrackEndOffset;
|
|
|
|
|
|
|
|
//如果是开启AB循环
|
|
//如果是开启AB循环
|
|
|
if(this.isOpenAB){
|
|
if(this.isOpenAB){
|
|
@@ -15755,15 +15822,15 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 判断是否播放到结束时间
|
|
// 判断是否播放到结束时间
|
|
|
- if (this.isOpenJump && duration > this.jumpEndTime * 1000) {
|
|
|
|
|
- if (position >= duration - this.jumpEndTime * 1000) {
|
|
|
|
|
|
|
+ if ((this.isOpenJump && duration > this.jumpEndTime * 1000 &&
|
|
|
|
|
+ position >= duration - this.jumpEndTime * 1000) || isCueTrackCompleted) {
|
|
|
if(this.playType == 1){//跳过尾部如果是单曲循环就选择单曲循环
|
|
if(this.playType == 1){//跳过尾部如果是单曲循环就选择单曲循环
|
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT
|
|
|
this.startPlayOrResumePlay();
|
|
this.startPlayOrResumePlay();
|
|
|
}else if (this.playType == 2) { //2:正常播放,单片播完
|
|
}else if (this.playType == 2) { //2:正常播放,单片播完
|
|
|
|
|
|
|
|
this.showRePlay();
|
|
this.showRePlay();
|
|
|
- this.currentTime = this.stringForTime(this.mIjkMediaPlayer.getDuration());
|
|
|
|
|
|
|
+ this.currentTime = this.stringForTime(duration);
|
|
|
this.progressValue = this.PROGRESS_MAX_VALUE;
|
|
this.progressValue = this.PROGRESS_MAX_VALUE;
|
|
|
this.slideEnable = false;
|
|
this.slideEnable = false;
|
|
|
this.stop();
|
|
this.stop();
|
|
@@ -15775,7 +15842,7 @@ export struct LocalMusic {
|
|
|
Logger.info('heanup setProgress', '连续播放不循环模式:已到达最后一首,停止播放');
|
|
Logger.info('heanup setProgress', '连续播放不循环模式:已到达最后一首,停止播放');
|
|
|
ToastUtil.showToast('已经是最后一首了');
|
|
ToastUtil.showToast('已经是最后一首了');
|
|
|
this.showRePlay();
|
|
this.showRePlay();
|
|
|
- this.currentTime = this.stringForTime(this.mIjkMediaPlayer.getDuration());
|
|
|
|
|
|
|
+ this.currentTime = this.stringForTime(duration);
|
|
|
this.progressValue = this.PROGRESS_MAX_VALUE;
|
|
this.progressValue = this.PROGRESS_MAX_VALUE;
|
|
|
this.slideEnable = false;
|
|
this.slideEnable = false;
|
|
|
this.stop();
|
|
this.stop();
|
|
@@ -15791,7 +15858,6 @@ export struct LocalMusic {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -16130,17 +16196,21 @@ export struct LocalMusic {
|
|
|
await this.initLyric(lyricPath);
|
|
await this.initLyric(lyricPath);
|
|
|
|
|
|
|
|
const applyDuration = (durationMs: number): void => {
|
|
const applyDuration = (durationMs: number): void => {
|
|
|
- if (durationMs <= 0) {
|
|
|
|
|
|
|
+ const cueTrackDuration = this.currentSong && isCueSplitItem(this.currentSong)
|
|
|
|
|
+ ? getCueTrackDuration(this.currentSong)
|
|
|
|
|
+ : 0;
|
|
|
|
|
+ const effectiveDuration = cueTrackDuration > 0 ? cueTrackDuration : durationMs;
|
|
|
|
|
+ if (effectiveDuration <= 0) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- this.duration = durationMs;
|
|
|
|
|
- this.durationTime = Math.floor(durationMs / 1000);
|
|
|
|
|
|
|
+ this.duration = effectiveDuration;
|
|
|
|
|
+ this.durationTime = Math.floor(effectiveDuration / 1000);
|
|
|
this.durationStringTime = secondToTime(this.durationTime);
|
|
this.durationStringTime = secondToTime(this.durationTime);
|
|
|
- this.totalTime = this.stringForTime(durationMs);
|
|
|
|
|
|
|
+ this.totalTime = this.stringForTime(effectiveDuration);
|
|
|
if (this.currentSong) {
|
|
if (this.currentSong) {
|
|
|
this.currentSong.duration = this.totalTime;
|
|
this.currentSong.duration = this.totalTime;
|
|
|
try {
|
|
try {
|
|
|
- this.avSessionController.setAVMetadataMusic(this.currentSong, durationMs, this.lyricContent);
|
|
|
|
|
|
|
+ this.avSessionController.setAVMetadataMusic(this.currentSong, effectiveDuration, this.lyricContent);
|
|
|
} catch (metaError) {
|
|
} catch (metaError) {
|
|
|
Logger.warn(TAG, `heanup 首次播放写入AVSession失败: ${(metaError as Error).message}`);
|
|
Logger.warn(TAG, `heanup 首次播放写入AVSession失败: ${(metaError as Error).message}`);
|
|
|
}
|
|
}
|
|
@@ -16246,8 +16316,12 @@ export struct LocalMusic {
|
|
|
this.updateSessionPlayState(true)
|
|
this.updateSessionPlayState(true)
|
|
|
this.setCurrentPlayMode()
|
|
this.setCurrentPlayMode()
|
|
|
|
|
|
|
|
- if(startOffset&&startOffset>0){//cue分轨播放
|
|
|
|
|
- this.seekTo(startOffset + "");
|
|
|
|
|
|
|
+ const cueTrackStartOffset = this.currentSong && isCueSplitItem(this.currentSong)
|
|
|
|
|
+ ? getCueTrackStartOffset(this.currentSong)
|
|
|
|
|
+ : 0;
|
|
|
|
|
+ if ((startOffset && startOffset > 0) || cueTrackStartOffset > 0) {//cue分轨播放
|
|
|
|
|
+ const cueSeekValue = cueTrackStartOffset > 0 && (!startOffset || startOffset <= 0) ? 0 : startOffset;
|
|
|
|
|
+ this.seekTo((cueSeekValue || 0) + "");
|
|
|
this.saveLastPlayList()
|
|
this.saveLastPlayList()
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -16291,7 +16365,7 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
const playerDuration = this.mIjkMediaPlayer.getDuration()
|
|
const playerDuration = this.mIjkMediaPlayer.getDuration()
|
|
|
- if (playerDuration > 0) {
|
|
|
|
|
|
|
+ if (playerDuration > 0 && (!this.currentSong || !isCueSplitItem(this.currentSong))) {
|
|
|
this.duration = playerDuration
|
|
this.duration = playerDuration
|
|
|
}
|
|
}
|
|
|
const memoryPosition = this.pendingMemorySeekPosition > 0 ?
|
|
const memoryPosition = this.pendingMemorySeekPosition > 0 ?
|
|
@@ -16398,7 +16472,7 @@ export struct LocalMusic {
|
|
|
} else if (this.playType == 2) { //2:正常播放,单曲播完
|
|
} else if (this.playType == 2) { //2:正常播放,单曲播完
|
|
|
|
|
|
|
|
that.showRePlay();
|
|
that.showRePlay();
|
|
|
- that.currentTime = that.stringForTime(this.mIjkMediaPlayer.getDuration());
|
|
|
|
|
|
|
+ that.currentTime = that.stringForTime(that.getActiveDuration());
|
|
|
that.progressValue = this.PROGRESS_MAX_VALUE;
|
|
that.progressValue = this.PROGRESS_MAX_VALUE;
|
|
|
that.slideEnable = false;
|
|
that.slideEnable = false;
|
|
|
that.stop();
|
|
that.stop();
|
|
@@ -17182,6 +17256,9 @@ export struct LocalMusic {
|
|
|
} else if (this.mIjkMediaPlayer != null) {
|
|
} else if (this.mIjkMediaPlayer != null) {
|
|
|
// 本地播放器模式
|
|
// 本地播放器模式
|
|
|
curPosition = this.mIjkMediaPlayer.getCurrentPosition();
|
|
curPosition = this.mIjkMediaPlayer.getCurrentPosition();
|
|
|
|
|
+ if (this.currentSong && isCueSplitItem(this.currentSong)) {
|
|
|
|
|
+ curPosition = Math.max(0, curPosition - getCueTrackStartOffset(this.currentSong));
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -17198,6 +17275,12 @@ export struct LocalMusic {
|
|
|
await this.seekTo(seeTime + "");
|
|
await this.seekTo(seeTime + "");
|
|
|
};
|
|
};
|
|
|
private getActiveDuration(): number {
|
|
private getActiveDuration(): number {
|
|
|
|
|
+ if (this.currentSong && isCueSplitItem(this.currentSong)) {
|
|
|
|
|
+ const cueDuration = getCueTrackDuration(this.currentSong);
|
|
|
|
|
+ if (cueDuration > 0) {
|
|
|
|
|
+ return cueDuration;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
let duration = this.mIjkMediaPlayer.getDuration();
|
|
let duration = this.mIjkMediaPlayer.getDuration();
|
|
|
if (this.castControllerWrapper && this.isCastPlaying) {
|
|
if (this.castControllerWrapper && this.isCastPlaying) {
|
|
|
return this.duration > 0 ? this.duration : duration;
|
|
return this.duration > 0 ? this.duration : duration;
|
|
@@ -17333,6 +17416,9 @@ export struct LocalMusic {
|
|
|
} else if (this.mIjkMediaPlayer != null) {
|
|
} else if (this.mIjkMediaPlayer != null) {
|
|
|
// 本地播放器模式
|
|
// 本地播放器模式
|
|
|
curPosition = this.mIjkMediaPlayer.getCurrentPosition();
|
|
curPosition = this.mIjkMediaPlayer.getCurrentPosition();
|
|
|
|
|
+ if (this.currentSong && isCueSplitItem(this.currentSong)) {
|
|
|
|
|
+ curPosition = Math.max(0, curPosition - getCueTrackStartOffset(this.currentSong));
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -17413,9 +17499,16 @@ export struct LocalMusic {
|
|
|
//保持记忆播放功能
|
|
//保持记忆播放功能
|
|
|
private savePlaybackPosition() {
|
|
private savePlaybackPosition() {
|
|
|
if (this.mIjkMediaPlayer != null) {
|
|
if (this.mIjkMediaPlayer != null) {
|
|
|
- const position = this.mIjkMediaPlayer.getCurrentPosition();
|
|
|
|
|
|
|
+ let position = this.mIjkMediaPlayer.getCurrentPosition();
|
|
|
// ToastUtil.showToast('保存记忆播放 = ' + position)
|
|
// ToastUtil.showToast('保存记忆播放 = ' + position)
|
|
|
- const duration = this.mIjkMediaPlayer.getDuration();
|
|
|
|
|
|
|
+ let duration = this.mIjkMediaPlayer.getDuration();
|
|
|
|
|
+ if (this.currentSong && isCueSplitItem(this.currentSong)) {
|
|
|
|
|
+ position = Math.max(0, position - getCueTrackStartOffset(this.currentSong));
|
|
|
|
|
+ const cueDuration = getCueTrackDuration(this.currentSong);
|
|
|
|
|
+ if (cueDuration > 0) {
|
|
|
|
|
+ duration = cueDuration;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
const threshold = 5000; // 阈值,单位为毫秒(这里设为5秒)
|
|
const threshold = 5000; // 阈值,单位为毫秒(这里设为5秒)
|
|
|
|
|
|
|
|
// 如果播放位置接近视频末尾,则保存 position 为 0
|
|
// 如果播放位置接近视频末尾,则保存 position 为 0
|
|
@@ -17432,6 +17525,9 @@ export struct LocalMusic {
|
|
|
const stablePath = song.remote_rel_path || song.id || song.baiduFsId || song.filePath || playbackUrl || '';
|
|
const stablePath = song.remote_rel_path || song.id || song.baiduFsId || song.filePath || playbackUrl || '';
|
|
|
return `memory_play_remote:${song.type}:${accountId}:${stablePath}`;
|
|
return `memory_play_remote:${song.type}:${accountId}:${stablePath}`;
|
|
|
}
|
|
}
|
|
|
|
|
+ if (song && isCueSplitItem(song)) {
|
|
|
|
|
+ return `memory_play_local_cue:${song.filePath}`;
|
|
|
|
|
+ }
|
|
|
return playbackUrl || '';
|
|
return playbackUrl || '';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -17525,10 +17621,19 @@ export struct LocalMusic {
|
|
|
if (this.castControllerWrapper && this.isCastPlaying) {
|
|
if (this.castControllerWrapper && this.isCastPlaying) {
|
|
|
try {
|
|
try {
|
|
|
let seekPos = Number.parseInt(value);
|
|
let seekPos = Number.parseInt(value);
|
|
|
|
|
+ const cueTrackItem = this.currentSong && isCueSplitItem(this.currentSong) ? this.currentSong : undefined;
|
|
|
|
|
+ const cueTrackStartOffset = cueTrackItem ? getCueTrackStartOffset(cueTrackItem) : 0;
|
|
|
|
|
+ const cueTrackEndOffset = cueTrackItem ? getCueTrackEndOffset(cueTrackItem) : 0;
|
|
|
const duration = this.getActiveDuration();
|
|
const duration = this.getActiveDuration();
|
|
|
if (duration > 0) {
|
|
if (duration > 0) {
|
|
|
seekPos = Math.max(0, Math.min(seekPos, duration - 200));
|
|
seekPos = Math.max(0, Math.min(seekPos, duration - 200));
|
|
|
}
|
|
}
|
|
|
|
|
+ if (cueTrackItem) {
|
|
|
|
|
+ seekPos += cueTrackStartOffset;
|
|
|
|
|
+ if (cueTrackEndOffset > cueTrackStartOffset) {
|
|
|
|
|
+ seekPos = Math.min(seekPos, cueTrackEndOffset - 200);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
this.beginSeekTrace(source, seekPos);
|
|
this.beginSeekTrace(source, seekPos);
|
|
|
this.isSeekTo = true;
|
|
this.isSeekTo = true;
|
|
|
Logger.info(
|
|
Logger.info(
|
|
@@ -17553,6 +17658,9 @@ export struct LocalMusic {
|
|
|
if (Number.isNaN(seekPos)) {
|
|
if (Number.isNaN(seekPos)) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ const cueTrackItem = this.currentSong && isCueSplitItem(this.currentSong) ? this.currentSong : undefined;
|
|
|
|
|
+ const cueTrackStartOffset = cueTrackItem ? getCueTrackStartOffset(cueTrackItem) : 0;
|
|
|
|
|
+ const cueTrackEndOffset = cueTrackItem ? getCueTrackEndOffset(cueTrackItem) : 0;
|
|
|
const duration = this.getActiveDuration();
|
|
const duration = this.getActiveDuration();
|
|
|
const isRemoteSong = this.currentSong ? isRemoteCloudType(this.currentSong.type) : false;
|
|
const isRemoteSong = this.currentSong ? isRemoteCloudType(this.currentSong.type) : false;
|
|
|
if (duration > 0) {
|
|
if (duration > 0) {
|
|
@@ -17560,6 +17668,12 @@ export struct LocalMusic {
|
|
|
} else if (seekPos < 0) {
|
|
} else if (seekPos < 0) {
|
|
|
seekPos = 0;
|
|
seekPos = 0;
|
|
|
}
|
|
}
|
|
|
|
|
+ if (cueTrackItem) {
|
|
|
|
|
+ seekPos += cueTrackStartOffset;
|
|
|
|
|
+ if (cueTrackEndOffset > cueTrackStartOffset) {
|
|
|
|
|
+ seekPos = Math.min(seekPos, cueTrackEndOffset - 200);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
if (isRemoteSong && duration <= 0 && seekPos > 0) {
|
|
if (isRemoteSong && duration <= 0 && seekPos > 0) {
|
|
|
Logger.warn(TAG, `seekTo 跳过未知时长远程seek: ${seekPos}ms`);
|
|
Logger.warn(TAG, `seekTo 跳过未知时长远程seek: ${seekPos}ms`);
|
|
|
return;
|
|
return;
|
|
@@ -17628,6 +17742,9 @@ export struct LocalMusic {
|
|
|
Logger.info('heanup backForward', `投播模式当前位置: ${pos}ms`);
|
|
Logger.info('heanup backForward', `投播模式当前位置: ${pos}ms`);
|
|
|
} else if (this.mIjkMediaPlayer) {
|
|
} else if (this.mIjkMediaPlayer) {
|
|
|
pos = this.mIjkMediaPlayer.getCurrentPosition();
|
|
pos = this.mIjkMediaPlayer.getCurrentPosition();
|
|
|
|
|
+ if (this.currentSong && isCueSplitItem(this.currentSong)) {
|
|
|
|
|
+ pos = Math.max(0, pos - getCueTrackStartOffset(this.currentSong));
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -17648,6 +17765,9 @@ export struct LocalMusic {
|
|
|
Logger.info('heanup fastForward', `投播模式当前位置: ${pos}ms`);
|
|
Logger.info('heanup fastForward', `投播模式当前位置: ${pos}ms`);
|
|
|
} else if (this.mIjkMediaPlayer) {
|
|
} else if (this.mIjkMediaPlayer) {
|
|
|
pos = this.mIjkMediaPlayer.getCurrentPosition();
|
|
pos = this.mIjkMediaPlayer.getCurrentPosition();
|
|
|
|
|
+ if (this.currentSong && isCueSplitItem(this.currentSong)) {
|
|
|
|
|
+ pos = Math.max(0, pos - getCueTrackStartOffset(this.currentSong));
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -17690,7 +17810,7 @@ export struct LocalMusic {
|
|
|
Logger.info('heanup playNext', '连续播放不循环模式:已到达最后一首,停止播放');
|
|
Logger.info('heanup playNext', '连续播放不循环模式:已到达最后一首,停止播放');
|
|
|
ToastUtil.showToast('已经是最后一首了');
|
|
ToastUtil.showToast('已经是最后一首了');
|
|
|
this.showRePlay();
|
|
this.showRePlay();
|
|
|
- this.currentTime = this.stringForTime(this.mIjkMediaPlayer.getDuration());
|
|
|
|
|
|
|
+ this.currentTime = this.stringForTime(this.getActiveDuration());
|
|
|
this.progressValue = this.PROGRESS_MAX_VALUE;
|
|
this.progressValue = this.PROGRESS_MAX_VALUE;
|
|
|
this.slideEnable = false;
|
|
this.slideEnable = false;
|
|
|
this.stop();
|
|
this.stop();
|