|
|
@@ -302,6 +302,7 @@ const ITEM_HEIGHT_BIG: number = 78; // 列表项大高度
|
|
|
@Preview
|
|
|
@Component
|
|
|
export struct LocalMusic {
|
|
|
+ @State showFindLocation: boolean = true
|
|
|
@StorageProp("EnablePointLight") enablePointLight: boolean = true
|
|
|
@State showSimple: boolean = true//开启沉浸模式
|
|
|
@State isPaging: boolean = true;//是否分页加载机制
|
|
|
@@ -2149,7 +2150,7 @@ export struct LocalMusic {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private async hydrateFullMediaPlayListIfNeeded(): Promise<void> {
|
|
|
+ private async hydrateFullMediaPlayListIfNeeded(isSonList:boolean = true): Promise<void> {
|
|
|
if (this.isHydratingPlayList) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -2183,8 +2184,14 @@ export struct LocalMusic {
|
|
|
}
|
|
|
}
|
|
|
if (fullList.length > 0) {
|
|
|
- this.songList = fullList;
|
|
|
- this.sonDataSource.pushArrayData(this.songList);
|
|
|
+ if(isSonList){
|
|
|
+ this.songList = fullList;
|
|
|
+ this.sonDataSource.pushArrayData(this.songList);
|
|
|
+ }else{
|
|
|
+ this.videoLocalList = fullList;
|
|
|
+ this.dataSource.pushArrayData(this.videoLocalList);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
} finally {
|
|
|
this.isHydratingPlayList = false;
|
|
|
@@ -3143,9 +3150,9 @@ export struct LocalMusic {
|
|
|
}
|
|
|
})
|
|
|
// 右侧居中的字母表索引
|
|
|
- if(this.showZMIndex){
|
|
|
+
|
|
|
this.indexBuilder()
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
this.topTitleBar()
|
|
|
}
|
|
|
@@ -3329,61 +3336,74 @@ export struct LocalMusic {
|
|
|
//字母表索引
|
|
|
@Builder
|
|
|
indexBuilder(){
|
|
|
- if(this.enableShowAlphabet){
|
|
|
Column({space: 5}){
|
|
|
- if(this.isShowAlphaBet&&!(this.modeType==2&&!this.isCanBack)
|
|
|
- &&!(this.modeType==3&&!this.isCanBack)){
|
|
|
- AlphabetIndexer({arrayValue: this.alphaBet,selected: this.selectAlphaBetIndex})
|
|
|
- .attributeModifier(this.alphaBetStyle)
|
|
|
- .usingPopup(this.isTouchingAlphaBet)
|
|
|
- .onAreaChange((old_value,new_value)=>{
|
|
|
- this.alphabetHeight = new_value.height as number
|
|
|
- })
|
|
|
- .popupPosition({
|
|
|
- x: 40,
|
|
|
- y: this.alphabetHeight / 2
|
|
|
- })
|
|
|
- .onSelect((index: number) => {
|
|
|
- void this.onSelectIndexItem(this.alphaBet[index])
|
|
|
+ if(this.showZMIndex&&this.enableShowAlphabet){
|
|
|
+ if(this.isShowAlphaBet&&!(this.modeType==2&&!this.isCanBack)
|
|
|
+ &&!(this.modeType==3&&!this.isCanBack)){
|
|
|
+ AlphabetIndexer({arrayValue: this.alphaBet,selected: this.selectAlphaBetIndex})
|
|
|
+ .attributeModifier(this.alphaBetStyle)
|
|
|
+ .usingPopup(this.isTouchingAlphaBet)
|
|
|
+ .onAreaChange((old_value,new_value)=>{
|
|
|
+ this.alphabetHeight = new_value.height as number
|
|
|
+ })
|
|
|
+ .popupPosition({
|
|
|
+ x: 40,
|
|
|
+ y: this.alphabetHeight / 2
|
|
|
+ })
|
|
|
+ .onSelect((index: number) => {
|
|
|
+ void this.onSelectIndexItem(this.alphaBet[index])
|
|
|
+ })
|
|
|
+ .onTouch((event: TouchEvent) =>{
|
|
|
+ this.showAlphabetIndex()
|
|
|
+ if(event.type === TouchType.Up || event.type === TouchType.Cancel){
|
|
|
+ this.isTouchingAlphaBet = false
|
|
|
+ this.hideAlphabetIndexAfterDelay(1500)
|
|
|
+ }else{
|
|
|
+ this.isTouchingAlphaBet = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .transition(
|
|
|
+ TransitionEffect.translate({x: 10})
|
|
|
+ .combine(TransitionEffect.opacity(0.1))
|
|
|
+ .animation({
|
|
|
+ duration: 150,
|
|
|
+ curve: Curve.EaseInOut,
|
|
|
+ })
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(this.showFindLocation){
|
|
|
+ if(!(this.showZMIndex&&this.enableShowAlphabet)){
|
|
|
+ Blank()
|
|
|
+ .layoutWeight(1)
|
|
|
+ }
|
|
|
+
|
|
|
+ PointLightDefaultButton({
|
|
|
+ isSysBol:true,
|
|
|
+ pointColor:Color.Black,
|
|
|
+ imageResource:$r('sys.symbol.local_fill'),
|
|
|
+ isPx: false,
|
|
|
+ builderHeight: 30,
|
|
|
+ builderWidth: 30,
|
|
|
+ })
|
|
|
+ // ListLocateButton()
|
|
|
+ .onClick(() =>{
|
|
|
+ void this.locateCurrentSong();
|
|
|
})
|
|
|
- .onTouch((event: TouchEvent) =>{
|
|
|
- this.showAlphabetIndex()
|
|
|
- if(event.type === TouchType.Up || event.type === TouchType.Cancel){
|
|
|
- this.isTouchingAlphaBet = false
|
|
|
- this.hideAlphabetIndexAfterDelay(1500)
|
|
|
- }else{
|
|
|
- this.isTouchingAlphaBet = true
|
|
|
- }
|
|
|
+ .clickEffect({level:ClickEffectLevel.LIGHT,scale: 0.5})
|
|
|
+ .margin({
|
|
|
+ bottom: this.bottomSafeHeight+100,right:10
|
|
|
})
|
|
|
- .transition(
|
|
|
- TransitionEffect.translate({x: 10})
|
|
|
- .combine(TransitionEffect.opacity(0.1))
|
|
|
- .animation({
|
|
|
- duration: 150,
|
|
|
- curve: Curve.EaseInOut,
|
|
|
- })
|
|
|
- )
|
|
|
- }else{
|
|
|
- Blank()
|
|
|
- .layoutWeight(1)
|
|
|
}
|
|
|
|
|
|
- // ListLocateButton()
|
|
|
- // .onClick(() =>{
|
|
|
- // this.locateSong()
|
|
|
- // })
|
|
|
- // .clickEffect({level:ClickEffectLevel.LIGHT,scale: 0.5})
|
|
|
- // .margin({
|
|
|
- // bottom: 10
|
|
|
- // })
|
|
|
}
|
|
|
.padding({
|
|
|
- bottom: 0
|
|
|
+ bottom: 0,right:5
|
|
|
})
|
|
|
.position({x:'92%'})
|
|
|
.height('100%')
|
|
|
.justifyContent(FlexAlign.Center)
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
async onSelectIndexItem(letter: string) {
|
|
|
@@ -7032,6 +7052,47 @@ export struct LocalMusic {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ scrollIndexMain(){
|
|
|
+ try {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.getUIContext()?.animateTo({ duration: 555 }, () => {
|
|
|
+ if(this.curIndex>60){
|
|
|
+ this.listScroller.scrollToIndex(this.curIndex,false, ScrollAlign.CENTER)
|
|
|
+ }else{
|
|
|
+ this.listScroller.scrollToIndex(this.curIndex,true, ScrollAlign.CENTER)
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ }, 123)
|
|
|
+ }catch (error) {
|
|
|
+ console.error(`onecold scrollIndexMain出错: ${error}`);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 智能定位当前播放歌曲,如果当前页没有则加载完整列表
|
|
|
+ async locateCurrentSong(): Promise<void> {
|
|
|
+ if (!this.currentSong) {
|
|
|
+ console.warn("heanup locateCurrentSong: 当前没有播放的歌曲");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查当前播放歌曲是否在已加载的列表中
|
|
|
+ const targetIndex = Utility.getIndexFromList(this.videoLocalList, this.currentSong.filePath);
|
|
|
+
|
|
|
+ if (targetIndex > 0) {
|
|
|
+ // 歌曲在当前列表中,直接滚动
|
|
|
+ console.info("heanup locateCurrentSong: 找到歌曲,索引=" + targetIndex);
|
|
|
+ this.curIndex = targetIndex;
|
|
|
+ } else {
|
|
|
+ // 歌曲不在当前列表中,加载当前歌曲再第几页完整列表后再定位
|
|
|
+ console.info("heanup locateCurrentSong: 歌曲不在当前列表,开始加载完整列表");
|
|
|
+ await this.hydrateFullMediaPlayListIfNeeded(false);
|
|
|
+
|
|
|
+ }
|
|
|
+ this.scrollIndexMain();
|
|
|
+ }
|
|
|
+
|
|
|
//播放列表布局
|
|
|
@Builder
|
|
|
PlayListSheet() {
|