From 069997a6edbb2179d7c50291cc5b86aaf68e23e5 Mon Sep 17 00:00:00 2001 From: sharpshooter_t Date: Mon, 9 May 2022 16:29:07 +0800 Subject: [PATCH 1/4] add the multiple-audio-track playback and set cache limit interfaces Signed-off-by: sharpshooter_t Change-Id: I806b2547f8d87b07a32901414915b2633c5774e5 --- api/@ohos.multimedia.media.d.ts | 120 ++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/api/@ohos.multimedia.media.d.ts b/api/@ohos.multimedia.media.d.ts index a9af1931df..eee77d3b93 100644 --- a/api/@ohos.multimedia.media.d.ts +++ b/api/@ohos.multimedia.media.d.ts @@ -269,6 +269,66 @@ declare namespace media { */ getTrackDescription() : Promise>; + /** + * Select a media track to be played. Only the most recent one will be effective if this + * function called multiple times on same type of track. There is a audio track selected + * by defaut, even though this function is not called. + * @since NA + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @param index the index of the track to be selected. The total number of the tracks is + * the length of the {@link #getTrackDescription}'s return result array. + * @param callback async callback return the selection result, refer to {@link MediaErrorCode} + */ + selectTrack(index: number, callback: AsyncCallback): void; + + /** + * Select a media track to be played. Only the most recent one will be effective if this + * function called multiple times on same type of track. There is a audio track selected + * by defaut, even though this function is not called. + * @since NA + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @param index the index of the track to be selected. The total number of the tracks is + * the length of the {@link #getTrackDescription}'s return result array. + * @return a promise to report the selection result, refer to {@link MediaErrorCode} + */ + selectTrack(index: number): Promise; + + /** + * Get the index of tracks currently selected. For each type track, one track index will + * be returned. + * @since NA + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @return a promise to return the indexes of currently selected tracks. + */ + getSelectedTracks(): Promise>; + + /** + * Get the index of tracks currently selected. For each type track, one track index will + * be returned. + * @since NA + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @param callback async callback return the the indexes of currently selected tracks. + */ + getSelectedTracks(callback: AsyncCallback>): void + + /** + * Set the network stream playback's cache limit. + * @since NA + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @param limit the value indicates how much data need to be cached before starting playback. + * @param callback async callback to indicate this call finished. + */ + setCacheLimit(limit: number, callback: AsyncCallback): void + + /** + * Set the network stream playback's cache limit. + * @since NA + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + * @param limit the value indicates how much data need to be cached before starting playback. + * @return a promise to indicate this call finished. + */ + setCacheLimit(limit: number): Promise + /** * Listens for audio playback buffering events. * @since 8 @@ -973,6 +1033,66 @@ declare namespace media { */ getTrackDescription() : Promise>; + /** + * Select a media track to be played. Only the most recent one will be effective if this + * function called multiple times on same type of track. There are a video and audio track + * selected by defaut, even though this function is not called. + * @since NA + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param index the index of the track to be selected. The total number of the tracks is + * the length of the {@link #getTrackDescription}'s return result array. + * @param callback async callback return the selection result, refer to {@link MediaErrorCode} + */ + selectTrack(index: number, callback: AsyncCallback): void; + + /** + * Select a media track to be played. Only the most recent one will be effective if this + * function called multiple times on same type of track. There are a video and audio track + * selected by defaut, even though this function is not called. + * @since NA + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param index the index of the track to be selected. The total number of the tracks is + * the length of the {@link #getTrackDescription}'s return result array. + * @return a promise to report the selection result, refer to {@link MediaErrorCode} + */ + selectTrack(index: number): Promise; + + /** + * Get the index of tracks currently selected. For each type track, one track index will + * be returned. + * @since NA + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @return a promise to return the indexes of currently selected tracks. + */ + getSelectedTracks(): Promise>; + + /** + * Get the index of tracks currently selected. For each type track, one track index will + * be returned. + * @since NA + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param callback async callback return the the indexes of currently selected tracks. + */ + getSelectedTracks(callback: AsyncCallback>): void + + /** + * Set the network stream playback's cache limit. + * @since NA + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param limit the value indicates how much data need to be cached before starting playback. + * @param callback async callback to indicate this call finished. + */ + setCacheLimit(limit: number, callback: AsyncCallback): void + + /** + * Set the network stream playback's cache limit. + * @since NA + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + * @param limit the value indicates how much data need to be cached before starting playback. + * @return a promise to indicate this call finished. + */ + setCacheLimit(limit: number): Promise + /** * media url. Mainstream video formats are supported. * local:fd://XXX, file://XXX. network:http://xxx -- Gitee From 48c35d685b93339dc8475f6f6ebbe48b81cbc217 Mon Sep 17 00:00:00 2001 From: sharpshooter_t Date: Mon, 9 May 2022 16:59:24 +0800 Subject: [PATCH 2/4] remove the cache limit setter and add the cache limit variable Signed-off-by: sharpshooter_t Change-Id: Ie06e15e506cc7e106af0dc44b06d07f5448c77f7 --- api/@ohos.multimedia.media.d.ts | 70 ++++++++++++++++----------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/api/@ohos.multimedia.media.d.ts b/api/@ohos.multimedia.media.d.ts index eee77d3b93..c763895daf 100644 --- a/api/@ohos.multimedia.media.d.ts +++ b/api/@ohos.multimedia.media.d.ts @@ -311,24 +311,6 @@ declare namespace media { */ getSelectedTracks(callback: AsyncCallback>): void - /** - * Set the network stream playback's cache limit. - * @since NA - * @syscap SystemCapability.Multimedia.Media.AudioPlayer - * @param limit the value indicates how much data need to be cached before starting playback. - * @param callback async callback to indicate this call finished. - */ - setCacheLimit(limit: number, callback: AsyncCallback): void - - /** - * Set the network stream playback's cache limit. - * @since NA - * @syscap SystemCapability.Multimedia.Media.AudioPlayer - * @param limit the value indicates how much data need to be cached before starting playback. - * @return a promise to indicate this call finished. - */ - setCacheLimit(limit: number): Promise - /** * Listens for audio playback buffering events. * @since 8 @@ -353,6 +335,24 @@ declare namespace media { */ loop: boolean; + /** + * The network stream playback's cache limit. The value indicates how much data need to be + * cached in memory expressed in milliseconds before starting playback. For local file's + * playback, write this variable is no effect and get this variable will always return -1. + * @since NA + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + */ + cachedDurationLimit: number; + + /** + * The network stream playback's cache limit. The value indicates how much data need to be + * cached in memory expressed in bytes before starting playback. For local file's playback, + * write this variable is no effect and get this variable will always return -1. + * @since NA + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + */ + cachedSizeLimit: number; + /** * Current playback position. * @since 6 @@ -1076,37 +1076,37 @@ declare namespace media { getSelectedTracks(callback: AsyncCallback>): void /** - * Set the network stream playback's cache limit. - * @since NA + * media url. Mainstream video formats are supported. + * local:fd://XXX, file://XXX. network:http://xxx + * @since 8 * @syscap SystemCapability.Multimedia.Media.VideoPlayer - * @param limit the value indicates how much data need to be cached before starting playback. - * @param callback async callback to indicate this call finished. */ - setCacheLimit(limit: number, callback: AsyncCallback): void + url: string; /** - * Set the network stream playback's cache limit. - * @since NA + * Whether to loop video playback. The value true means to loop playback. + * @since 8 * @syscap SystemCapability.Multimedia.Media.VideoPlayer - * @param limit the value indicates how much data need to be cached before starting playback. - * @return a promise to indicate this call finished. */ - setCacheLimit(limit: number): Promise + loop: boolean; /** - * media url. Mainstream video formats are supported. - * local:fd://XXX, file://XXX. network:http://xxx - * @since 8 + * The network stream playback's cache limit. The value indicates how much data need to be + * cached in memory expressed in milliseconds before starting playback. For local file's + * playback, write this variable is no effect and get this variable will always return -1. + * @since NA * @syscap SystemCapability.Multimedia.Media.VideoPlayer */ - url: string; + cachedDurationLimit: number; /** - * Whether to loop video playback. The value true means to loop playback. - * @since 8 + * The network stream playback's cache limit. The value indicates how much data need to be + * cached in memory expressed in bytes before starting playback. For local file's playback, + * write this variable is no effect and get this variable will always return -1. + * @since NA * @syscap SystemCapability.Multimedia.Media.VideoPlayer */ - loop: boolean; + cachedSizeLimit: number; /** * Current playback position. -- Gitee From 8df9233b793d8e35de2117e7c78e8406764ed864 Mon Sep 17 00:00:00 2001 From: sharpshooter_t Date: Tue, 24 May 2022 16:50:10 +0800 Subject: [PATCH 3/4] fix the api comments Signed-off-by: sharpshooter_t Change-Id: I16f991ce596466eac16650ac39a4672857cdc0b3 --- api/@ohos.multimedia.media.d.ts | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/api/@ohos.multimedia.media.d.ts b/api/@ohos.multimedia.media.d.ts index c763895daf..74a20929f4 100644 --- a/api/@ohos.multimedia.media.d.ts +++ b/api/@ohos.multimedia.media.d.ts @@ -337,21 +337,22 @@ declare namespace media { /** * The network stream playback's cache limit. The value indicates how much data need to be - * cached in memory expressed in milliseconds before starting playback. For local file's - * playback, write this variable is no effect and get this variable will always return -1. + * cached in memory expressed in milliseconds before starting playback. Defautly, the player + * will decide cache limit by itself. For local file's playback, write this variable is no + * effect and get this variable will always return -1. * @since NA * @syscap SystemCapability.Multimedia.Media.AudioPlayer */ - cachedDurationLimit: number; + cachedDurationLimit?: number; /** * The network stream playback's cache limit. The value indicates how much data need to be - * cached in memory expressed in bytes before starting playback. For local file's playback, - * write this variable is no effect and get this variable will always return -1. - * @since NA + * cached in memory expressed in bytes before starting playback. Defautly, the player will + * decide cache limit by itself. For local file's playback, write this variable is no effect + * and get this variable will always return -1. * @syscap SystemCapability.Multimedia.Media.AudioPlayer */ - cachedSizeLimit: number; + cachedSizeLimit?: number; /** * Current playback position. @@ -1092,21 +1093,23 @@ declare namespace media { /** * The network stream playback's cache limit. The value indicates how much data need to be - * cached in memory expressed in milliseconds before starting playback. For local file's - * playback, write this variable is no effect and get this variable will always return -1. + * cached in memory expressed in milliseconds before starting playback. Defautly, the player + * will decide cache limit by itself. For local file's playback, write this variable is no + * effect and get this variable will always return -1. * @since NA * @syscap SystemCapability.Multimedia.Media.VideoPlayer */ - cachedDurationLimit: number; + cachedDurationLimit?: number; /** * The network stream playback's cache limit. The value indicates how much data need to be - * cached in memory expressed in bytes before starting playback. For local file's playback, - * write this variable is no effect and get this variable will always return -1. + * cached in memory expressed in bytes before starting playback. Defautly, the player will + * decide cache limit by itself. For local file's playback, write this variable is no effect + * and get this variable will always return -1. * @since NA * @syscap SystemCapability.Multimedia.Media.VideoPlayer */ - cachedSizeLimit: number; + cachedSizeLimit?: number; /** * Current playback position. -- Gitee From 7225017e55df11226f9a100ec2628bb8f366ab0e Mon Sep 17 00:00:00 2001 From: sharpshooter_t Date: Tue, 24 May 2022 20:29:10 +0800 Subject: [PATCH 4/4] adjust interface definitions Signed-off-by: sharpshooter_t Change-Id: I2920f73b2c49ba70e861c7b2c8fa8f0442338f99 --- api/@ohos.multimedia.media.d.ts | 80 +++++++++++++++++---------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/api/@ohos.multimedia.media.d.ts b/api/@ohos.multimedia.media.d.ts index 74a20929f4..07f30cc664 100644 --- a/api/@ohos.multimedia.media.d.ts +++ b/api/@ohos.multimedia.media.d.ts @@ -335,25 +335,6 @@ declare namespace media { */ loop: boolean; - /** - * The network stream playback's cache limit. The value indicates how much data need to be - * cached in memory expressed in milliseconds before starting playback. Defautly, the player - * will decide cache limit by itself. For local file's playback, write this variable is no - * effect and get this variable will always return -1. - * @since NA - * @syscap SystemCapability.Multimedia.Media.AudioPlayer - */ - cachedDurationLimit?: number; - - /** - * The network stream playback's cache limit. The value indicates how much data need to be - * cached in memory expressed in bytes before starting playback. Defautly, the player will - * decide cache limit by itself. For local file's playback, write this variable is no effect - * and get this variable will always return -1. - * @syscap SystemCapability.Multimedia.Media.AudioPlayer - */ - cachedSizeLimit?: number; - /** * Current playback position. * @since 6 @@ -375,6 +356,15 @@ declare namespace media { */ readonly state: AudioState; + /** + * the network stream playback's cache limit. Defautly, the player will decide cache limit by + * itself, set it to change the limit by yourself. For local file's playback, write this variable + * is no effect and get this variable will always return a object with that all property is -1. + * @since NA + * @syscap SystemCapability.Multimedia.Media.AudioPlayer + */ + cacheLimit ?: PlaybackCacheLimit; + /** * Listens for audio playback events. * @since 6 @@ -1091,26 +1081,6 @@ declare namespace media { */ loop: boolean; - /** - * The network stream playback's cache limit. The value indicates how much data need to be - * cached in memory expressed in milliseconds before starting playback. Defautly, the player - * will decide cache limit by itself. For local file's playback, write this variable is no - * effect and get this variable will always return -1. - * @since NA - * @syscap SystemCapability.Multimedia.Media.VideoPlayer - */ - cachedDurationLimit?: number; - - /** - * The network stream playback's cache limit. The value indicates how much data need to be - * cached in memory expressed in bytes before starting playback. Defautly, the player will - * decide cache limit by itself. For local file's playback, write this variable is no effect - * and get this variable will always return -1. - * @since NA - * @syscap SystemCapability.Multimedia.Media.VideoPlayer - */ - cachedSizeLimit?: number; - /** * Current playback position. * @since 8 @@ -1146,6 +1116,15 @@ declare namespace media { */ readonly height: number; + /** + * the network stream playback's cache limit. Defautly, the player will decide cache limit by + * itself, set it to change the limit by yourself. For local file's playback, write this variable + * is no effect and get this variable will always return a object with that all property is -1. + * @since NA + * @syscap SystemCapability.Multimedia.Media.VideoPlayer + */ + cacheLimit ?: PlaybackCacheLimit; + /** * set payback speed. * @since 8 @@ -1209,6 +1188,29 @@ declare namespace media { on(type: 'error', callback: ErrorCallback): void; } + /** + * The network stream playback's cache limit. + * @since NA + * @syscap SystemCapability.Multimedia.Media.Core + */ + interface PlaybackCacheLimit { + /** + * The value indicates how much data need to be cached in memory expressed in milliseconds + * before starting playback. + * @since NA + * @syscap SystemCapability.Multimedia.Media.Core + */ + durationUpperLimit?: number; + + /** + * The value indicates how much data need to be cached in memory expressed in bytes before + * starting playback. + * @since NA + * @syscap SystemCapability.Multimedia.Media.Core + */ + sizeUpperLimit?: number; + } + /** * Enumerates container format type(The abbreviation for 'container format type' is CFT). * @since 8 -- Gitee