|
|
@@ -10127,7 +10127,7 @@ export struct LocalMusic {
|
|
|
@State isHide: boolean = false; //是否因此播放器的按钮,默认是进入横屏模式隐藏,点击视频的时候显示
|
|
|
@State name: string = '';
|
|
|
// @State loop: boolean = false;
|
|
|
- @State playType: number = 0; //0:连续播放 1:单片重复播放 2:正常播放 3:随机播放
|
|
|
+ @State playType: number = 0; //0:连续循环播放 1:单片重复播放 2:正常播放 3:随机播放 4:连续播放不循环
|
|
|
@State multiple: string = '1.0X';
|
|
|
xcomponentController: XComponentController = new XComponentController()
|
|
|
private panOptionBright: PanGestureOptions =
|
|
|
@@ -11128,6 +11128,11 @@ export struct LocalMusic {
|
|
|
.width(26)
|
|
|
.clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
|
|
|
.aspectRatio(CommonConstants.ASPECT_RATIO)
|
|
|
+ } else if (this.playType === 4) {
|
|
|
+ Image($r('app.media.noloop'))
|
|
|
+ .width(26)
|
|
|
+ .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
|
|
|
+ .aspectRatio(CommonConstants.ASPECT_RATIO)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -14119,7 +14124,7 @@ export struct LocalMusic {
|
|
|
if(this.playType == 1){//跳过尾部如果是单曲循环就选择单曲循环
|
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT
|
|
|
this.startPlayOrResumePlay();
|
|
|
- }else if (this.playType == 2) { //2:正常播放,单曲播完
|
|
|
+ }else if (this.playType == 2) { //2:正常播放,单片播完
|
|
|
|
|
|
this.showRePlay();
|
|
|
this.currentTime = this.stringForTime(this.mIjkMediaPlayer.getDuration());
|
|
|
@@ -14127,6 +14132,23 @@ export struct LocalMusic {
|
|
|
this.slideEnable = false;
|
|
|
this.stop();
|
|
|
// ToastUtil.showToast('开始重新播放')
|
|
|
+ }else if (this.playType == 4) { //4:连续播放不循环
|
|
|
+ // 检查是否是最后一首
|
|
|
+ if (this.curIndex >= this.songList.length - 1) {
|
|
|
+ // 已经是最后一首,停止播放
|
|
|
+ Logger.info('heanup setProgress', '连续播放不循环模式:已到达最后一首,停止播放');
|
|
|
+ ToastUtil.showToast('已经是最后一首了');
|
|
|
+ this.showRePlay();
|
|
|
+ this.currentTime = this.stringForTime(this.mIjkMediaPlayer.getDuration());
|
|
|
+ this.progressValue = this.PROGRESS_MAX_VALUE;
|
|
|
+ this.slideEnable = false;
|
|
|
+ this.stop();
|
|
|
+ } else {
|
|
|
+ // 不是最后一首,继续播放下一首
|
|
|
+ this.playNext().catch(() => {
|
|
|
+ Logger.error('heanup setProgress playNext', `播放下一首失败`);
|
|
|
+ });
|
|
|
+ }
|
|
|
}else{
|
|
|
this.playNext().catch(() => {
|
|
|
Logger.error('heanup setProgress playNext', `播放下一首失败`);
|
|
|
@@ -14624,7 +14646,7 @@ export struct LocalMusic {
|
|
|
() => {
|
|
|
|
|
|
LogUtils.getInstance().LOGI("OnCompletionListener-->go")
|
|
|
- if (this.playType == 0) { //0:连续播放 1:单片重复播放 2:正常播放
|
|
|
+ if (this.playType == 0) { //0:连续循环播放 1:单片重复播放 2:正常播放 4:连续播放不循环
|
|
|
// 异步调用playNext
|
|
|
this.playNext().catch(() => {
|
|
|
Logger.error('heanup OnCompletionListener playNext', `播放下一首失败`);
|
|
|
@@ -14646,7 +14668,11 @@ export struct LocalMusic {
|
|
|
this.randomPlay().catch(() => {
|
|
|
Logger.error('heanup OnCompletionListener randomPlay', `随机播放失败`);
|
|
|
});
|
|
|
-
|
|
|
+ } else if (this.playType == 4) { //4:连续播放不循环
|
|
|
+ // 异步调用playNext
|
|
|
+ this.playNext().catch(() => {
|
|
|
+ Logger.error('heanup OnCompletionListener playNext', `播放下一首失败`);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -14831,9 +14857,9 @@ export struct LocalMusic {
|
|
|
|
|
|
setLoopMode() {
|
|
|
let itype = this.playType + 1
|
|
|
- if (itype >= 4) {
|
|
|
+ if (itype >= 5) {
|
|
|
this.playType = 0
|
|
|
- ToastUtil.showToast('连续播放')
|
|
|
+ ToastUtil.showToast('连续循环播放')
|
|
|
} else if (itype === 1) {
|
|
|
this.playType = 1
|
|
|
ToastUtil.showToast('单曲循环')
|
|
|
@@ -14843,9 +14869,12 @@ export struct LocalMusic {
|
|
|
} else if (itype === 3) {
|
|
|
this.playType = 3
|
|
|
ToastUtil.showToast('随机播放')
|
|
|
+ } else if (itype === 4) {
|
|
|
+ this.playType = 4
|
|
|
+ ToastUtil.showToast('连续播放不循环')
|
|
|
} else if (itype === 0) {
|
|
|
this.playType = 0
|
|
|
- ToastUtil.showToast('连续播放')
|
|
|
+ ToastUtil.showToast('连续循环播放')
|
|
|
}
|
|
|
PreferencesUtil.putSync('musicPlayType', this.playType)
|
|
|
this.setCurrentPlayMode()
|
|
|
@@ -14870,7 +14899,10 @@ export struct LocalMusic {
|
|
|
ToastUtil.showToast('随机播放')
|
|
|
} else if (hmPlayMode === 2) {
|
|
|
this.playType = 0
|
|
|
- ToastUtil.showToast('连续播放')
|
|
|
+ ToastUtil.showToast('连续循环播放')
|
|
|
+ } else if (hmPlayMode === 4) {
|
|
|
+ this.playType = 4
|
|
|
+ ToastUtil.showToast('连续播放不循环')
|
|
|
}
|
|
|
PreferencesUtil.putSync('musicPlayType', this.playType)
|
|
|
// 应用收到设置循环模式的指令后,应用自定下一个模式,切换完毕后通过AVPlaybackState上报切换后的LoopMode。
|
|
|
@@ -14893,7 +14925,7 @@ export struct LocalMusic {
|
|
|
let mLoopMode = 0
|
|
|
switch (this.playType) {
|
|
|
case 0:
|
|
|
- mLoopMode = avSession.LoopMode.LOOP_MODE_LIST //连续播放
|
|
|
+ mLoopMode = avSession.LoopMode.LOOP_MODE_LIST //连续循环播放
|
|
|
break;
|
|
|
case 1:
|
|
|
mLoopMode = avSession.LoopMode.LOOP_MODE_SINGLE //单曲
|
|
|
@@ -14904,6 +14936,9 @@ export struct LocalMusic {
|
|
|
case 3:
|
|
|
mLoopMode = avSession.LoopMode.LOOP_MODE_SHUFFLE //随机播放
|
|
|
break;
|
|
|
+ case 4:
|
|
|
+ mLoopMode = avSession.LoopMode.LOOP_MODE_CUSTOM //连续播放不循环
|
|
|
+ break;
|
|
|
}
|
|
|
// 应用启动时/内部切换循环模式,需要把应用内的当前的循环模式设置给AVSession。
|
|
|
let playBState: avSession.AVPlaybackState = {
|
|
|
@@ -15763,9 +15798,23 @@ export struct LocalMusic {
|
|
|
|
|
|
if (ArrayUtil.isNotEmpty(this.songList)) {
|
|
|
if (this.curIndex >= this.songList.length - 1) {
|
|
|
+ // playType=0 或 3: 尝试加载更多或循环
|
|
|
+ // playType=4: 不循环,检查是否是最后一首
|
|
|
+ if (this.playType == 4) {
|
|
|
+ // 连续播放不循环模式:到达最后一首时停止播放
|
|
|
+ Logger.info('heanup playNext', '连续播放不循环模式:已到达最后一首,停止播放');
|
|
|
+ ToastUtil.showToast('已经是最后一首了');
|
|
|
+ this.showRePlay();
|
|
|
+ this.currentTime = this.stringForTime(this.mIjkMediaPlayer.getDuration());
|
|
|
+ this.progressValue = this.PROGRESS_MAX_VALUE;
|
|
|
+ this.slideEnable = false;
|
|
|
+ this.stop();
|
|
|
+ return;
|
|
|
+ }
|
|
|
await this.tryLoadNextPageForPlayback();
|
|
|
}
|
|
|
if (this.curIndex >= this.songList.length - 1) {
|
|
|
+ // playType=4 不应该执行到这里,因为上面已经return了
|
|
|
this.curIndex = 0;
|
|
|
} else {
|
|
|
this.curIndex++;
|