|
|
@@ -17,6 +17,7 @@ import { BusinessError } from '@kit.BasicServicesKit';
|
|
|
import { http } from '@kit.NetworkKit';
|
|
|
import json from '@ohos.util.json';
|
|
|
import MediaTable from '../util/MediaTable';
|
|
|
+import { Utility } from '../util/Utility';
|
|
|
|
|
|
/**
|
|
|
* 服务就绪状态详情接口
|
|
|
@@ -318,6 +319,7 @@ interface widgeData {
|
|
|
filePath: string;
|
|
|
imgName: string;
|
|
|
imageColorHex: string;
|
|
|
+ isFavorite: boolean;
|
|
|
|
|
|
// PlayerState数据平铺
|
|
|
isPlaying: boolean;
|
|
|
@@ -578,6 +580,23 @@ export class UnifiedPlayerService implements IPlayerService, PlaylistSyncListene
|
|
|
// 同步更新所有桌面卡片状态
|
|
|
this.updateAllForms();
|
|
|
}
|
|
|
+ public toggleFavorite() {
|
|
|
+
|
|
|
+ let isFav = 0
|
|
|
+ let item=this.getCurrentSong() as VideoItem;
|
|
|
+ if (Utility.getIsFav(this.getFav(), item)) {
|
|
|
+ isFav = 0
|
|
|
+ } else {
|
|
|
+ isFav = 1
|
|
|
+ }
|
|
|
+ this.getTable().updateIsFavByFilePath(item.filePath, isFav, async (result: boolean) => {
|
|
|
+ if (result) {
|
|
|
+ // 刷新UnifiedPlayerService的收藏状态,这会自动更新AVSession
|
|
|
+ console.log("Heanup2 UnifiedPlayerService toggleFavorite: 收藏状态切换");
|
|
|
+ await this.refreshFavoriteStatus();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 从暂停状态恢复播放
|
|
|
@@ -1039,6 +1058,7 @@ export class UnifiedPlayerService implements IPlayerService, PlaylistSyncListene
|
|
|
// 更新收藏列表后,立即更新AVSession状态以反映正确的收藏状态
|
|
|
setTimeout(() => {
|
|
|
this.updateSessionPlayState();
|
|
|
+ this.updateAllForms();
|
|
|
}, 100);
|
|
|
|
|
|
resolve();
|
|
|
@@ -2817,7 +2837,7 @@ export class UnifiedPlayerService implements IPlayerService, PlaylistSyncListene
|
|
|
pixelMapPath: formData.pixelMapPath || '',
|
|
|
duration: typeof formData.duration === 'string' ? parseInt(formData.duration || '0') : (formData.duration || 0),
|
|
|
filePath: formData.filePath || '',
|
|
|
- imgName: imgName, // 使用生成的唯一图片名称
|
|
|
+ imgName: imgName,
|
|
|
imageColorHex: '2A2A2A',
|
|
|
|
|
|
// PlayerState数据平铺
|
|
|
@@ -2844,7 +2864,8 @@ export class UnifiedPlayerService implements IPlayerService, PlaylistSyncListene
|
|
|
timeInfo: widgetTimeInfo,
|
|
|
|
|
|
// 卡片图片显示必填字段
|
|
|
- formImages: imgMap
|
|
|
+ formImages: imgMap,
|
|
|
+ isFavorite: this.getCurrentSongFavoriteState() ,
|
|
|
};
|
|
|
|
|
|
// 记录更新统计
|
|
|
@@ -2858,7 +2879,7 @@ export class UnifiedPlayerService implements IPlayerService, PlaylistSyncListene
|
|
|
const formBindingDataInstance = formBindingData.createFormBindingData(flatWidgetData);
|
|
|
await formProvider.updateForm(formId, formBindingDataInstance);
|
|
|
successCount++;
|
|
|
- LogUtils.getInstance().LOGI(`UnifiedPlayerService updateAllForms: Updated form ${formId} - isPlaying=${flatWidgetData.isPlaying}, hasNext=${flatWidgetData.hasNext}, hasPrevious=${flatWidgetData.hasPrevious}`);
|
|
|
+ LogUtils.getInstance().LOGI(`UnifiedPlayerService updateAllForms: Updated form ${formId} -isFavorite=${flatWidgetData.isFavorite}, - isPlaying=${flatWidgetData.isPlaying}, hasNext=${flatWidgetData.hasNext}, hasPrevious=${flatWidgetData.hasPrevious}`);
|
|
|
} catch (error) {
|
|
|
failedCount++;
|
|
|
const errorStr: string = error?.toString() || '';
|