|
@@ -2,7 +2,7 @@ import { common, ConfigurationConstant } from '@kit.AbilityKit';
|
|
|
import { CommonConstants } from '../common/constants/CommonConstants';
|
|
import { CommonConstants } from '../common/constants/CommonConstants';
|
|
|
import { VideoItem } from '../viewmodel/VideoItem';
|
|
import { VideoItem } from '../viewmodel/VideoItem';
|
|
|
import { LazyDataSource } from '../common/util/LazyDataSource';
|
|
import { LazyDataSource } from '../common/util/LazyDataSource';
|
|
|
-import { AppUtil, LogUtil, PreferencesUtil, StrUtil, ToastUtil } from '@pura/harmony-utils';
|
|
|
|
|
|
|
+import { AppUtil, FileUtil, LogUtil, PreferencesUtil, StrUtil, ToastUtil } from '@pura/harmony-utils';
|
|
|
import fs from '@ohos.file.fs';
|
|
import fs from '@ohos.file.fs';
|
|
|
import { changeMusicCover, findLocalCoverImage, getApiLyric, repairAudioMetadata,
|
|
import { changeMusicCover, findLocalCoverImage, getApiLyric, repairAudioMetadata,
|
|
|
searchCover,
|
|
searchCover,
|
|
@@ -11,6 +11,8 @@ import { util } from '@kit.ArkTS';
|
|
|
import { FFMpegTags, Utility } from '../common/util/Utility';
|
|
import { FFMpegTags, Utility } from '../common/util/Utility';
|
|
|
import { DialogHelper } from '@pura/harmony-dialog';
|
|
import { DialogHelper } from '@pura/harmony-dialog';
|
|
|
import PermissionUtil from '../common/util/PermissionUtil'
|
|
import PermissionUtil from '../common/util/PermissionUtil'
|
|
|
|
|
+import MediaTable from '../common/util/MediaTable';
|
|
|
|
|
+
|
|
|
//批量编辑标签
|
|
//批量编辑标签
|
|
|
// 批量编辑标签
|
|
// 批量编辑标签
|
|
|
@Component
|
|
@Component
|
|
@@ -22,6 +24,7 @@ export struct TagsContentCover {
|
|
|
@State isCover:boolean = true
|
|
@State isCover:boolean = true
|
|
|
@State download_path:string = ''
|
|
@State download_path:string = ''
|
|
|
@Link isOneKeyTags: boolean;
|
|
@Link isOneKeyTags: boolean;
|
|
|
|
|
+ @Prop table: MediaTable
|
|
|
@State packName: string = ''
|
|
@State packName: string = ''
|
|
|
@State dataSource: LazyDataSource<VideoItem> = new LazyDataSource([])
|
|
@State dataSource: LazyDataSource<VideoItem> = new LazyDataSource([])
|
|
|
@Prop selectedFiles: Array<VideoItem>
|
|
@Prop selectedFiles: Array<VideoItem>
|
|
@@ -49,7 +52,10 @@ export struct TagsContentCover {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async aboutToAppear() {
|
|
async aboutToAppear() {
|
|
|
- this.download_path = PreferencesUtil.getStringSync('download_path')
|
|
|
|
|
|
|
+ this.download_path = PreferencesUtil.getStringSync('download_path')+'批量内嵌'+'/'
|
|
|
|
|
+ if (!FileUtil.accessSync(this.download_path)) {
|
|
|
|
|
+ FileUtil.mkdirSync(this.download_path)
|
|
|
|
|
+ }
|
|
|
console.info('onecold download_path:', this.download_path)
|
|
console.info('onecold download_path:', this.download_path)
|
|
|
this.packName = AppUtil.getBundleName()
|
|
this.packName = AppUtil.getBundleName()
|
|
|
// 确保 selectedFiles 有默认值后再初始化 dataSource
|
|
// 确保 selectedFiles 有默认值后再初始化 dataSource
|
|
@@ -131,7 +137,24 @@ export struct TagsContentCover {
|
|
|
@Builder
|
|
@Builder
|
|
|
TagSetting() {
|
|
TagSetting() {
|
|
|
Column(){
|
|
Column(){
|
|
|
|
|
+ Row() {
|
|
|
|
|
+ SymbolGlyph($r('sys.symbol.night_badge_clock'))
|
|
|
|
|
+ .fontSize(20)
|
|
|
|
|
+ .fontColor([this.themeColor])
|
|
|
|
|
+ .alignSelf(ItemAlign.Center)
|
|
|
|
|
+ .margin({ left: 15 })
|
|
|
|
|
+ Text('说明:不是本app路径下的歌曲将在DownLoad/天天静听/内嵌标签文件夹中生成新的内嵌歌曲。')
|
|
|
|
|
+ .margin({ left: 5 ,right: 5})
|
|
|
|
|
+ .fontSize(14)
|
|
|
|
|
+ .padding({top:4,bottom:4})
|
|
|
|
|
+ .fontColor($r('app.color.text_color'))
|
|
|
|
|
+ .fontWeight(480)
|
|
|
|
|
+ .layoutWeight(1)
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ .height(55)
|
|
|
|
|
+ .margin({top:15,bottom:8})
|
|
|
|
|
+ .clickEffect({level:ClickEffectLevel.HEAVY,scale:0.6})
|
|
|
Row() {
|
|
Row() {
|
|
|
SymbolGlyph($r('sys.symbol.doc_text'))
|
|
SymbolGlyph($r('sys.symbol.doc_text'))
|
|
|
.fontSize(20)
|
|
.fontSize(20)
|
|
@@ -321,7 +344,7 @@ export struct TagsContentCover {
|
|
|
try {
|
|
try {
|
|
|
this.currentFileIndex = index + 1;
|
|
this.currentFileIndex = index + 1;
|
|
|
this.currentFileName = item.name;
|
|
this.currentFileName = item.name;
|
|
|
-
|
|
|
|
|
|
|
+ await PermissionUtil.activatePermission(item.filePath)
|
|
|
|
|
|
|
|
let success = true;
|
|
let success = true;
|
|
|
let tempOutPath = ''
|
|
let tempOutPath = ''
|
|
@@ -348,10 +371,9 @@ export struct TagsContentCover {
|
|
|
if (StrUtil.isNotEmpty(defaultCover)) {
|
|
if (StrUtil.isNotEmpty(defaultCover)) {
|
|
|
// 确保 filePath 存在
|
|
// 确保 filePath 存在
|
|
|
if (item.filePath) {
|
|
if (item.filePath) {
|
|
|
- await PermissionUtil.activatePermission(item.filePath)
|
|
|
|
|
// 如果不是 packName 包下的文件,则直接路径用this.download_path
|
|
// 如果不是 packName 包下的文件,则直接路径用this.download_path
|
|
|
if(!item.filePath.toLowerCase().includes(this.packName)){
|
|
if(!item.filePath.toLowerCase().includes(this.packName)){
|
|
|
- tempOutPath = item.parentPath+'/'+ item.fileName
|
|
|
|
|
|
|
+ tempOutPath = this.download_path+ item.fileName
|
|
|
}
|
|
}
|
|
|
console.info('onecold tempOutPath: ' + tempOutPath)
|
|
console.info('onecold tempOutPath: ' + tempOutPath)
|
|
|
|
|
|
|
@@ -417,7 +439,7 @@ export struct TagsContentCover {
|
|
|
const metadata: FFMpegTags = {};
|
|
const metadata: FFMpegTags = {};
|
|
|
let newInput = item.filePath
|
|
let newInput = item.filePath
|
|
|
//内嵌标签歌路径如果不是包含包名,输入newInput要赋值tempOutPath,然后tempOutPath为空
|
|
//内嵌标签歌路径如果不是包含包名,输入newInput要赋值tempOutPath,然后tempOutPath为空
|
|
|
- if(!item.filePath.toLowerCase().includes(this.packName)){
|
|
|
|
|
|
|
+ if(!item.filePath.toLowerCase().includes(this.packName)&&FileUtil.accessSync(tempOutPath)){
|
|
|
newInput = tempOutPath
|
|
newInput = tempOutPath
|
|
|
tempOutPath = ''
|
|
tempOutPath = ''
|
|
|
}
|
|
}
|
|
@@ -432,14 +454,15 @@ export struct TagsContentCover {
|
|
|
if (!result) {
|
|
if (!result) {
|
|
|
success = false;
|
|
success = false;
|
|
|
}else{
|
|
}else{
|
|
|
- // if(!item.filePath.includes(this.packName)){
|
|
|
|
|
- // //内嵌成功的歌路径如果不是包含包名,则要入库
|
|
|
|
|
- // let newItem: VideoItem = await Utility.uriGetMusicAssetsFromFile(this.context, newInput,
|
|
|
|
|
- // CommonConstants.TYPE_LOCAL, true);
|
|
|
|
|
- // this.table.insert(newItem, (id: number) => {
|
|
|
|
|
- //
|
|
|
|
|
- // });
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ if(!item.filePath.includes(this.packName)){
|
|
|
|
|
+ //内嵌成功的歌路径如果不是包含包名,则要入库
|
|
|
|
|
+ let newItem: VideoItem = await Utility.uriGetMusicAssetsFromFile(this.context, newInput,
|
|
|
|
|
+ CommonConstants.TYPE_LOCAL, true);
|
|
|
|
|
+ this.table.insert(newItem, (id: number) => {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
//内嵌成功后同步歌词到数据库
|
|
//内嵌成功后同步歌词到数据库
|
|
|
syncLyricToDB(this.context,item.filePath,lyricContent)
|
|
syncLyricToDB(this.context,item.filePath,lyricContent)
|
|
|
}
|
|
}
|