| API in the FA Model| Corresponding d.ts File in the Stage Model| Corresponding API or Field in the Stage Model|
| API in the FA Model| Corresponding .d.ts File in the Stage Model| Corresponding API or Field in the Stage Model|
| -------- | -------- | -------- |
| [getOrCreateLocalDir(callback:AsyncCallback<string>):void;](../reference/apis/js-apis-inner-app-context.md#contextgetorcreatelocaldir7)<br>[getOrCreateLocalDir():Promise<string>;](../reference/apis/js-apis-inner-app-context.md#contextgetorcreatelocaldir7-1) | There is no corresponding API in the stage model.| Applications developed on the stage model do not have the operation permission in the application root directory. Therefore, no corresponding API is provided.|
## Can the lifecycle callback of a released FA widget be triggered when the widget is displayed in the service center so that the user login information can be obtained without opening the FA application?
Applicable to: OpenHarmony 3.2 Beta5 (API version 9)
Applicable to: OpenHarmony 3.2 Beta5 (API version 9)
**Solution**
...
...
@@ -275,7 +275,7 @@ After a widget is added, the **onCreate()** lifecycle is triggered so that relat
## How do I implement service login by touching a widget?
Applicable to: OpenHarmony 3.2 Beta5 (API version 9)
Applicable to: OpenHarmony 3.2 Beta5 (API version 9)
**Solution**
...
...
@@ -299,7 +299,7 @@ To create a service widget in the FA model, perform the following steps:
## How do I redirect to the application details page in Settings?
Applicable to: OpenHarmony 3.2 Beta5 (API version 9)
Applicable to: OpenHarmony 3.2 Beta5 (API version 9)
@@ -20,6 +20,6 @@ To enable your application to play a video in the background or when the screen
1. The application is registered with the system for unified management through the **AVSession** APIs. Otherwise, the playback will be forcibly stopped when the application switches to the background. For details, see [AVSession Development](avsession-overview.md).
2. The application must request a continuous task to prevent from being suspended. For details, see [Continuous Task Development](../task-management/continuous-task-dev-guide.md).
2. The application must request a continuous task to prevent from being suspended. For details, see [Continuous Task](../task-management/continuous-task.md).
If the playback is interrupted when the application switches to the background, you can view the log to see whether the application has requested a continuous task. If the application has requested a continuous task, there is no log recording **pause id**; otherwise, there is a log recording **pause id**.
@@ -4,7 +4,7 @@ The Audio and Video Session (AVSession) service is used to manage the playback b
Audio and video applications access the AVSession service and send application data (for example, a song that is being played and playback state) to it. Through a controller, the user can choose another application or device to continue the playback. If an application does not access the AVSession service, its playback will be forcibly interrupted when it switches to the background.
To implement background playback, you must request a continuous task to prevent the task from being suspended. For details, see [Continuous Task Development](../task-management/continuous-task-dev-guide.md).
To implement background playback, you must request a continuous task to prevent the task from being suspended. For details, see [Continuous Task](../task-management/continuous-task.md).
The AVPlayer is used to play raw media assets in an end-to-end manner. In this topic, you will learn how to use the AVPlayer to play a complete piece of music.
If you want the application to continue playing the music in the background or when the screen is off, you must use the [AVSession](avsession-overview.md) and [continuous task](../task-management/continuous-task-dev-guide.md) to prevent the playback from being forcibly interrupted by the system.
If you want the application to continue playing the music in the background or when the screen is off, you must use the [AVSession](avsession-overview.md) and [continuous task](../task-management/continuous-task.md) to prevent the playback from being forcibly interrupted by the system.
The full playback process includes creating an **AVPlayer** instance, setting the media asset to play, setting playback parameters (volume, speed, and focus mode), controlling playback (play, pause, seek, and stop), resetting the playback configuration, and releasing the instance.
...
...
@@ -23,24 +23,24 @@ Read [AVPlayer](../reference/apis/js-apis-media.md#avplayer9) for the API refere
1. Call **createAVPlayer()** to create an **AVPlayer** instance. The AVPlayer is the **idle** state.
2. Set the events to listen for, which will be used in the full-process scenario. The table below lists the supported events.
| Event Type| Description|
| Event Type| Description|
| -------- | -------- |
| stateChange | Mandatory; used to listen for changes of the **state** attribute of the AVPlayer.|
| error | Mandatory; used to listen for AVPlayer errors.|
| durationUpdate | Used to listen for progress bar updates to refresh the media asset duration.|
| timeUpdate | Used to listen for the current position of the progress bar to refresh the current time.|
| seekDone | Used to listen for the completion status of the **seek()** request.<br>This event is reported when the AVPlayer seeks to the playback position specified in **seek()**.|
| speedDone | Used to listen for the completion status of the **setSpeed()** request.<br>This event is reported when the AVPlayer plays music at the speed specified in **setSpeed()**.|
| volumeChange | Used to listen for the completion status of the **setVolume()** request.<br>This event is reported when the AVPlayer plays music at the volume specified in **setVolume()**.|
| bufferingUpdate | Used to listen for network playback buffer information. This event reports the buffer percentage and playback progress.|
| audioInterrupt | Used to listen for audio interruption. This event is used together with the **audioInterruptMode** attribute.<br>This event is reported when the current audio playback is interrupted by another (for example, when a call is coming), so the application can process the event in time.|
| stateChange | Mandatory; used to listen for changes of the **state** attribute of the AVPlayer.|
| error | Mandatory; used to listen for AVPlayer errors.|
| durationUpdate | Used to listen for progress bar updates to refresh the media asset duration.|
| timeUpdate | Used to listen for the current position of the progress bar to refresh the current time.|
| seekDone | Used to listen for the completion status of the **seek()** request.<br>This event is reported when the AVPlayer seeks to the playback position specified in **seek()**.|
| speedDone | Used to listen for the completion status of the **setSpeed()** request.<br>This event is reported when the AVPlayer plays music at the speed specified in **setSpeed()**.|
| volumeChange | Used to listen for the completion status of the **setVolume()** request.<br>This event is reported when the AVPlayer plays music at the volume specified in **setVolume()**.|
| bufferingUpdate | Used to listen for network playback buffer information. This event reports the buffer percentage and playback progress.|
| audioInterrupt | Used to listen for audio interruption. This event is used together with the **audioInterruptMode** attribute.<br>This event is reported when the current audio playback is interrupted by another (for example, when a call is coming), so the application can process the event in time.|
3. Set the media asset URL. The AVPlayer enters the **initialized** state.
> **NOTE**
>
> The URL in the code snippet below is for reference only. You need to check the media asset validity and set the URL based on service requirements.
>
> - If local files are used for playback, ensure that the files are available and the application sandbox path is used for access. For details about how to obtain the application sandbox path, see [Obtaining the Application Development Path](../application-models/application-context-stage.md#obtaining-the-application-development-path). For details about the application sandbox and how to push files to the application sandbox, see [File Management](../file-management/app-sandbox-directory.md).
> - If local files are used for playback, ensure that the files are available and the application sandbox path is used for access. For details about how to obtain the application sandbox path, see [Obtaining Application File Paths](../application-models/application-context-stage.md#obtaining-application-file-paths). For details about the application sandbox and how to push files to the application sandbox, see [File Management](../file-management/app-sandbox-directory.md).
>
> - If a network playback path is used, you must request the ohos.permission.INTERNET [permission](../security/accesstoken-guidelines.md).
>
...
...
@@ -59,7 +59,7 @@ Read [AVPlayer](../reference/apis/js-apis-media.md#avplayer9) for the API refere
## Sample Code
Refer to the sample code below to play a complete piece of music.
@@ -6,7 +6,7 @@ OpenHarmony provides two solutions for video playback development:
- <Video\> component: encapsulates basic video playback capabilities. It can be used to play video files after the data source and basic information are set. However, its scalability is poor. This component is provided by ArkUI. For details about how to use this component for video playback development, see [Video Component](../ui/arkts-common-components-video-player.md).
In this topic, you will learn how to use the AVPlayer to develop a video playback service that plays a complete video file. If you want the application to continue playing the video in the background or when the screen is off, you must use the [AVSession](avsession-overview.md) and [continuous task](../task-management/continuous-task-dev-guide.md) to prevent the playback from being forcibly interrupted by the system.
In this topic, you will learn how to use the AVPlayer to develop a video playback service that plays a complete video file. If you want the application to continue playing the video in the background or when the screen is off, you must use the [AVSession](avsession-overview.md) and [continuous task](../task-management/continuous-task.md) to prevent the playback from being forcibly interrupted by the system.
## Development Guidelines
...
...
@@ -25,28 +25,28 @@ Read [AVPlayer](../reference/apis/js-apis-media.md#avplayer9) for the API refere
1. Call **createAVPlayer()** to create an **AVPlayer** instance. The AVPlayer is the **idle** state.
2. Set the events to listen for, which will be used in the full-process scenario. The table below lists the supported events.
| Event Type| Description|
| Event Type| Description|
| -------- | -------- |
| stateChange | Mandatory; used to listen for changes of the **state** attribute of the AVPlayer.|
| error | Mandatory; used to listen for AVPlayer errors.|
| durationUpdate | Used to listen for progress bar updates to refresh the media asset duration.|
| timeUpdate | Used to listen for the current position of the progress bar to refresh the current time.|
| seekDone | Used to listen for the completion status of the **seek()** request.<br>This event is reported when the AVPlayer seeks to the playback position specified in **seek()**.|
| speedDone | Used to listen for the completion status of the **setSpeed()** request.<br>This event is reported when the AVPlayer plays video at the speed specified in **setSpeed()**.|
| volumeChange | Used to listen for the completion status of the **setVolume()** request.<br>This event is reported when the AVPlayer plays video at the volume specified in **setVolume()**.|
| bitrateDone | Used to listen for the completion status of the **setBitrate()** request, which is used for HTTP Live Streaming (HLS) streams.<br>This event is reported when the AVPlayer plays video at the bit rate specified in **setBitrate()**.|
| availableBitrates | Used to listen for available bit rates of HLS resources. The available bit rates are provided for **setBitrate()**.|
| bufferingUpdate | Used to listen for network playback buffer information.|
| startRenderFrame | Used to listen for the rendering time of the first frame during video playback.|
| videoSizeChange | Used to listen for the width and height of video playback and adjust the window size and ratio.|
| audioInterrupt | Used to listen for audio interruption. This event is used together with the **audioInterruptMode** attribute.<br>This event is reported when the current audio playback is interrupted by another (for example, when a call is coming), so the application can process the event in time.|
| stateChange | Mandatory; used to listen for changes of the **state** attribute of the AVPlayer.|
| error | Mandatory; used to listen for AVPlayer errors.|
| durationUpdate | Used to listen for progress bar updates to refresh the media asset duration.|
| timeUpdate | Used to listen for the current position of the progress bar to refresh the current time.|
| seekDone | Used to listen for the completion status of the **seek()** request.<br>This event is reported when the AVPlayer seeks to the playback position specified in **seek()**.|
| speedDone | Used to listen for the completion status of the **setSpeed()** request.<br>This event is reported when the AVPlayer plays video at the speed specified in **setSpeed()**.|
| volumeChange | Used to listen for the completion status of the **setVolume()** request.<br>This event is reported when the AVPlayer plays video at the volume specified in **setVolume()**.|
| bitrateDone | Used to listen for the completion status of the **setBitrate()** request, which is used for HTTP Live Streaming (HLS) streams.<br>This event is reported when the AVPlayer plays video at the bit rate specified in **setBitrate()**.|
| availableBitrates | Used to listen for available bit rates of HLS resources. The available bit rates are provided for **setBitrate()**.|
| bufferingUpdate | Used to listen for network playback buffer information.|
| startRenderFrame | Used to listen for the rendering time of the first frame during video playback.|
| videoSizeChange | Used to listen for the width and height of video playback and adjust the window size and ratio.|
| audioInterrupt | Used to listen for audio interruption. This event is used together with the **audioInterruptMode** attribute.<br>This event is reported when the current audio playback is interrupted by another (for example, when a call is coming), so the application can process the event in time.|
3. Set the media asset URL. The AVPlayer enters the **initialized** state.
> **NOTE**
>
> The URL in the code snippet below is for reference only. You need to check the media asset validity and set the URL based on service requirements.
>
> - If local files are used for playback, ensure that the files are available and the application sandbox path is used for access. For details about how to obtain the application sandbox path, see [Obtaining the Application Development Path](../application-models/application-context-stage.md#obtaining-the-application-development-path). For details about the application sandbox and how to push files to the application sandbox, see [File Management](../file-management/app-sandbox-directory.md).
> - If local files are used for playback, ensure that the files are available and the application sandbox path is used for access. For details about how to obtain the application sandbox path, see [Obtaining Application File Paths](../application-models/application-context-stage.md#obtaining-application-file-paths). For details about the application sandbox and how to push files to the application sandbox, see [File Management](../file-management/app-sandbox-directory.md).
>
> - If a network playback path is used, you must request the ohos.permission.INTERNET [permission](../security/accesstoken-guidelines.md).
>
...
...
@@ -68,7 +68,7 @@ Read [AVPlayer](../reference/apis/js-apis-media.md#avplayer9) for the API refere
@@ -8,6 +8,7 @@ The system schedules and executes deferred tasks at an appropriate time, subject
>
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module can be used only in the stage model.
> - For details about the constraints on deferred task scheduling, see [Constraints](../../task-management/work-scheduler.md#constraints).
## Modules to Import
...
...
@@ -79,7 +80,7 @@ Instructs the WorkSchedulerService to stop a task.
| work | [WorkInfo](#workinfo) | Yes | Task to stop. |
| needCancel | boolean | No | Whether to cancel the task.|
| needCancel | boolean | No | Whether to cancel the task.|
**Error codes**
...
...
@@ -410,7 +411,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes
```
## WorkInfo
Provides detailed information about the task.
Provides detailed information about the task. For details about the constraints on setting the **WorkInfo** parameter, see [Constraints](../../task-management/work-scheduler.md#constraints).