@@ -16,38 +16,49 @@ You can use audio playback APIs to convert audio data into audible analog signal
## How to Develop
For details about the APIs used for audio playback, see [AudioPlayer in the Media API](../reference/apis/js-apis-media.md).
For details about the APIs, see [AudioPlayer in the Media API](../reference/apis/js-apis-media.md).
### Full-Process Scenario
The full audio playback process includes creating an instance, setting the URI, playing audio, seeking to the playback position, setting the volume, pausing playback, obtaining track information, stopping playback, resetting the player, and releasing resources.
For details about the **src**media source input types supported by **AudioPlayer**, see the [src attribute](../reference/apis/js-apis-media.md#audioplayer_attributes).
For details about the **src** types supported by **AudioPlayer**, see the [src attribute](../reference/apis/js-apis-media.md#audioplayer_attributes).
```js
importmediafrom'@ohos.multimedia.media'
importfileIOfrom'@ohos.fileio'
functionSetCallBack(audioPlayer){
// Print the stream track information.
functionprintfDescription(obj){
for(letiteminobj){
letproperty=obj[item];
console.info('audio key is '+item);
console.info('audio value is '+property);
}
}
// Set the player callbacks.
functionsetCallBack(audioPlayer){
audioPlayer.on('dataLoad',()=>{// Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully.
console.info('audio set source success');
// The playback page is ready. You can click the Play button to start the playback.
audioPlayer.play();// The play() API can be invoked only after the 'dataLoad' event callback is complete. The 'play' event callback is then triggered.
});
audioPlayer.on('play',()=>{// Set the 'play' event callback.
console.info('audio play success');
// The Play button is changed to the pausable state.
audioPlayer.pause();// Trigger the 'pause' event callback and pause the playback.
});
audioPlayer.on('pause',()=>{// Set the 'pause' event callback.
console.info('audio pause success');
// The Play button is changed to the playable state.
audioPlayer.seek(5000);// Trigger the 'timeUpdate' event callback, and seek to 5000 ms for playback.
});
audioPlayer.on('stop',()=>{// Set the 'stop' event callback.
console.info('audio stop success');
// The playback stops, the playback progress bar returns to 0, and the Play button is changed to the playable state.
audioPlayer.reset();// Trigger the 'reset' event callback, and reconfigure the src attribute to switch to the next song.
});
audioPlayer.on('reset',()=>{// Set the 'reset' event callback.
console.info('audio reset success');
// You can reconfigure the src attribute to play another audio file.
audioPlayer.release();// Release the AudioPlayer resources.
audioPlayer=undefined;
});
audioPlayer.on('timeUpdate',(seekDoneTime)=>{// Set the 'timeUpdate' event callback.
if(typeof(seekDoneTime)=='undefined'){
...
...
@@ -55,71 +66,49 @@ function SetCallBack(audioPlayer) {
return;
}
console.info('audio seek success, and seek time is '+seekDoneTime);
// The playback progress bar is updated to the seek position.
audioPlayer.setVolume(0.5);// Trigger the 'volumeChange' event callback.
});
audioPlayer.on('volumeChange',()=>{// Set the 'volumeChange' event callback.
console.info('audio volumeChange success');
// Display the updated volume.
audioPlayer.getTrackDescription((error,arrlist)=>{// Obtain the audio track information in callback mode.
audioPlayer.stop();// Trigger the 'stop' event callback to stop the playback.
});
});
audioPlayer.on('finish',()=>{// Set the 'finish' event callback, which is triggered when the playback is complete.
audioPlayer.on('finish',()=>{// Set the 'finish' event callback, which is triggered when the playback is complete.
console.info('audio play finish');
});
audioPlayer.on('error',(error)=>{// Set the 'error' event callback.
audioPlayer.on('error',(error)=>{// Set the 'error' event callback.
console.info(`audio error called, errName is ${error.name}`);
console.info(`audio error called, errCode is ${error.code}`);
console.info(`audio error called, errMessage is ${error.message}`);
});
}
functionprintfDescription(obj){
for(letiteminobj){
letproperty=obj[item];
console.info('audio key is '+item);
console.info('audio value is '+property);
}
asyncfunctionaudioPlayerDemo(){
// 1. Create an audioPlayer instance.
letaudioPlayer=media.createAudioPlayer();
setCallBack(audioPlayer);// Set the event callbacks.
// 2. Set the URI of the audio file selected by the user.
letfdPath='fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
audioPlayer.stop();// Trigger the 'stop' event callback.
// 9. Reset the player.
audioPlayer.reset();// Trigger the 'reset' event callback, and reconfigure the src attribute to switch to the next song.
// 10. Release the resource.
audioPlayer.release();// Release the AudioPlayer instance.
audioPlayer=undefined;
```
### Normal Playback Scenario
...
...
@@ -127,37 +116,40 @@ audioPlayer = undefined;
```js
importmediafrom'@ohos.multimedia.media'
importfileIOfrom'@ohos.fileio'
functionSetCallBack(audioPlayer){
exportclassAudioDemo{
// Set the player callbacks.
setCallBack(audioPlayer){
audioPlayer.on('dataLoad',()=>{// Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully.
console.info('audio set source success');
audioPlayer.play();// Call the play() API to start the playback and trigger the 'play' event callback.
console.info('audio set source success');
audioPlayer.play();// Call the play() API to start the playback and trigger the 'play' event callback.
});
audioPlayer.on('play',()=>{// Set the 'play' event callback.
console.info('audio play success');
console.info('audio play success');
});
audioPlayer.on('finish',()=>{// Set the 'finish' event callback, which is triggered when the playback is complete.
console.info('audio play finish');
audioPlayer.release();// Release the AudioPlayer instance.
audioPlayer=undefined;
console.info('audio play finish');
audioPlayer.release();// Release the AudioPlayer resources.
audioPlayer=undefined;
});
}
asyncaudioPlayerDemo(){
letaudioPlayer=media.createAudioPlayer();// Create an AudioPlayer instance.
this.setCallBack(audioPlayer);// Set the event callbacks.
letfdPath='fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
audioPlayer.src=fdPath;// Set the src attribute and trigger the 'dataLoad' event callback.
```
### Switching to the Next Song
...
...
@@ -165,52 +157,62 @@ audioPlayer.src = fdPath; // Set the src attribute and
```js
importmediafrom'@ohos.multimedia.media'
importfileIOfrom'@ohos.fileio'
functionSetCallBack(audioPlayer){
exportclassAudioDemo{
// Set the player callbacks.
privateisNextMusic=false;
setCallBack(audioPlayer){
audioPlayer.on('dataLoad',()=>{// Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully.
console.info('audio set source success');
audioPlayer.play();// Call the play() API to start the playback and trigger the 'play' event callback.
console.info('audio set source success');
audioPlayer.play();// Call the play() API to start the playback and trigger the 'play' event callback.
});
audioPlayer.on('play',()=>{// Set the 'play' event callback.
console.info('audio play success');
console.info('audio play success');
audioPlayer.reset();// Call the reset() API and trigger the 'reset' event callback.
});
audioPlayer.on('finish',()=>{// Set the 'finish' event callback, which is triggered when the playback is complete.
console.info('audio play finish');
audioPlayer.on('reset',()=>{// Set the 'reset' event callback.
console.info('audio play success');
if(!this.isNextMusic){// When isNextMusic is false, changing songs is implemented.
this.nextMusic(audioPlayer);// Changing songs is implemented.
}else{
audioPlayer.release();// Release the AudioPlayer instance.
audioPlayer=undefined;
audioPlayer=undefined;
}
});
}
asyncnextMusic(audioPlayer){
this.isNextMusic=true;
letnextFdPath='fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\02.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
audioPlayer.src=nextFdPath;// Set the src attribute and trigger the 'dataLoad' event callback.
}
asyncaudioPlayerDemo(){
letaudioPlayer=media.createAudioPlayer();// Create an AudioPlayer instance.
this.setCallBack(audioPlayer);// Set the event callbacks.
letfdPath='fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
audioPlayer.on('dataLoad',()=>{// Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully.
console.info('audio set source success');
audioPlayer.play();// Call the play() API to start the playback and trigger the 'play' event callback.
console.info('audio set source success');
audioPlayer.loop=true;// Set the loop playback attribute.
audioPlayer.play();// Call the play() API to start the playback and trigger the 'play' event callback.
});
audioPlayer.on('play',()=>{// Set the 'play' event callback.
console.info('audio play success');
audioPlayer.on('play',()=>{// Sets the 'play' event callback to start loop playback.
console.info('audio play success');
});
audioPlayer.on('finish',()=>{// Set the 'finish' event callback, which is triggered when the playback is complete.
console.info('audio play finish');
audioPlayer.release();// Release the AudioPlayer instance.
audioPlayer=undefined;
}
asyncaudioPlayerDemo(){
letaudioPlayer=media.createAudioPlayer();// Create an AudioPlayer instance.
this.setCallBack(audioPlayer);// Set the event callbacks.
letfdPath='fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
audioPlayer.src=fdPath;// Set the src attribute and trigger the 'dataLoad' event callback.
audioPlayer.loop=true;// Set the loop playback attribute.
```
## Samples
The following samples are provided to help you better understand how to develop audio playback:
-[`JsDistributedMusicPlayer`: Distributed Music Player (JS) (API7)](https://gitee.com/openharmony/app_samples/tree/master/ability/JsDistributedMusicPlayer)
-[`JsAudioPlayer`: Audio Playback and Management (JS, API 7)](https://gitee.com/openharmony/app_samples/tree/master/media/JsAudioPlayer)
-[`eTsAudioPlayer`: Audio Player (eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets)
audioRecorder.on('prepare',()=>{// Set the 'prepare' event callback.
console.log('prepare success');
// The recording page is ready. You can click the Record button to start recording.
exportclassAudioRecorderDemo{
privatetestFdNumber;// Used to save the FD address.
// Set the callbacks related to audio recording.
setCallBack(audioRecorder){
audioRecorder.on('prepare',()=>{// Set the 'prepare' event callback.
console.log('prepare success');
audioRecorder.start();// Call the start API to start recording and trigger the 'start' event callback.
});
audioRecorder.on('start',()=>{// Set the 'start' event callback.
console.log('audio recorder start success');
// The Record button is changed to the pausable state.
audioRecorder.on('start',()=>{// Set the 'start' event callback.
console.log('audio recorder start success');
audioRecorder.pause();// Call the pause API to pause recording and trigger the 'pause' event callback.
});
audioRecorder.on('pause',()=>{// Set the 'pause' event callback.
console.log('audio recorder pause success');
// The Record button is changed to the recordable state.
audioRecorder.on('pause',()=>{// Set the 'pause' event callback.
console.log('audio recorder pause success');
audioRecorder.resume();// Call the resume API to resume recording and trigger the 'resume' event callback.
});
audioRecorder.on('resume',()=>{// Set the 'resume' event callback.
console.log('audio recorder resume success');
// The Record button is changed to the pausable state.
audioRecorder.on('resume',()=>{// Set the 'resume' event callback.
console.log('audio recorder resume success');
audioRecorder.stop();// Call the stop API to stop recording and trigger the 'stop' event callback.
});
audioRecorder.on('stop',()=>{// Set the 'stop' event callback.
console.log('audio recorder stop success');
audioRecorder.on('stop',()=>{// Set the 'stop' event callback.
console.log('audio recorder stop success');
audioRecorder.reset();// Call the reset API to reset the recorder and trigger the 'reset' event callback.
});
audioRecorder.on('release',()=>{// Set the 'release' event callback.
console.log('audio recorder release success');
audioRecorder.on('reset',()=>{// Set the 'reset' event callback.
console.log('audio recorder reset success');
audioRecorder.release();// Call the release API to release resources and trigger the 'release' event callback.
});
audioRecorder.on('reset',()=>{// Set the 'reset' event callback.
console.log('audio recorder reset success');
// You need to reset the recording parameters for another recording.
audioRecorder.on('release',()=>{// Set the 'release' event callback.
console.log('audio recorder release success');
audioRecorder=undefined;
});
audioRecorder.on('error',(error)=>{// Set the 'error' event callback.
console.info(`audio error called, errName is ${error.name}`);
console.info(`audio error called, errCode is ${error.code}`);
console.info(`audio error called, errMessage is ${error.message}`);
audioRecorder.on('error',(error)=>{// Set the 'error' event callback.
console.info(`audio error called, errName is ${error.name}`);
console.info(`audio error called, errCode is ${error.code}`);
console.info(`audio error called, errMessage is ${error.message}`);
});
}
}
// pathName indicates the passed recording file name, for example, 01.mp3. The generated file address is /storage/media/100/local/files/Movies/01.mp3.
// To use the media library, declare the following permissions: ohos.permission.MEDIA_LOCATION, ohos.permission.WRITE_MEDIA, and ohos.permission.READ_MEDIA.
asyncfunctiongetFd(pathName){
// pathName indicates the passed recording file name, for example, 01.mp3. The generated file address is /storage/media/100/local/files/Video/01.mp3.
// To use the media library, declare the following permissions: ohos.permission.MEDIA_LOCATION, ohos.permission.WRITE_MEDIA, and ohos.permission.READ_MEDIA.
asyncgetFd(pathName){
letdisplayName=pathName;
constmediaTest=mediaLibrary.getMediaLibrary();
letfileKeyObj=mediaLibrary.FileKey;
...
...
@@ -72,49 +75,37 @@ async function getFd(pathName) {
audioRecorder.on('prepare',()=>{// Set the 'prepare' event callback.
console.log('prepare success');
// The recording page is ready. You can click the Record button to start recording.
exportclassAudioRecorderDemo{
privatetestFdNumber;// Used to save the FD address.
// Set the callbacks related to audio recording.
setCallBack(audioRecorder){
audioRecorder.on('prepare',()=>{// Set the 'prepare' event callback.
console.log('prepare success');
audioRecorder.start();// Call the start API to start recording and trigger the 'start' event callback.
});
audioRecorder.on('start',()=>{// Set the 'start' event callback.
console.log('audio recorder start success');
// The Record button is changed to the pausable state.
});
audioRecorder.on('stop',()=>{// Set the 'stop' event callback.
console.log('audio recorder stop success');
});
audioRecorder.on('release',()=>{// Set the 'release' event callback.
console.log('audio recorder release success');
});
}
audioRecorder.on('start',()=>{// Set the 'start' event callback.
console.log('audio recorder start success');
audioRecorder.stop();// Call the stop API to stop recording and trigger the 'stop' event callback.
});
audioRecorder.on('stop',()=>{// Set the 'stop' event callback.
console.log('audio recorder stop success');
audioRecorder.release();// Call the release API to release resources and trigger the 'release' event callback.
});
audioRecorder.on('release',()=>{// Set the 'release' event callback.
console.log('audio recorder release success');
audioRecorder=undefined;
});
audioRecorder.on('error',(error)=>{// Set the 'error' event callback.
console.info(`audio error called, errName is ${error.name}`);
console.info(`audio error called, errCode is ${error.code}`);
console.info(`audio error called, errMessage is ${error.message}`);
});
}
// pathName indicates the passed recording file name, for example, 01.mp3. The generated file address is /storage/media/100/local/files/Movies/01.mp3.
// To use the media library, declare the following permissions: ohos.permission.MEDIA_LOCATION, ohos.permission.WRITE_MEDIA, and ohos.permission.READ_MEDIA.
asyncfunctiongetFd(pathName){
// pathName indicates the passed recording file name, for example, 01.mp3. The generated file address is /storage/media/100/local/files/Video/01.mp3.
// To use the media library, declare the following permissions: ohos.permission.MEDIA_LOCATION, ohos.permission.WRITE_MEDIA, and ohos.permission.READ_MEDIA.
asyncgetFd(pathName){
letdisplayName=pathName;
constmediaTest=mediaLibrary.getMediaLibrary();
letfileKeyObj=mediaLibrary.FileKey;
...
...
@@ -154,41 +153,43 @@ async function getFd(pathName) {
awaitthis.getFd('01.mp3');// Call the getFd method to obtain the FD address of the file to be recorded.
// 3. Set the recording parameters.
letaudioRecorderConfig={
audioEncodeBitRate:22050,
audioSampleRate:22050,
numberOfChannels:2,
uri:this.testFdNumber,// testFdNumber is generated by getFd.
location:{latitude:30,longitude:130},
audioEncoderMime:media.CodecMimeType.AUDIO_AAC,
fileFormat:media.ContainerFormatType.CFT_MPEG_4A,
}
audioRecorder.prepare(audioRecorderConfig);// Call the prepare method to trigger the 'prepare' event callback.
}
}
awaitgetFd('01.mp3');
// 1. Create an AudioRecorder instance.
letaudioRecorder=media.createAudioRecorder();
// 2. Set the callbacks.
SetCallBack(audioRecorder);
// 3. Set the recording parameters.
letaudioRecorderConfig={
audioEncoder:media.AudioEncoder.AAC_LC,
audioEncodeBitRate:22050,
audioSampleRate:22050,
numberOfChannels:2,
format:media.AudioOutputFormat.AAC_ADTS,
uri:testFdNumber,// testFdNumber is generated by getFd.
location:{latitude:30,longitude:130},
}
audioRecorder.prepare(audioRecorderConfig)
// 4. Start recording.
audioRecorder.start();// The start API can be called to trigger the 'start' event callback only after the 'prepare' event callback is complete.
// 5. Stop recording.
audioRecorder.stop();// The stop API can be called to trigger the 'stop' event callback only after the 'start' or 'resume' event callback is complete.
// 6. Release resources.
audioRecorder.release();// The AudioRecorder resource is destroyed.
audioRecorder=undefined;
```
## Samples
The following samples are provided to help you better understand how to develop audio recording:
-[`Recorder`: Recorder (eTS, API 8)](https://gitee.com/openharmony/app_samples/tree/master/media/Recorder)
-[`eTsAudioPlayer`: Audio Player (eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets)
You can use video playback APIs to convert video data into visible signals, play the signals using output devices, and manage playback tasks. This document describes the following video playback development scenarios: full-process, normal playback, video switching, and loop playback.
You can use video playback APIs to convert video data into visible signals, play the signals using output devices, and manage playback tasks. This document describes development for the following video playback scenarios: full-process, normal playback, video switching, and loop playback.
**Figure 1** Video playback state transition
...
...
@@ -16,17 +16,17 @@ You can use video playback APIs to convert video data into visible signals, play
Note: Video playback requires hardware capabilities such as display, audio, and codec.
1. A third-party application obtains a surface ID from the Xcomponent.
1. A third-party application obtains a surface ID from the XComponent.
2. The third-party application transfers the surface ID to the VideoPlayer JS.
3. The media service flushes the frame data to the surface buffer.
## Compatibility
You are advised to use the mainstream playback formats and resolutions, rather than custom or abnormal streams to avoid playback failure, frame freezing, and artifacts. The system is not affected by incompatibility issues. If such an error occurs, you can exit stream playback mode.
Use the mainstream playback formats and resolutions, rather than custom ones to avoid playback failures, frame freezing, and artifacts. The system is not affected by incompatibility issues. If such an issue occurs, you can exit stream playback mode.
The table below lists the mainstream playback formats and resolutions.
| Video Container Specification| Specification Description | Resolution |
| Video Container Format| Description | Resolution |
| mp4 | Video format: H.264/MPEG-2/MPEG-4/H.263; audio format: AAC/MP3| Mainstream resolutions, such as 1080p, 720p, 480p, and 270p|
| mkv | Video format: H.264/MPEG-2/MPEG-4/H.263; audio format: AAC/MP3| Mainstream resolutions, such as 1080p, 720p, 480p, and 270p|
...
...
@@ -41,140 +41,137 @@ For details about the APIs, see [VideoPlayer in the Media API](../reference/apis
The full video playback process includes creating an instance, setting the URL, setting the surface ID, preparing for video playback, playing video, pausing playback, obtaining track information, seeking to a playback position, setting the volume, setting the playback speed, stopping playback, resetting the playback configuration, and releasing resources.
For details about the **url**media source input types supported by **VideoPlayer**, see the [url attribute](../reference/apis/js-apis-media.md#videoplayer_attributes).
For details about the **url** types supported by **VideoPlayer**, see the [url attribute](../reference/apis/js-apis-media.md#videoplayer_attributes).
For details about how to create an Xcomponent, see [Xcomponent Creation](#Xcomponent).
For details about how to create an XComponent, see [XComponent](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md).
*Note: **setSurface** must be called after the URL is set but before **prepare** is called.
```js
importmediafrom'@ohos.multimedia.media'
importfileIOfrom'@ohos.fileio'
letvideoPlayer=undefined;// Used to store instances created by calling the createVideoPlayer API.
letsurfaceID=undefined;// Used to save the surface ID returned by the Xcomponent interface.
// The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the Xcomponent is loaded.
// Report an error in the case of a function invocation failure.
functionfailureCallback(error){
exportclassVideoPlayerDemo{
// Report an error in the case of a function invocation failure.
failureCallback(error){
console.info(`error happened,error Name is ${error.name}`);
console.info(`error happened,error Code is ${error.code}`);
console.info(`error happened,error Message is ${error.message}`);
}
}
// Report an error in the case of a function invocation exception.
functioncatchCallback(error){
// Report an error in the case of a function invocation exception.
catchCallback(error){
console.info(`catch error happened,error Name is ${error.name}`);
console.info(`catch error happened,error Code is ${error.code}`);
console.info(`catch error happened,error Message is ${error.message}`);
}
}
// Used to print the video track information.
functionprintfDescription(obj){
// Used to print the video track information.
printfDescription(obj){
for(letiteminobj){
letproperty=obj[item];
console.info('key is '+item);
console.info('value is '+property);
letproperty=obj[item];
console.info('key is '+item);
console.info('value is '+property);
}
}
// Call createVideoPlayer to create a VideoPlayer instance.
awaitmedia.createVideoPlayer().then((video)=>{
if(typeof(video)!='undefined'){
}
asyncvideoPlayerDemo(){
letvideoPlayer=undefined;
letsurfaceID='test'// The surfaceID parameter is used for screen display. Its value is obtained through the XComponent interface. For details about the document link, see the method of creating the XComponent.
letfdPath='fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command.
letvideoPlayer=undefined;// Used to store instances created by calling the createVideoPlayer API.
letsurfaceID=undefined;// Used to save the surface ID returned by the Xcomponent interface.
// The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the Xcomponent is loaded.
// Report an error in the case of a function invocation failure.
functionfailureCallback(error){
exportclassVideoPlayerDemo{
// Report an error in the case of a function invocation failure.
failureCallback(error){
console.info(`error happened,error Name is ${error.name}`);
console.info(`error happened,error Code is ${error.code}`);
console.info(`error happened,error Message is ${error.message}`);
}
}
// Report an error in the case of a function invocation exception.
functioncatchCallback(error){
// Report an error in the case of a function invocation exception.
catchCallback(error){
console.info(`catch error happened,error Name is ${error.name}`);
console.info(`catch error happened,error Code is ${error.code}`);
console.info(`catch error happened,error Message is ${error.message}`);
}
}
// Set the 'playbackCompleted' event callback, which is triggered when the playback is complete.
functionSetCallBack(videoPlayer){
videoPlayer.on('playbackCompleted',()=>{
console.info('video play finish');
awaitvideoPlayer.release().then(()=>{
console.info('release success');
},failureCallback).catch(catchCallback);
videoPlayer=undefined;
surfaceID=undefined;
// Used to print the video track information.
printfDescription(obj){
for(letiteminobj){
letproperty=obj[item];
console.info('key is '+item);
console.info('value is '+property);
}
}
asyncvideoPlayerDemo(){
letvideoPlayer=undefined;
letsurfaceID='test'// The surfaceID parameter is used for screen display. Its value is obtained through the XComponent interface. For details about the document link, see the method of creating the XComponent.
letfdPath='fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command.
letvideoPlayer=undefined;// Used to store instances created by calling the createVideoPlayer API.
letsurfaceID=undefined;// Used to save the surface ID returned by the Xcomponent interface.
// The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the Xcomponent is loaded.
// Report an error in the case of a function invocation failure.
functionfailureCallback(error){
exportclassVideoPlayerDemo{
// Report an error in the case of a function invocation failure.
failureCallback(error){
console.info(`error happened,error Name is ${error.name}`);
console.info(`error happened,error Code is ${error.code}`);
console.info(`error happened,error Message is ${error.message}`);
}
}
// Report an error in the case of a function invocation exception.
functioncatchCallback(error){
// Report an error in the case of a function invocation exception.
catchCallback(error){
console.info(`catch error happened,error Name is ${error.name}`);
console.info(`catch error happened,error Code is ${error.code}`);
console.info(`catch error happened,error Message is ${error.message}`);
}
}
// Set the 'playbackCompleted' event callback, which is triggered when the playback is complete.
functionSetCallBack(videoPlayer){
videoPlayer.on('playbackCompleted',()=>{
console.info('video play finish');
awaitvideoPlayer.release().then(()=>{
console.info('release success');
},failureCallback).catch(catchCallback);
videoPlayer=undefined;
surfaceID=undefined;
// Used to print the video track information.
printfDescription(obj){
for(letiteminobj){
letproperty=obj[item];
console.info('key is '+item);
console.info('value is '+property);
}
}
asyncvideoPlayerDemo(){
letvideoPlayer=undefined;
letsurfaceID='test'// The surfaceID parameter is used for screen display. Its value is obtained through the XComponent interface. For details about the document link, see the method of creating the XComponent.
letfdPath='fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command.
letvideoPlayer=undefined;// Used to store instances created by calling the createVideoPlayer API.
letsurfaceID=undefined;// Used to save the surface ID returned by the Xcomponent interface.
// The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the Xcomponent is loaded.
// Report an error in the case of a function invocation failure.
functionfailureCallback(error){
exportclassVideoPlayerDemo{
// Report an error in the case of a function invocation failure.
failureCallback(error){
console.info(`error happened,error Name is ${error.name}`);
console.info(`error happened,error Code is ${error.code}`);
console.info(`error happened,error Message is ${error.message}`);
}
}
// Report an error in the case of a function invocation exception.
functioncatchCallback(error){
// Report an error in the case of a function invocation exception.
catchCallback(error){
console.info(`catch error happened,error Name is ${error.name}`);
console.info(`catch error happened,error Code is ${error.code}`);
console.info(`catch error happened,error Message is ${error.message}`);
}
}
// Set the 'playbackCompleted' event callback, which is triggered when the playback is complete.
functionSetCallBack(videoPlayer){
videoPlayer.on('playbackCompleted',()=>{
console.info('video play finish');
awaitvideoPlayer.release().then(()=>{
console.info('release success');
},failureCallback).catch(catchCallback);
videoPlayer=undefined;
surfaceID=undefined;
// Used to print the video track information.
printfDescription(obj){
for(letiteminobj){
letproperty=obj[item];
console.info('key is '+item);
console.info('value is '+property);
}
}
sleep(time){
for(lett=Date.now();Date.now()-t<=time;);
}
asyncvideoPlayerDemo(){
letvideoPlayer=undefined;
letsurfaceID='test'// The surfaceID parameter is used for screen display. Its value is obtained through the XComponent interface. For details about the document link, see the method of creating the XComponent.
letfdPath='fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command.
// Call the prepare interface to prepare for playback.
awaitvideoPlayer.prepare().then(()=>{
console.info('prepare success');
},failureCallback).catch(catchCallback);
// Set the loop playback attribute.
videoPlayer.loop=true;
// Call the play interface to start playback.
awaitvideoPlayer.play().then(()=>{
console.info('play success');
},failureCallback).catch(catchCallback);
```
### Xcomponent Creation
The Xcomponent is used to obtain the surface ID during video playback. You need to create an xxx.hml file and add the following code to the xxx.hml file, where xxx is the same as that in the xxx.js file:
```js
<xcomponentid='Xcomponent'
if="{{isFlush}}"// Refresh the surface ID. To enable automatic loading of the Xcomponent and obtain the new surface ID, assign **false** to **isFlush** and then assign **true** to **isFlush**.
type='surface'
onload='LoadXcomponent'// Default interface for loading the Xcomponent.
style="width:720px;height:480px;border-color:red;border-width:5px;">// Set the window width, height, and other attributes.
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> API version 9 is a canary release for trial use. The APIs of this version may be unstable.
This module provides the following common audio-related functions:
-[AudioManager](#audiomanager): Audio management.
-[AudioRenderer](#audiorenderer8): Audio rendering, used to play Pulse Code Modulation (PCM) audio data.
-[AudioCapturer](#audiocapturer8): Audio capture, used to record PCM audio data.
-[AudioManager](#audiomanager): audio management.
-[AudioRenderer](#audiorenderer8): audio rendering, used to play Pulse Code Modulation (PCM) audio data.
-[AudioCapturer](#audiocapturer8): audio capture, used to record PCM audio data.
## Modules to Import
...
...
@@ -15,22 +17,21 @@ This module provides the following common audio-related functions:
| pauseWhenDucked | boolean | Yes | Whether audio playback can be paused when audio is interrupted (true means audio playback can be paused during audio interruptions and false means the opposite). |
| pauseWhenDucked | boolean | Yes | Whether audio playback can be paused during audio interruption. The value **true** means that audio playback can be paused during audio interruption, and **false** means the opposite.|
## InterruptAction
Callback method for the audio interrupt or audio interrupt activated event.
Describes the callback invoked for audio interruption or focus gain events.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
| actionType | [InterruptActionType](#interruptactiontype) | Yes | Event return type. TYPE_ACTIVATED is the audio interrupt activated event, and TYPE_INTERRUPT is the audio interrupt event. |
| type | [InterruptType](#interrupttype) | No | Interrupt event type. |
| hint | [InterruptHint](#interrupthint) | No | Interrupt event prompts. |
| activated | boolean | No | Acquire/release focus. true indicates that the focus acquisition/release is successful, and false indicates that the focus acquisition/release fails. |
| actionType | [InterruptActionType](#interruptactiontype) | Yes | Returned event type. The value **TYPE_ACTIVATED** means the focus gain event, and **TYPE_INTERRUPT** means the audio interruption event.|
| type | [InterruptType](#interrupttype) | No | Type of the audio interruption event. |
| hint | [InterruptHint](interrupthint) | No | Hint provided along with the audio interruption event. |
| activated | boolean | No | Whether the focus is gained or released. The value **true** means that the focus is gained or released, and **false** means that the focus fails to be gained or released.|
## VolumeEvent<sup>8+</sup>
Describes the volume event received by the app when the volume is changed.
This is a system API and cannot be called by third-party applications.
Describes the event received by the application when the volume is changed.
| SOURCE_TYPE_VOICE_COMMUNICATION(This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR) | 7 | Voice communication source type. |
| SOURCE_TYPE_VOICE_COMMUNICATION | 7 | Voice communication source.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
Implements audio volume and audio device management. Before calling the interface of AudioManager, you need to create an instance through [getAudioManager](#audiogetaudiomanager).
Implements audio volume and audio device management. Before calling any API in **AudioManager**, you must use [getAudioManager](#audiogetaudiomanager) to create an **AudioManager** instance.
| callback | AsyncCallback<boolean> | Yes | Callback used to return the mute status of the stream. The value true means that the stream is muted, and false means the opposite.|
| callback | AsyncCallback<boolean> | Yes | Callback used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite.|
| Promise<boolean> | Promise used to return the mute status of the stream. The value true means that the stream is muted, and false means the opposite. |
| Promise<boolean> | Promise used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite.|
| callback | AsyncCallback<boolean> | Yes | Callback used to return the active status of the stream. The value true means that the stream is active, and false means the opposite.|
| callback | AsyncCallback<boolean> | Yes | Callback used to return the active status of the stream. The value **true** means that the stream is active, and **false** means the opposite.|
| Promise<boolean> | Promise used to return the active status of the stream. The value true means that the stream is active, and false means the opposite. |
| Promise<boolean> | Promise used to return the active status of the stream. The value **true** means that the stream is active, and **false** means the opposite.|
| callback | AsyncCallback<boolean> | Yes | Callback used to return the mute status of the microphone. The value true means that the microphone is muted, and false means the opposite. |
| callback | AsyncCallback<boolean> | Yes | Callback used to return the mute status of the microphone. The value **true** means that the microphone is muted, and **false** means the opposite.|
**Example:**
**Example**
```
var audioManager = audio.getAudioManager();
audioManager.isMicrophoneMute((err, value) => {
if (err) {
console.error('Failed to obtain the mute status of the microphone. ${err.message}');
| Promise<boolean> | Promise used to return the mute status of the microphone. The value **true** means that the microphone is muted, and **false** means the opposite.|
| Promise<boolean> | Promise used to return the mute status of the microphone. The value true means that the microphone is muted, and false means the opposite. |
**Example**
**Example:**
```
var audioManager = audio.getAudioManager();
audioManager.isMicrophoneMute().then((value) => {
console.log('Promise returned to indicate that the mute status of the microphone is obtained.', + value);
| type | string | Yes | Type of the event to subscribe to. The value 'volumeChange' means the system volume change event, which is triggered when a system volume change is detected. |
| callback | Callback<[VolumeEvent](#volumeevent8)> | Yes | Callback used to get the system volume change event. |
| type | string | Yes | Type of event to subscribe to. The value **volumeChange** means the system volume change event, which is triggered when a system volume change is detected.|
| callback | Callback<[VolumeEvent](#volumeevent8)> | Yes | Callback used to return the system volume change event. |
| type | string | Yes | Type of the event to subscribe to. The value 'ringerModeChange' means the ringer mode change event, which is triggered when a ringer mode change is detected. |
| callback | Callback<[AudioRingMode](#audioringmode)> | Yes | Callback used to get the updated ringer mode. |
| type | string | Yes | Type of event to subscribe to. The value **ringerModeChange** means the ringer mode change event, which is triggered when a ringer mode change is detected.|
| callback | Callback<[AudioRingMode](#audioringmode)>| Yes | Callback used to return the updated ringer mode. |
| type | string | Yes | Type of the event to subscribe to. The value 'deviceChange' means the device change event, which is triggered when a device change is detected. |
| callback | Callback<[DeviceChangeAction](#devicechangeaction)> | Yes | Callback used to obtain the device update details. |
| type | string | Yes | Type of event to subscribe to. The value **deviceChange** means the device change event, which is triggered when a device connection status change is detected.|
| callback | Callback<[DeviceChangeAction](#DeviceChangeAction)\> | Yes | Callback used to return the device update details. |
| type | string | Yes | Type of event to unsubscribe from. The value **deviceChange** means the device change event, which is triggered when a device connection status change is detected.|
| callback | Callback<[DeviceChangeAction](#DeviceChangeAction)> | No | Callback used to return the device update details. |
Subscribes to audio interrupt events. When the application's audio is interrupted by another playback event, the application will receive the callback.
Subscribes to audio interruption events. When the application's audio is interrupted by another playback event, the application will receive the callback.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
| type | string | Yes | Type of event to subscribe to. The value 'interrupt' means the audio interrupt event, which is triggered when the audio playback of the current application is interrupted by another application.|
| type | string | Yes | Type of event to subscribe to. The value **interrupt** means the audio interruption event, which is triggered when the audio playback of the current application is interrupted by another application.|
| type | string | Yes | Type of event to unsubscribe from. The value 'interrupt' means the audio interrupt event, which is triggered when the audio playback of the current application is interrupted by another application. |
| type | string | Yes | Type of event to subscribe to. The value **interrupt** means the audio interruption event, which is triggered when the audio playback of the current application is interrupted by another application.|
Provides related APIs for audio rendering. Before calling the AudioRenderer API, you need to create an instance through [createAudioRenderer](#audiocreateaudiorenderer8).
Provides APIs for audio rendering. Before calling any API in **AudioRenderer**, you must use [createAudioRenderer](#audiocreateaudiorenderer8) to create an **AudioRenderer** instance.
| type | string | Yes | Type of event to subscribe to. The value **interrupt** means the audio interruption event, which is triggered when audio playback is interrupted.|
| callback | Callback<[InterruptEvent](#interruptevent9)> | Yes | Callback used to return the audio interruption event. |
| type | string | Yes | Type of event to subscribe to. The value **markReach** means the mark reached event, which is triggered when the number of frames captured reaches the value of the **frame** parameter.|
| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
| callback | (position: number) => {} | Yes | Callback invoked when the event is triggered. |
| type | string | Yes | Type of event to subscribe to. The value **periodReach** means the period reached event, which is triggered when the period of frame rendering reaches the value of the **frame** parameter.|
| frame | number | Yes | Period during which frame rendering is listened. The value must be greater than **0**. |
| callback | (position: number) => {} | Yes | Callback invoked when the event is triggered. |
Provides related APIs for audio capture. Before calling the API of AudioCapturer, you need to create an instance through [createAudioCapturer](#audiocreateaudiocapturer8).
Provides APIs for audio capture. Before calling any API in **AudioCapturer**, you must use [createAudioCapturer](#audiocreateaudiocapturer8) to create an **AudioCapturer** instance.
| type | string | Yes | Type of event to subscribe to. The value **markReach** means the mark reached event, which is triggered when the number of frames captured reaches the value of the **frame** parameter. |
| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
| callback | position: number) => {} | Yes | Callback invoked when the event is triggered.|
| type | string | Yes | Type of event to unsubscribe from. The value **markReach** means the mark reached event, which is triggered when the number of frames captured reaches the value of the **frame** parameter.|
| type | string | Yes | Type of event to subscribe to. The value **periodReach** means the period reached event, which is triggered when the period of frame capturing reaches the value of the **frame** parameter.|
| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
| callback | (position: number) => {} | Yes | Callback invoked when the event is triggered. |
| type | string | Yes | Type of event to unsubscribe from. The value **periodReach** means the period reached event, which is triggered when the period of frame capturing reaches the value of the **frame** parameter.|
> The initial APIs of this module are supported since API version 9. The APIs of API version 9 is of the Canary version and are for trial use only. The API call may be unstable.
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. API version 9 is a canary release for trial use. The APIs of this version may be unstable.
## Modules to Import
...
...
@@ -12,25 +11,22 @@ import camera from '@ohos.multimedia.camera';
Creates a **CameraInput** instance with the specified camera position and camera type. This API uses an asynchronous callback to return the instance.
Creates a **CameraInput** instance with the specified camera position and camera type. This method uses an asynchronous callback to return the instance.
when we call *cameraManager.getCameras()* API, then it will return the **Camera** class which will have all camera-related metadata such as *cameraId, cameraPosition, cameraType & connectionType*.
## Camera
**System Capabilities:**
After **[camera.getCameraManager](#cameragetcameramanager)** is called, a camera instance is returned, including camera-related metadata such as **cameraId**, **cameraPosition**, **cameraType**, and **connectionType**.
| cameraPosition | cameraPosition | readonly | Camera position |
| cameraType | cameraType | readonly | Camera type |
| connectionType | connectionType | readonly | Camera connection type |
**Example**
```
asyncfunctiongetCameraInfo(){
...
...
@@ -368,41 +339,37 @@ async function getCameraInfo() {
```
## CameraStatusInfo<a name="section_Camera"></a>
This interface is a CameraManager callback API return. **CameraStatusInfo** will have *Camera* class & *CameraStatus* predefine constants.From *Camera* class, we can have all camera-related metadata & from *CameraStatus* constants, we will have information such as *APPEAR, DISAPPEAR, AVAILABLE & UNAVAILABLE*.
| callback | AsyncCallback<boolean\> | Yes | Callback used to return the flash light support status. The value **true** means that the device has flash light.|
| callback | AsyncCallback<boolean\> | Yes | Callback used to return the flash mode support status. The value **true** means that the specified flash mode is supported.|
Sets the flash mode. This API uses an asynchronous callback to return the result.
**Description**
Before setting the parameters, do the following checks:
Sets flash mode. This method uses an asynchronous callback to return the result.
1. Use [hasFlash](#hasflash) to check whether the device has flash light.
2. Use [isFlashModeSupported](#isflashmodesupported) to check whether the device supports a specified flash mode.
Note: Before setting the flash mode, check the support for the flash light (<ahref="#sec_hasFlash">hasFlash</a> method) and flash mode support (<ahref="#sec_isFlashModeSupported">isFlashModeSupported</a> method);
Sets the flash mode. This API uses a promise to return the result.
**Description**
Before setting the parameters, do the following checks:
Sets flash mode. This method uses a promise to return the result.
1. Use [hasFlash](#hasflash) to check whether the device has flash light.
2. Use [isFlashModeSupported](#isflashmodesupported) to check whether the device supports a specified flash mode.
Note: Before setting the flash mode, check the support for the flash light (<ahref="#sec_hasFlash">hasFlash</a> method) and flash mode support (<ahref="#sec_isFlashModeSupported">isFlashModeSupported</a> method);
| callback | AsyncCallback<boolean\> | Yes | Callback used to return the focus mode support status. The value **true** means that the specified focus mode is supported.|
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> API version 9 is a canary release for trial use. The APIs of this version may be unstable.
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> API version 9 is a canary release for trial use. The APIs of this version may be unstable.
The multimedia subsystem provides a set of simple and easy-to-use APIs for you to access the system and use media resources.
...
...
@@ -10,6 +13,7 @@ This subsystem offers various media services covering audio and video, which pro
- Video recording ([VideoRecorder](#videorecorder9))
The following capabilities will be provided in later versions: data source audio/video playback, audio/video encoding and decoding, container encapsulation and decapsulation, and media capability query.
...
...
@@ -87,21 +91,16 @@ Creates a **VideoPlayer** instance in asynchronous mode. This API uses a promise
Obtains the audio track information. This API uses a callback to return the result.
Obtains the audio track information. This API uses a callback to return the result. It can be called only after the [dataLoad](#audioplayer_on) event is triggered.
Obtains the audio track information. This API uses a promise to return the result.
Obtains the audio track information. This API uses a promise to return the result. It can be called only after the [dataLoad](#audioplayer_on) event is triggered.
@@ -1774,6 +1791,644 @@ Enumerates the audio output formats.
| AMR_WB | 4 | AMR_WB.<br>This API is defined but not implemented yet.|
| AAC_ADTS | 6 | Audio Data Transport Stream (ADTS), which is a transport stream format of AAC-based audio.|
## VideoRecorder<sup>9+</sup>
Implements video recording. Before calling an API of the **VideoRecorder** class, you must call [createVideoRecorder()](#mediacreatevideorecorder9) to create a [VideoRecorder](#videorecorder9) instance.
For details about the video recording demo, see [Video Recording Development](../../media/video-recorder.md).
Obtains the surface required for recording in asynchronous mode. This surface is provided for the caller. The caller obtains the **surfaceBuffer** from this surface and fills in the corresponding data.
Note that the video data must carry the timestamp (in ns) and buffer size, and the start time of the timestamp is based on the system startup time.
This API can be called only after [prepare()](#videorecorder_prepare1) is called.
| callback | AsyncCallback\<string> | Yes | Callback used to obtain the result.|
**Example**
```js
// asyncallback
letsurfaceID=null;// Surface ID passed to the external system.
videoRecorder.getInputSurface((err,surfaceId)=>{
if(typeof(err)=='undefined'){
console.info('getInputSurface success');
surfaceID=surfaceId;
}else{
console.info('getInputSurface failed and error is '+err.message);
}
});
```
### getInputSurface<sup>9+</sup>
getInputSurface(): Promise\<string>;
Obtains the surface required for recording in asynchronous mode. This surface is provided for the caller. The caller obtains the **surfaceBuffer** from this surface and fills in the corresponding data.
Note that the video data must carry the timestamp (in ns) and buffer size, and the start time of the timestamp is based on the system startup time.
This API can be called only after [prepare()](#videorecorder_prepare1) is called.
Starts video recording in asynchronous mode. This API uses a callback to return the result.
This API can be called only after [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) are called, because the data source must pass data to the surface first.
Starts video recording in asynchronous mode. This API uses a promise to return the result.
This API can be called only after [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) are called, because the data source must pass data to the surface first.
| type | string | Yes | Type of the event to subscribe to, which is 'error' in this API.<br>The 'error' event is triggered when an error occurs during video recording.|
| callback | ErrorCallback | Yes | Callback invoked when the event is triggered. |
**Example**
```js
videoRecorder.on('error',(error)=>{// Set the 'error' event callback.
console.info(`audio error called, errName is ${error.name}`);// Print the error name.
console.info(`audio error called, errCode is ${error.code}`);// Print the error code.
console.info(`audio error called, errMessage is ${error.message}`);// Print the detailed description of the error type.
});
// This event is reported when an error occurs during the retrieval of videoRecordState.
```
## VideoRecordState<sup>9+</sup>
Enumerates the video recording states. You can obtain the state through the **state** attribute.
| rotation | number | No | Rotation angle of the recorded video. |
| location | [Location](#location) | No | Geographical location of the recorded video. |
| url | string | Yes | Video output URL. Supported: fd://xx (fd number)<br><br>The file must be created by the caller and granted with proper permissions.|
## AudioSourceType<sup>9+</sup>
Enumerates the audio source types for video recording.