|
|
@@ -143,6 +143,8 @@ const ITEM_HEIGHT_BIG: number = 78; // 列表项大高度
|
|
|
@Preview
|
|
|
@Component
|
|
|
export struct LocalMusic {
|
|
|
+ @State fastForwardSeconds: string = '10'
|
|
|
+ @State isShowBackFast: boolean = true//快进快退按钮
|
|
|
@State isCanAuto:boolean = true
|
|
|
@State opacityValueImage: number = 1;
|
|
|
@State tipPopup:boolean = false
|
|
|
@@ -684,6 +686,8 @@ export struct LocalMusic {
|
|
|
this.autoParseMusicName = PreferencesUtil.getBooleanSync('autoParseMusicName', true)
|
|
|
this.isShowFileName = PreferencesUtil.getBooleanSync('isShowFileName', false)
|
|
|
this.isLongNameRoLL = PreferencesUtil.getBooleanSync('isLongNameRoLL', true)
|
|
|
+ this.fastForwardSeconds = PreferencesUtil.getStringSync('fastForwardSeconds', '10')
|
|
|
+ this.isShowBackFast = PreferencesUtil.getBooleanSync('isShowBackFast', false)
|
|
|
if(this.volumeSmall){
|
|
|
this.volume = 0.5
|
|
|
}else{
|
|
|
@@ -964,7 +968,7 @@ export struct LocalMusic {
|
|
|
workerInstance.postMessage({ code: 2, data: this.context,data2:this.packName });
|
|
|
}
|
|
|
if (this.modeType !== 0) {
|
|
|
-
|
|
|
+ this.openMusic(isOpen, destPath)
|
|
|
return
|
|
|
}
|
|
|
console.info('onecold getSortedFiles 2')
|
|
|
@@ -1088,25 +1092,8 @@ export struct LocalMusic {
|
|
|
// }
|
|
|
|
|
|
// this.setButtonStatus()
|
|
|
- if (isOpen) {
|
|
|
-
|
|
|
- if (destPath === undefined) {
|
|
|
- // 处理 destPath 为 undefined 的情况
|
|
|
- return
|
|
|
- }
|
|
|
- if (destPath.endsWith('.lrc')) {
|
|
|
- ToastUtil.showToast('导入歌词成功!请注意歌词文件和歌曲要同个歌单路径。')
|
|
|
- if (StrUtil.isNotEmpty(this.videoUrl)) {
|
|
|
- let lyricPath = this.videoUrl.substring(0, this.videoUrl.lastIndexOf('.')) + '.lrc'
|
|
|
- this.initLyric(lyricPath);
|
|
|
- }
|
|
|
+ this.openMusic(isOpen, destPath)
|
|
|
|
|
|
- return
|
|
|
- }
|
|
|
- let item2 = new VideoItem(Utility.getMediaNameByUri(destPath), destPath, destPath, 0, 0, '')
|
|
|
- this.doPlay(item2)
|
|
|
- this.isShowPlay = true
|
|
|
- }
|
|
|
|
|
|
|
|
|
});
|
|
|
@@ -1114,6 +1101,29 @@ export struct LocalMusic {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //第三方app打开天天静听导入音乐后播放
|
|
|
+ openMusic(isOpen?: boolean, destPath?: string){
|
|
|
+ if (isOpen&&destPath) {
|
|
|
+
|
|
|
+ if (destPath === undefined) {
|
|
|
+ // 处理 destPath 为 undefined 的情况
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (destPath.endsWith('.lrc')) {
|
|
|
+ ToastUtil.showToast('导入歌词成功!请注意歌词文件和歌曲要同个歌单路径。')
|
|
|
+ if (StrUtil.isNotEmpty(this.videoUrl)) {
|
|
|
+ let lyricPath = this.videoUrl.substring(0, this.videoUrl.lastIndexOf('.')) + '.lrc'
|
|
|
+ this.initLyric(lyricPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let item2 = new VideoItem(Utility.getMediaNameByUri(destPath), destPath, destPath, 0, 0, '')
|
|
|
+ this.doPlay(item2,0,false,true)
|
|
|
+ this.isShowPlay = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//扫描文件夹入库
|
|
|
async scanDirectory(curPath: string): Promise<VideoItem[]> {
|
|
|
const files = FileUtil.listFileSync(curPath);
|
|
|
@@ -4855,7 +4865,7 @@ export struct LocalMusic {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private doPlay(item: VideoItem, index?: number, isFromSonPlayList?: boolean) {
|
|
|
+ private doPlay(item: VideoItem, index?: number, isFromSonPlayList?: boolean,isOpen?:boolean) {
|
|
|
switch (item.type) {
|
|
|
case CommonConstants.TYPE_IS_DIR:
|
|
|
// 进入歌单前安全保存当前滚动偏移量,支持列表和网格
|
|
|
@@ -5055,11 +5065,14 @@ export struct LocalMusic {
|
|
|
this.stop();
|
|
|
}
|
|
|
|
|
|
- if (isFromSonPlayList) { //点击来自右下角的播放列表
|
|
|
+ if (isFromSonPlayList||isOpen) { //点击来自右下角的播放列表
|
|
|
this.currentSong = item
|
|
|
if (index !== undefined) {
|
|
|
this.curIndex = index
|
|
|
}
|
|
|
+ this.songList = []
|
|
|
+ this.songList.push(item)
|
|
|
+ this.sonDataSource.pushArrayData(this.songList)
|
|
|
} else {
|
|
|
let globalVideoList = Utility.getGlobalList(this.videoLocalList, CommonConstants.TYPE_LOCAL) as VideoItem[];
|
|
|
this.curIndex = Utility.getCurIndexFromGlobalList(globalVideoList, item.filePath)
|
|
|
@@ -8373,6 +8386,23 @@ export struct LocalMusic {
|
|
|
Row() {
|
|
|
Column(){
|
|
|
Row(){
|
|
|
+ Stack(){
|
|
|
+ SymbolGlyph($r('sys.symbol.arrow_counterclockwise'))
|
|
|
+ .fontColor([Color.White])
|
|
|
+ .fontSize(21)
|
|
|
+ .effectStrategy(1)
|
|
|
+ Text(this.fastForwardSeconds)
|
|
|
+ .fontColor(Color.White)
|
|
|
+ .fontSize(10)
|
|
|
+ .fontWeight(FontWeight.Bold)
|
|
|
+
|
|
|
+ }
|
|
|
+ .margin({left:12,bottom:6})
|
|
|
+ .visibility(this.isShowBackFast?Visibility.Visible:Visibility.None)
|
|
|
+ .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
|
|
|
+ .onClick(()=>{
|
|
|
+ this.backForward()
|
|
|
+ })
|
|
|
Slider({
|
|
|
value: this.progressValue,
|
|
|
min: 0,
|
|
|
@@ -8403,9 +8433,25 @@ export struct LocalMusic {
|
|
|
this.isSeekTo = false;
|
|
|
// }
|
|
|
})
|
|
|
+ Stack(){
|
|
|
+ SymbolGlyph($r('sys.symbol.arrow_clockwise'))
|
|
|
+ .fontColor([Color.White])
|
|
|
+ .fontSize(21)
|
|
|
+ .effectStrategy(1)
|
|
|
+ Text(this.fastForwardSeconds)
|
|
|
+ .fontColor(Color.White)
|
|
|
+ .fontSize(10)
|
|
|
+ .fontWeight(FontWeight.Bold)
|
|
|
|
|
|
+ }
|
|
|
+ .margin({right:10,bottom:6})
|
|
|
+ .visibility(this.isShowBackFast?Visibility.Visible:Visibility.None)
|
|
|
+ .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
|
|
|
+ .onClick(()=>{
|
|
|
+ this.fastForward()
|
|
|
+ })
|
|
|
}
|
|
|
- .padding({ right: 7,left:20 })
|
|
|
+ .padding({ right: 7,left:22 })
|
|
|
Row(){
|
|
|
Text(this.currentTime)
|
|
|
.fontSize(10)
|
|
|
@@ -12006,6 +12052,25 @@ export struct LocalMusic {
|
|
|
ToastUtil.showToast('已添加至下一首播放')
|
|
|
}
|
|
|
|
|
|
+ //后退10s,可再设置设置默认几秒
|
|
|
+ backForward() {
|
|
|
+ if(this.mIjkMediaPlayer){
|
|
|
+ let pos = this.mIjkMediaPlayer.getCurrentPosition();
|
|
|
+ let value = pos - Number(this.fastForwardSeconds) * 1000;
|
|
|
+ this.seekTo(value+"");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //快进10s,可再设置设置默认几秒
|
|
|
+ fastForward() {
|
|
|
+ if(this.mIjkMediaPlayer){
|
|
|
+ let pos = this.mIjkMediaPlayer.getCurrentPosition();
|
|
|
+ let value = pos + Number(this.fastForwardSeconds) * 1000;
|
|
|
+ this.seekTo(value+"");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//下一个
|
|
|
private playNext() {
|
|
|
if (!this.debounce()) {
|