|
|
@@ -4905,16 +4905,18 @@ export struct LocalMusic {
|
|
|
|
|
|
Image(StrUtil.isNotEmpty(this.imagePathStr)?this.imagePathStr.startsWith('http')?
|
|
|
this.imagePathStr:fileUri.getUriFromPath(this.imagePathStr):
|
|
|
- StrUtil.isEmpty(item.pixelMapPath) ? $r('app.media.add') :
|
|
|
+ StrUtil.isEmpty(item.pixelMapPath) ? $r('app.media.add_image2') :
|
|
|
item.pixelMapPath)
|
|
|
.fillColor(this.themeColor)
|
|
|
.height(88)
|
|
|
.width(88)
|
|
|
- .borderRadius('100%')
|
|
|
+ .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.6})
|
|
|
+ .borderRadius(12)
|
|
|
.clip(true)
|
|
|
.opacity(this.opacityItem)// 绑定透明度
|
|
|
.margin({ left: 25 })
|
|
|
}
|
|
|
+ .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.6})
|
|
|
.onClick(async () => {
|
|
|
|
|
|
const imagePath:string | undefined = await this.goSelectImage(item);
|
|
|
@@ -4929,7 +4931,7 @@ export struct LocalMusic {
|
|
|
Row() {
|
|
|
Column() {
|
|
|
Text(item.name)
|
|
|
- .fontSize(18)
|
|
|
+ .fontSize(17)
|
|
|
.maxLines(1)
|
|
|
.textOverflow({ overflow: TextOverflow.MARQUEE })//超长滚动
|
|
|
.animation({
|
|
|
@@ -4938,25 +4940,90 @@ export struct LocalMusic {
|
|
|
})
|
|
|
|
|
|
.fontColor(this.themeColor)
|
|
|
- .margin({ left: 18 })
|
|
|
+ .margin({ left: 8 })
|
|
|
Row() {
|
|
|
Text(item.artist)
|
|
|
- .fontSize(15)
|
|
|
+ .fontSize(14)
|
|
|
.maxLines(1)
|
|
|
.textOverflow({ overflow: TextOverflow.MARQUEE })//超长滚动
|
|
|
.padding({ top: 8 })
|
|
|
.fontColor(this.themeColor)
|
|
|
- .margin({ left: 18 })
|
|
|
+ .margin({ left: 8 })
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
.height('100%')
|
|
|
.width(100)
|
|
|
+ .layoutWeight(1)
|
|
|
.visibility(this.isDarkMode ? Visibility.None : Visibility.Visible)
|
|
|
.justifyContent(FlexAlign.Center)
|
|
|
.alignItems(HorizontalAlign.Start)
|
|
|
|
|
|
+ Column() {
|
|
|
+ Button('获取封面')
|
|
|
+ .fontColor(Color.White)
|
|
|
+ .fontSize(12)
|
|
|
+ .height(38)
|
|
|
+ .width(88)
|
|
|
+ .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
|
|
|
+ .backgroundColor(this.themeColor)
|
|
|
+ .stateEffect(true)
|
|
|
+ .margin({ left: 5 })
|
|
|
+ .onClick(async () => {
|
|
|
+ if (PreferencesUtil.getStringSync('COVER_API', '') === '') {
|
|
|
+ this.showTipsDialog();
|
|
|
+ return; // Return empty string when no API is configured
|
|
|
+ }
|
|
|
+
|
|
|
+ const imagePath:string | undefined = await this.doSearchCover(item);
|
|
|
+ console.info('onecold imagePath = '+imagePath)
|
|
|
+ if (StrUtil.isNotEmpty(imagePath)) {
|
|
|
+ //用户更改过图片
|
|
|
+ this.imagePathStr = imagePath
|
|
|
+ ToastUtil.showToast('获取封面成功')
|
|
|
+ }else{
|
|
|
+ ToastUtil.showToast('获取封面失败,请重试')
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ Button('获取歌词')
|
|
|
+ .fontColor(Color.White)
|
|
|
+ .fontSize(12)
|
|
|
+ .height(38)
|
|
|
+ .width(88)
|
|
|
+ .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
|
|
|
+ .backgroundColor(this.themeColor)
|
|
|
+ .stateEffect(true)
|
|
|
+ .margin({ top: 9, left: 5 })
|
|
|
+ .onClick(async () => {
|
|
|
+ //判断有没有设置api
|
|
|
+ let apiUrl = PreferencesUtil.getStringSync('LRC_API', '')
|
|
|
+ if (StrUtil.isEmpty(apiUrl)) {
|
|
|
+ this.isLyricSetting = false
|
|
|
+ this.showTipsDialog()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let artist = item.artist
|
|
|
+ let title = item.name
|
|
|
+ if(!artist)
|
|
|
+ artist = ''
|
|
|
+ if(!title)
|
|
|
+ title = ''
|
|
|
+ let res: string | undefined = await getApiLyric(apiUrl,title, artist, false);
|
|
|
+ if (res && StrUtil.isNotEmpty(res) && res !== 'unknown' && res !== 'Timeout was reached') {
|
|
|
+ this.lyricConStr = res;
|
|
|
+ ToastUtil.showToast('获取歌词成功')
|
|
|
+ }else{
|
|
|
+ ToastUtil.showToast('获取歌词失败,请重试')
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .justifyContent(FlexAlign.Start)
|
|
|
+
|
|
|
|
|
|
}
|
|
|
.height('100%')
|
|
|
@@ -4967,70 +5034,7 @@ export struct LocalMusic {
|
|
|
.width('100%')
|
|
|
.height(98)
|
|
|
|
|
|
- Row() {
|
|
|
- Button('获取封面')
|
|
|
- .fontColor(Color.White)
|
|
|
- .fontSize(12)
|
|
|
- .height(38)
|
|
|
- .width(88)
|
|
|
- .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
|
|
|
- .backgroundColor(this.themeColor)
|
|
|
- .stateEffect(true)
|
|
|
- .margin({ right: 15, left: 20 })
|
|
|
- .onClick(async () => {
|
|
|
- if (PreferencesUtil.getStringSync('COVER_API', '') === '') {
|
|
|
- this.showTipsDialog();
|
|
|
- return; // Return empty string when no API is configured
|
|
|
- }
|
|
|
-
|
|
|
- const imagePath:string | undefined = await this.doSearchCover(item);
|
|
|
- console.info('onecold imagePath = '+imagePath)
|
|
|
- if (StrUtil.isNotEmpty(imagePath)) {
|
|
|
- //用户更改过图片
|
|
|
- this.imagePathStr = imagePath
|
|
|
- ToastUtil.showToast('获取封面成功')
|
|
|
- }else{
|
|
|
- ToastUtil.showToast('获取封面失败,请重试')
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- })
|
|
|
-
|
|
|
- Button('获取歌词')
|
|
|
- .fontColor(Color.White)
|
|
|
- .fontSize(12)
|
|
|
- .height(38)
|
|
|
- .width(88)
|
|
|
- .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
|
|
|
- .backgroundColor(this.themeColor)
|
|
|
- .stateEffect(true)
|
|
|
- .margin({ right: 20, left: 15 })
|
|
|
- .onClick(async () => {
|
|
|
- //判断有没有设置api
|
|
|
- let apiUrl = PreferencesUtil.getStringSync('LRC_API', '')
|
|
|
- if (StrUtil.isEmpty(apiUrl)) {
|
|
|
- this.isLyricSetting = false
|
|
|
- this.showTipsDialog()
|
|
|
- return
|
|
|
- }
|
|
|
- let artist = item.artist
|
|
|
- let title = item.name
|
|
|
- if(!artist)
|
|
|
- artist = ''
|
|
|
- if(!title)
|
|
|
- title = ''
|
|
|
- let res: string | undefined = await getApiLyric(apiUrl,title, artist, false);
|
|
|
- if (res && StrUtil.isNotEmpty(res) && res !== 'unknown' && res !== 'Timeout was reached') {
|
|
|
- this.lyricConStr = res;
|
|
|
- ToastUtil.showToast('获取歌词成功')
|
|
|
- }else{
|
|
|
- ToastUtil.showToast('获取歌词失败,请重试')
|
|
|
- }
|
|
|
|
|
|
- })
|
|
|
- }
|
|
|
- .height(55)
|
|
|
- .justifyContent(FlexAlign.Start)
|
|
|
|
|
|
Row() {
|
|
|
Text('标题:')
|
|
|
@@ -7120,10 +7124,23 @@ export struct LocalMusic {
|
|
|
async getLyricContent(item: VideoItem): Promise<string> {
|
|
|
let neiqianLrc = ''
|
|
|
let lyContent = item?.lyricContent
|
|
|
- if(lyContent&&StrUtil.isNotEmpty(lyContent)){//取数据库里面的歌词lyContent
|
|
|
+ if(lyContent&&StrUtil.isNotEmpty(lyContent)){
|
|
|
neiqianLrc = lyContent
|
|
|
return neiqianLrc
|
|
|
}
|
|
|
+ try {
|
|
|
+ //取数据库里面的歌词lyContent
|
|
|
+ const lyricContent = await this.table.getLyricContentByFilePath(item.filePath);
|
|
|
+ if (lyricContent&&StrUtil.isNotEmpty(lyricContent)) {
|
|
|
+ console.log("onecold Lyrics:", lyricContent);
|
|
|
+ neiqianLrc = lyricContent
|
|
|
+ return neiqianLrc
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error("Error fetching lyrics:", error);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
try {
|
|
|
let filePath = item.filePath;
|
|
|
let lyricPath = filePath.substring(0, filePath.lastIndexOf('.')) + '.lrc';
|