|
|
@@ -36,7 +36,7 @@ import { PopupPosition, XPopup } from '@chinalike/popup';
|
|
|
import { common, ConfigurationConstant } from '@kit.AbilityKit';
|
|
|
import { AnimationHelper, DialogAction, DialogHelper } from '@pura/harmony-dialog';
|
|
|
import { fileIo, fileUri, picker } from '@kit.CoreFileKit';
|
|
|
-import { MessageEvents, util, worker, ErrorEvent } from '@kit.ArkTS';
|
|
|
+import { MessageEvents, util, worker, ErrorEvent, JSON } from '@kit.ArkTS';
|
|
|
import { Verify } from './Verify';
|
|
|
import { taskpool } from '@kit.ArkTS';
|
|
|
import { RotatingCover } from './RotatingCover';
|
|
|
@@ -127,7 +127,6 @@ import {
|
|
|
} from '@kit.UIDesignKit';
|
|
|
import { GlobalAlphabetIndexerModifier } from '../Styels/GlobalStyles'
|
|
|
import { getFirstLetter } from '../Constants';
|
|
|
-
|
|
|
const TAG = 'LocalMusic';
|
|
|
const HICAR_LOG_TAG = 'HiCarWindow';
|
|
|
|
|
|
@@ -879,10 +878,10 @@ export struct LocalMusic {
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ // @Consume currentSong: VideoItem | undefined;
|
|
|
@StorageLink('currentSong') currentSong: VideoItem | undefined = undefined;
|
|
|
// @StorageLink('isPlay') isPlay: boolean = false;
|
|
|
- @StorageLink('isShowPlay') isShowPlay: boolean = false;
|
|
|
+ @Consume isShowPlay: boolean ;
|
|
|
@StorageLink('songList') songList: Array<VideoItem> = [];
|
|
|
@State translateY: number = 0;
|
|
|
@State isShowSheet: boolean = false;
|
|
|
@@ -964,7 +963,7 @@ export struct LocalMusic {
|
|
|
|
|
|
// 多选机制
|
|
|
@State selectedFiles: Array<VideoItem> = [];
|
|
|
- @State isMultiSelect: boolean = false;
|
|
|
+ @Consume isMultiSelect: boolean;
|
|
|
@State isAllSelected: boolean = false;
|
|
|
@State appName: string = ''
|
|
|
@State isHasDir: boolean = false
|
|
|
@@ -1063,6 +1062,7 @@ export struct LocalMusic {
|
|
|
}
|
|
|
// 组件生命周期
|
|
|
aboutToAppear() {
|
|
|
+
|
|
|
console.info('onecold aboutToAppear sdkApiVersion = '+deviceInfo.sdkApiVersion)
|
|
|
if(ArrayUtil.isNotEmpty(this.videoLocalList)&&this.modeType==0){
|
|
|
this.updateListData(this.videoLocalList)
|
|
|
@@ -1251,6 +1251,36 @@ export struct LocalMusic {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ //NewIndex的博空调收到eventHub消息控制播放
|
|
|
+ this.getUIContext().getHostContext()!.eventHub.on('playOrPause', () => {
|
|
|
+ if (ArrayUtil.isNotEmpty(this.songList)) {
|
|
|
+ this.playOrPause();
|
|
|
+ } else {
|
|
|
+ ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.getUIContext().getHostContext()!.eventHub.on('playPrevious', () => {
|
|
|
+ if (ArrayUtil.isNotEmpty(this.songList)) {
|
|
|
+ this.playPrevious();
|
|
|
+ } else {
|
|
|
+ ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.getUIContext().getHostContext()!.eventHub.on('playNext', () => {
|
|
|
+ if (ArrayUtil.isNotEmpty(this.songList)) {
|
|
|
+ this.playNext();
|
|
|
+ } else {
|
|
|
+ ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ this.getUIContext().getHostContext()!.eventHub.on('showPlayerView', () => {
|
|
|
+ this.showPlayerView();
|
|
|
+ });
|
|
|
+ this.getUIContext().getHostContext()!.eventHub.on('openPlayList', () => {
|
|
|
+ this.openPlayList();
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
//载入媒体库,艺术家,专辑等缓存
|
|
|
initLoadCache(){
|
|
|
@@ -3152,20 +3182,27 @@ export struct LocalMusic {
|
|
|
Stack() {
|
|
|
this.ContentBuild()
|
|
|
Stack() {
|
|
|
- this.PlayController()
|
|
|
+ Column()
|
|
|
+ .bindSheet($$this.isShowSheet, this.PlayListSheet(), {
|
|
|
+ height: '95%',
|
|
|
+ dragBar: true,
|
|
|
+ showClose: true,
|
|
|
+ blurStyle: BlurStyle.Thin,
|
|
|
+ preferType: this.currentBreakpoint !== BreakpointTypeEnum.SM ? SheetType.CENTER : SheetType.BOTTOM,
|
|
|
+ backgroundColor: this.isPlayListBgGrass ? Color.Transparent : $r('app.color.silvery'),
|
|
|
+ title: {
|
|
|
+ title: Utility.resourceToString(this.context, $r('app.string.current_play_list'))
|
|
|
+ + `(${this.songList.length}首)`
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
- .hitTestBehavior(HitTestMode.Transparent)
|
|
|
- .opacity(this.barBottomOpacity)
|
|
|
- .width('90%')
|
|
|
- .borderRadius(20)
|
|
|
- .margin({ bottom:DeviceUtil.getDeviceType() === resourceManager.DeviceType.DEVICE_TYPE_2IN1
|
|
|
- ? 30 :this.bottomSafeHeight })
|
|
|
- .backgroundBlurStyle(BlurStyle.BACKGROUND_ULTRA_THICK)
|
|
|
- .backgroundImage( this.cover)
|
|
|
- .visibility(this.isMultiSelect ? Visibility.None : Visibility.Visible)
|
|
|
- .backgroundImageSize( { width: '100%' })
|
|
|
- .opacity(0.9)
|
|
|
- .clickEffect({ level: ClickEffectLevel.HEAVY })
|
|
|
+ .bindContentCover($$this.isShowPlay, this.MusicPlayBuilder(), {
|
|
|
+ modalTransition: ModalTransition.ALPHA,
|
|
|
+ onWillDisappear: () => {
|
|
|
+ this.setShowPlayFalse()
|
|
|
+ },
|
|
|
+ })
|
|
|
+
|
|
|
|
|
|
}
|
|
|
.alignContent(Alignment.Bottom)
|
|
|
@@ -7133,116 +7170,10 @@ export struct LocalMusic {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- @Builder
|
|
|
- PlayController() {
|
|
|
- Row() {
|
|
|
- if(this.isHiCar()){
|
|
|
- this.playConRigth()
|
|
|
- Column(){
|
|
|
- this.centerName()
|
|
|
- }.layoutWeight(1)
|
|
|
- .onClick(()=>{
|
|
|
- this.showPlayerView()
|
|
|
- })
|
|
|
- this.playConLeft(false)
|
|
|
-
|
|
|
- }else{
|
|
|
- this.playConLeft()
|
|
|
- this.playConRigth()
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- .width('100%')
|
|
|
- .height(this.bottomBarHeight)
|
|
|
- .hitTestBehavior(HitTestMode.Transparent)
|
|
|
- .bindContentCover($$this.isShowPlay, this.MusicPlayBuilder(), {
|
|
|
- modalTransition: ModalTransition.DEFAULT,
|
|
|
- onWillDisappear: () => {
|
|
|
- this.setShowPlayFalse()
|
|
|
- },
|
|
|
- })
|
|
|
- .padding({
|
|
|
- left: 16,
|
|
|
- right: 16
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
@State isFrontWhite: boolean = false
|
|
|
|
|
|
- @Builder
|
|
|
- centerName() {
|
|
|
- Column() {
|
|
|
- Text(this.currentSong?.name)
|
|
|
- .fontSize(16)
|
|
|
- .textOverflow({ overflow: TextOverflow.MARQUEE }) //超长滚动
|
|
|
- .maxLines(1)
|
|
|
- .fontColor(Color.White)
|
|
|
- .fontWeight(FontWeight.Bolder);
|
|
|
- Row() {
|
|
|
- Text(this.currentSong?.artist)
|
|
|
- .margin({ top: 2 })
|
|
|
- .fontSize(13)
|
|
|
- .textAlign(TextAlign.Start)
|
|
|
- .maxLines(1)
|
|
|
- .fontWeight(FontWeight.Bold)
|
|
|
- .textOverflow({ overflow: TextOverflow.MARQUEE }) //超长滚动
|
|
|
- .fontColor(Color.White)
|
|
|
- }
|
|
|
- .visibility(this.currentSong?.artist? Visibility.Visible:Visibility.None)
|
|
|
- }
|
|
|
- .alignItems(HorizontalAlign.Center)
|
|
|
- }
|
|
|
- @Builder
|
|
|
- playConLeft(isLeft: boolean = true) {
|
|
|
- Row() {
|
|
|
- // RotatingCover({ songLabel: this.currentSong?.pixelMapPath })
|
|
|
- Image( StrUtil.isNotEmpty(this.currentSong?.pixelMapPath)?
|
|
|
- this.currentSong?.pixelMapPath:$r('app.media.music_red'))
|
|
|
- .height(45)
|
|
|
- .objectFit(ImageFit.Contain)
|
|
|
- .alt( $r('app.media.music_red'))
|
|
|
- .fillColor(this.themeColor)
|
|
|
- .borderRadius(8)
|
|
|
- .shadow({
|
|
|
- radius: 10,
|
|
|
- type: ShadowType.BLUR,
|
|
|
- color: 'on_primary'
|
|
|
- })
|
|
|
- .geometryTransition('cover', { follow: true }) // 绑定标识符
|
|
|
- Column() {
|
|
|
- Text(this.currentSong?.name)
|
|
|
- .fontSize(16)
|
|
|
- .textOverflow({ overflow: TextOverflow.MARQUEE }) //超长滚动
|
|
|
- .maxLines(1)
|
|
|
- .fontColor(Color.White)
|
|
|
- .fontWeight(FontWeight.Bolder);
|
|
|
- Row() {
|
|
|
- Text(this.currentSong?.artist)
|
|
|
- .margin({ top: 2 })
|
|
|
- .fontSize(13)
|
|
|
- .textAlign(TextAlign.Start)
|
|
|
- .maxLines(1)
|
|
|
- .fontWeight(FontWeight.Bold)
|
|
|
- .textOverflow({ overflow: TextOverflow.MARQUEE }) //超长滚动
|
|
|
- .fontColor(Color.White)
|
|
|
- }
|
|
|
- .visibility(this.currentSong?.artist? Visibility.Visible:Visibility.None)
|
|
|
- }
|
|
|
- .padding({left:8})
|
|
|
- .alignItems(isLeft?HorizontalAlign.Start:HorizontalAlign.End)
|
|
|
- .margin({ right: isLeft?22:10 })
|
|
|
- .visibility(isLeft? Visibility.Visible:Visibility.None)
|
|
|
- }
|
|
|
- .padding({ right: 18 })
|
|
|
- .layoutWeight(isLeft?1:0)
|
|
|
- .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
|
|
|
- .onClick(() => {
|
|
|
- this.showPlayerView()
|
|
|
- })
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
setShowPlayTrue(){
|
|
|
this.getUIContext()?.animateTo({
|
|
|
@@ -7263,7 +7194,7 @@ export struct LocalMusic {
|
|
|
}
|
|
|
//打开播放页
|
|
|
showPlayerView() {
|
|
|
-
|
|
|
+ console.info('onecold showPlayerView this.songList'+ JSON.stringify(this.songList))
|
|
|
if (ArrayUtil.isNotEmpty(this.songList)) {
|
|
|
this.setShowPlayTrue()
|
|
|
let lyricPath = this.videoUrl.substring(0, this.videoUrl.lastIndexOf('.')) + '.lrc';
|
|
|
@@ -7273,105 +7204,19 @@ export struct LocalMusic {
|
|
|
ToastUtil.showToast('当前播放列表为空,请先导入音乐。');
|
|
|
}
|
|
|
}
|
|
|
- @Builder
|
|
|
- playConRigth() {
|
|
|
- Row() {
|
|
|
-
|
|
|
- SymbolGlyph($r('sys.symbol.backward_end_fill'))
|
|
|
- .fontSize(28)
|
|
|
- .fontColor([this.themeColor])
|
|
|
- .alignSelf(ItemAlign.Center)
|
|
|
- .visibility(this.isShowPrecious? Visibility.Visible:Visibility.None)
|
|
|
- .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
|
|
|
- .margin({ left: 8, right: 14 })
|
|
|
- .displayPriority(2)
|
|
|
- .onClick(() => {
|
|
|
- if (ArrayUtil.isNotEmpty(this.songList)) {
|
|
|
- this.playPrevious()
|
|
|
- } else {
|
|
|
- ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- })
|
|
|
- //播放进度条
|
|
|
- Stack() {
|
|
|
- Progress({
|
|
|
- value: Math.floor(this.progressValue),
|
|
|
- type: ProgressType.Ring,
|
|
|
-
|
|
|
- })
|
|
|
- .color(this.themeColor)// 进度条前景色为灰色
|
|
|
- .height(38)
|
|
|
- .aspectRatio(CommonConstants.ASPECT_RATIO)
|
|
|
- Image(this.CONTROL_PlayStatus === PlayStatus.PLAY ? $r('app.media.hm_pause') : $r('app.media.hm_play2'))
|
|
|
- .height(36)
|
|
|
- .width(36)
|
|
|
- .displayPriority(3)
|
|
|
- .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
|
|
|
- .fillColor(this.themeColor)
|
|
|
- .onClick(() => {
|
|
|
- if (ArrayUtil.isNotEmpty(this.songList)) {
|
|
|
- console.info('onecold playOrPause 4642')
|
|
|
- this.playOrPause()
|
|
|
- } else {
|
|
|
- ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- SymbolGlyph($r('sys.symbol.forward_end_fill'))
|
|
|
- .fontSize(28)
|
|
|
- .fontColor([this.themeColor])
|
|
|
- .alignSelf(ItemAlign.Center)
|
|
|
- .margin({
|
|
|
- right: 14,
|
|
|
- left: 14
|
|
|
- })
|
|
|
- .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
|
|
|
- .displayPriority(2)
|
|
|
- .onClick(() => {
|
|
|
- if (ArrayUtil.isNotEmpty(this.songList)) {
|
|
|
- this.playNext()
|
|
|
- } else {
|
|
|
- ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
|
|
|
- }
|
|
|
-
|
|
|
- })
|
|
|
-
|
|
|
- Image($r('app.media.hm_playlist'))
|
|
|
- .height(26)
|
|
|
- .width(26)
|
|
|
- .displayPriority(1)
|
|
|
- .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
|
|
|
- .fillColor(this.themeColor)
|
|
|
- .bindSheet($$this.isShowSheet, this.PlayListSheet(), {
|
|
|
- height: '95%',
|
|
|
- dragBar: true,
|
|
|
- showClose: true,
|
|
|
- blurStyle: BlurStyle.Thin,
|
|
|
- preferType: this.currentBreakpoint !== BreakpointTypeEnum.SM ? SheetType.CENTER : SheetType.BOTTOM,
|
|
|
- backgroundColor: this.isPlayListBgGrass ? Color.Transparent : $r('app.color.silvery'),
|
|
|
- title: {
|
|
|
- title: Utility.resourceToString(this.context, $r('app.string.current_play_list'))
|
|
|
- + `(${this.songList.length}首)`
|
|
|
- }
|
|
|
- })
|
|
|
- .onClick(() => {
|
|
|
- if (ArrayUtil.isNotEmpty(this.songList)) {
|
|
|
- this.isShowSheet = !this.isShowSheet;
|
|
|
- this.isFrontWhite = false
|
|
|
- LogUtil.info('onecold scrollToIndex = ' + this.curIndex)
|
|
|
|
|
|
- this.scrollIndex()
|
|
|
|
|
|
- } else {
|
|
|
- ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
|
|
|
- }
|
|
|
+ //打开播放列表
|
|
|
+ openPlayList(){
|
|
|
+ if (ArrayUtil.isNotEmpty(this.songList)) {
|
|
|
+ this.isShowSheet = !this.isShowSheet;
|
|
|
+ this.isFrontWhite = false
|
|
|
+ LogUtil.info('onecold scrollToIndex = ' + this.curIndex)
|
|
|
|
|
|
+ this.scrollIndex()
|
|
|
|
|
|
- })
|
|
|
+ } else {
|
|
|
+ ToastUtil.showToast('当前播放列表为空,请先导入音乐。')
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -9727,7 +9572,7 @@ export struct LocalMusic {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- @State progressValue: number = 0;
|
|
|
+ @Consume progressValue: number ;
|
|
|
@State currentTime: string = "00:00";
|
|
|
@State totalTime: string = "00:00";
|
|
|
@State loadingVisible: Visibility = Visibility.None;
|
|
|
@@ -9750,7 +9595,7 @@ export struct LocalMusic {
|
|
|
private last: number = 0;
|
|
|
@State videoParentAspectRatio: number = this.initAspectRatio;
|
|
|
private mIjkMediaPlayer = IjkMediaPlayer.getInstance();
|
|
|
- @State CONTROL_PlayStatus: number = PlayStatus.INIT;
|
|
|
+ @Consume CONTROL_PlayStatus: number ;
|
|
|
@State PROGRESS_MAX_VALUE: number = 100;
|
|
|
@State updateProgressTimer: number = 0;
|
|
|
@State isHide: boolean = false; //是否因此播放器的按钮,默认是进入横屏模式隐藏,点击视频的时候显示
|
|
|
@@ -9802,7 +9647,7 @@ export struct LocalMusic {
|
|
|
// @State isBgPlayOpen:boolean = true //是否启用后台播放
|
|
|
@State rotateAngle2: number = -9
|
|
|
@StorageLink('imageColor') imageColor: string = 'rgba(0, 0, 2, 1.00)';
|
|
|
- @State cover: string | undefined = '';
|
|
|
+ @Consume cover: string | undefined ;
|
|
|
@State artist: string | undefined = ''
|
|
|
// 1.初始化controller
|
|
|
private lyricController: LyricController = new LyricController()
|
|
|
@@ -14675,6 +14520,7 @@ export struct LocalMusic {
|
|
|
|
|
|
//上一个
|
|
|
private async playPrevious() {
|
|
|
+
|
|
|
if (!this.debounce()) {
|
|
|
return;
|
|
|
}
|