| url<sup>9+</sup> | string | Yes | Yes | URL of the media asset. It is a static attribute and can be set only when the AVPlayer is in the idle state. <br>The video formats MP4, MPEG-TS, WebM, and MKV are supported.<br>The audio formats M4A, AAC, MP3, OGG, and WAV are supported.<br>**Examples of supported URLs**:<br>1. FD: fd://xx<br><br>2. HTTP: http://xx<br>3. HTTPS: https://xx<br>4. HLS: http://xx or https://xx|
| fdSrc<sup>9+</sup> | [AVFileDescriptor](#avfiledescriptor9) | Yes | Yes | FD of the media asset. It is a static attribute and can be set only when the AVPlayer is in the idle state.<br>This attribute is required when media assets of an application are continuously stored in a file.<br>**Example:**<br>Assume that a media file that stores continuous assets consists of the following:<br>Video 1 (address offset: 0, byte length: 100)<br>Video 2 (address offset: 101; byte length: 50)<br>Video 3 (address offset: 151, byte length: 150)<br>1. To play video 1: AVFileDescriptor {fd = resource handle; offset = 0; length = 100; }<br>2. To play video 2: AVFileDescriptor {fd = resource handle; offset = 101; length = 50; }<br>3. To play video 3: AVFileDescriptor {fd = resource handle; offset = 151; length = 150; }<br>To play an independent media file, use **src=fd://xx**.|
| dataSrc<sup>10+</sup> | [AVDataSrcDescriptor](#avdatasrcdescriptor10) | Yes | Yes | Descriptor of a streaming media asset. It is a static attribute and can be set only when the AVPlayer is in the idle state.<br>Use scenario: An application starts playing a media file while the file is still being downloaded from the remote to the local host.<br>**Example:**<br>A user is obtaining an audio and video file from a remote server and wants to play the downloaded file content. To implement this scenario, do as follows:<br>1. Obtain the total file size, in bytes. If the total size cannot be obtained or the live mode is expected, set **fileSize** to **-1**.<br>2. Implement the **func** callback to fill in data. If **fileSize** is **-1**, the format of **func** is **func(buffer: ArrayBuffer, length: number)**; otherwise, the format is **func(buffer: ArrayBuffer, length: number, pos: number)**.<br>3. Set **AVDataSrcDescriptor {fileSize = size, callback = func}**.|
| fdSrc<sup>9+</sup> | [AVFileDescriptor](#avfiledescriptor9) | Yes | Yes | FD of the media asset. It is a static attribute and can be set only when the AVPlayer is in the idle state.<br>This attribute is required when media assets of an application are continuously stored in a file.<br>The video formats MP4, MPEG-TS, WebM, and MKV are supported.<br>The audio formats M4A, AAC, MP3, OGG, and WAV are supported.<br>**Example:**<br>Assume that a media file that stores continuous assets consists of the following:<br>Video 1 (address offset: 0, byte length: 100)<br>Video 2 (address offset: 101; byte length: 50)<br>Video 3 (address offset: 151, byte length: 150)<br>1. To play video 1: AVFileDescriptor {fd = resource handle; offset = 0; length = 100; }<br>2. To play video 2: AVFileDescriptor {fd = resource handle; offset = 101; length = 50; }<br>3. To play video 3: AVFileDescriptor {fd = resource handle; offset = 151; length = 150; }<br>To play an independent media file, use **src=fd://xx**.|
| dataSrc<sup>10+</sup> | [AVDataSrcDescriptor](#avdatasrcdescriptor10) | Yes | Yes | Descriptor of a streaming media asset. It is a static attribute and can be set only when the AVPlayer is in the idle state.<br>Use scenario: An application starts playing a media file while the file is still being downloaded from the remote to the local host.<br>The video formats MP4, MPEG-TS, WebM, and MKV are supported.<br>The audio formats M4A, AAC, MP3, OGG, and WAV are supported.<br>**Example:**<br>A user is obtaining an audio and video file from a remote server and wants to play the downloaded file content. To implement this scenario, do as follows:<br>1. Obtain the total file size, in bytes. If the total size cannot be obtained, set **fileSize** to **-1**.<br>2. Implement the **func** callback to fill in data. If **fileSize** is **-1**, the format of **func** is **func(buffer: ArrayBuffer, length: number)**, and the AVPlayer obtains data in sequence; otherwise, the format is **func(buffer: ArrayBuffer, length: number, pos: number)**, and the AVPlayer seeks and obtains data in the required positions.<br>3. Set **AVDataSrcDescriptor {fileSize = size, callback = func}**.<br>**Notes:**<br>If the media file to play is in MP4/M4A format, ensure that the **moov** field (specifying the media information) is before the **mdat** field (specifying the media data) or the fields before the **moov** field is less than 10 MB. Otherwise, the parsing fails and the media file cannot be played.|
| surfaceId<sup>9+</sup> | string | Yes | Yes | Video window ID. By default, there is no video window. It is a static attribute and can be set only when the AVPlayer is in the initialized state.<br>It is used to render the window for video playback and therefore is not required in audio-only playback scenarios.<br>**Example:**<br>[Create a surface ID through XComponent](../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid).|
| loop<sup>9+</sup> | boolean | Yes | Yes | Whether to loop playback. The value **true** means to loop playback, and **false** (default) means the opposite. It is a dynamic attribute<br>and can be set only when the AVPlayer is in the prepared, playing, paused, or completed state.|
| loop<sup>9+</sup> | boolean | Yes | Yes | Whether to loop playback. The value **true** means to loop playback, and **false** (default) means the opposite. It is a dynamic attribute<br>and can be set only when the AVPlayer is in the prepared, playing, paused, or completed state.<br>This setting is not supported in the live mode.|
| videoScaleType<sup>9+</sup> | [VideoScaleType](#videoscaletype9) | Yes | Yes | Video scaling type. The default value is **VIDEO_SCALE_TYPE_FIT_CROP**. It is a dynamic attribute<br>and can be set only when the AVPlayer is in the prepared, playing, paused, or completed state.|
| audioInterruptMode<sup>9+</sup> | [audio.InterruptMode](js-apis-audio.md#interruptmode9) | Yes | Yes | Audio interruption mode. The default value is **SHARE_MODE**. It is a dynamic attribute<br>and can be set only when the AVPlayer is in the prepared, playing, paused, or completed state.|
| audioRendererInfo<sup>10+</sup> | [audio.AudioRendererInfo](js-apis-audio.md#audiorendererinfo8) | Yes | Yes | Audio renderer information. The default value of **contentType** is **CONTENT_TYPE_MUSIC**, and the default value of **streamUsage** is **STREAM_USAGE_MEDIA**.<br>It can be set only when the AVPlayer is in the initialized state.|
| state<sup>9+</sup> | [AVPlayerState](#avplayerstate9) | Yes | No | AVPlayer state. It can be used as a query parameter when the AVPlayer is in any state. |
| currentTime<sup>9+</sup> | number | Yes | No | Current video playback position, in ms. It can be used as a query parameter when the AVPlayer is in the prepared, playing, paused, or completed state.<br>The value **-1** indicates an invalid value.|
| currentTime<sup>9+</sup> | number | Yes | No | Current video playback position, in ms. It can be used as a query parameter when the AVPlayer is in the prepared, playing, paused, or completed state.<br>The value **-1** indicates an invalid value.<br>In the live mode, **-1** is returned by default.|
| duration<sup>9+</sup><aname=avplayer_duration></a> | number | Yes | No | Video duration, in ms. It can be used as a query parameter when the AVPlayer is in the prepared, playing, paused, or completed state.<br>The value **-1** indicates an invalid value.<br>In live streaming scenarios, **-1** is returned by default.|
| width<sup>9+</sup> | number | Yes | No | Video width, in pixels. It can be used as a query parameter when the AVPlayer is in the prepared, playing, paused, or completed state.<br>The value **0** indicates an invalid value.|
| height<sup>9+</sup> | number | Yes | No | Video height, in pixels. It can be used as a query parameter when the AVPlayer is in the prepared, playing, paused, or completed state.<br>The value **0** indicates an invalid value.|
...
...
@@ -396,38 +396,38 @@ Subscribes to AVPlayer state changes.
```js
avPlayer.on('stateChange',async(state,reason)=>{
switch(state){
case'idle':
console.info('state idle called')
break;
case'initialized':
console.info('initialized prepared called')
break;
case'prepared':
console.info('state prepared called')
break;
case'playing':
console.info('state playing called')
break;
case'paused':
console.info('state paused called')
break;
case'completed':
console.info('state completed called')
break;
case'stopped':
console.info('state stopped called')
break;
case'released':
console.info('state released called')
break;
case'error':
console.info('state error called')
break;
default:
console.info('unkown state :'+state)
break;
}
switch(state){
case'idle':
console.info('state idle called')
break;
case'initialized':
console.info('initialized prepared called')
break;
case'prepared':
console.info('state prepared called')
break;
case'playing':
console.info('state playing called')
break;
case'paused':
console.info('state paused called')
break;
case'completed':
console.info('state completed called')
break;
case'stopped':
console.info('state stopped called')
break;
case'released':
console.info('state released called')
break;
case'error':
console.info('state error called')
break;
default:
console.info('unkown state :'+state)
break;
}
})
```
...
...
@@ -484,8 +484,8 @@ The AVPlayer provides the following error types<a name = error_info></a>:
```js
avPlayer.on('error',(error)=>{
console.info('error happened,and error message is :'+error.message)
console.info('error happened,and error code is :'+error.code)
console.error('error happened,and error message is :'+error.message)
console.error('error happened,and error code is :'+error.code)
})
```
...
...
@@ -536,11 +536,11 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avPlayer.prepare((err)=>{
if(err==null){
console.info('prepare success');
}else{
console.error('prepare filed,error message is :'+err.message)
}
if(err==null){
console.info('prepare success');
}else{
console.error('prepare filed,error message is :'+err.message)
}
})
```
...
...
@@ -571,9 +571,9 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avPlayer.prepare().then(()=>{
console.info('prepare success');
console.info('prepare success');
},(err)=>{
console.error('prepare filed,error message is :'+err.message)
console.error('prepare filed,error message is :'+err.message)
})
```
...
...
@@ -603,11 +603,11 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avPlayer.play((err)=>{
if(err==null){
console.info('play success');
}else{
console.error('play filed,error message is :'+err.message)
}
if(err==null){
console.info('play success');
}else{
console.error('play filed,error message is :'+err.message)
}
})
```
...
...
@@ -637,9 +637,9 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avPlayer.play().then(()=>{
console.info('play success');
console.info('play success');
},(err)=>{
console.error('play filed,error message is :'+err.message)
console.error('play filed,error message is :'+err.message)
})
```
...
...
@@ -669,11 +669,11 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avPlayer.pause((err)=>{
if(err==null){
console.info('pause success');
}else{
console.error('pause filed,error message is :'+err.message)
}
if(err==null){
console.info('pause success');
}else{
console.error('pause filed,error message is :'+err.message)
}
})
```
...
...
@@ -703,9 +703,9 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avPlayer.pause().then(()=>{
console.info('pause success');
console.info('pause success');
},(err)=>{
console.error('pause filed,error message is :'+err.message)
console.error('pause filed,error message is :'+err.message)
})
```
...
...
@@ -735,11 +735,11 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avPlayer.stop((err)=>{
if(err==null){
console.info('stop success');
}else{
console.error('stop filed,error message is :'+err.message)
}
if(err==null){
console.info('stop success');
}else{
console.error('stop filed,error message is :'+err.message)
}
})
```
...
...
@@ -769,9 +769,9 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avPlayer.stop().then(()=>{
console.info('stop success');
console.info('stop success');
},(err)=>{
console.error('stop filed,error message is :'+err.message)
console.error('stop filed,error message is :'+err.message)
})
```
...
...
@@ -801,11 +801,11 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avPlayer.reset((err)=>{
if(err==null){
console.info('reset success');
}else{
console.error('reset filed,error message is :'+err.message)
}
if(err==null){
console.info('reset success');
}else{
console.error('reset filed,error message is :'+err.message)
}
})
```
...
...
@@ -835,9 +835,9 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avPlayer.reset().then(()=>{
console.info('reset success');
console.info('reset success');
},(err)=>{
console.error('reset filed,error message is :'+err.message)
console.error('reset filed,error message is :'+err.message)
})
```
...
...
@@ -867,11 +867,11 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avPlayer.release((err)=>{
if(err==null){
console.info('reset success');
}else{
console.error('release filed,error message is :'+err.message)
}
if(err==null){
console.info('reset success');
}else{
console.error('release filed,error message is :'+err.message)
}
})
```
...
...
@@ -901,9 +901,9 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avPlayer.release().then(()=>{
console.info('release success');
console.info('release success');
},(err)=>{
console.error('release filed,error message is :'+err.message)
console.error('release filed,error message is :'+err.message)
})
```
...
...
@@ -932,22 +932,22 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
@@ -1004,6 +1004,7 @@ for (let i = 0; i < arrayDescription.length; i++) {
seek(timeMs: number, mode?:SeekMode): void
Seeks to the specified playback position. This API can be called only when the AVPlayer is in the prepared, playing, paused, or completed state. You can check whether the seek operation takes effect by subscribing to the [seekDone](#seekDone_on) event.
| timeMs | number | Yes | Position to seek to, in ms. The value range is [0, [duration](#avplayer_duration)].|
| mode | [SeekMode](#seekmode8) | No | Seek mode based on the video I frame. **Set this parameter only for video playback.**|
| mode | [SeekMode](#seekmode8) | No | Seek mode based on the video I frame. The default value is **SEEK_PREV_SYNC**. **Set this parameter only for video playback.**|
**Example**
...
...
@@ -1040,7 +1041,7 @@ Subscribes to the event to check whether the seek operation takes effect.
```js
avPlayer.on('seekDone',(seekDoneTime:number)=>{
console.info('seekDone success,and seek time is:'+seekDoneTime)
console.info('seekDone success,and seek time is:'+seekDoneTime)
})
```
...
...
@@ -1069,6 +1070,7 @@ avPlayer.off('seekDone')
setSpeed(speed: PlaybackSpeed): void
Sets the playback speed. This API can be called only when the AVPlayer is in the prepared, playing, paused, or completed state. You can check whether the setting takes effect by subscribing to the [speedDone](#speedDone_on) event.
Subscribes to playback position changes. It is used to refresh the current position of the progress bar. By default, this event is reported every 1 second. However, it is reported immediately upon a successful seek operation.
The **'timeUpdate'** event is not supported in the live mode.
Subscribes to media asset duration changes. It is used to refresh the length of the progress bar. By default, this event is reported once when the AVPlayer switches to the prepared state. However, it can be repeatedly reported for special streams that trigger duration changes.
The **'durationUpdate'** event is not supported in the live mode.
console.info('audioInterrupt success,and InterruptEvent info is:'+info)
console.info('audioInterrupt success,and InterruptEvent info is:'+info)
})
```
...
...
@@ -1690,19 +1694,19 @@ Defines media information in key-value mode.
```js
importmediafrom'@ohos.multimedia.media'
functionprintfItemDescription(obj,key){
letproperty=obj[key];
console.info('audio key is '+key);// Specify a key. For details about the keys, see [MediaDescriptionKey].
console.info('audio value is '+property);// Obtain the value of the key. The value can be any type. For details about the types, see [MediaDescriptionKey].
letproperty=obj[key];
console.info('audio key is '+key);// Specify a key. For details about the keys, see [MediaDescriptionKey].
console.info('audio value is '+property);// Obtain the value of the key. The value can be any type. For details about the types, see [MediaDescriptionKey].
url:'fd://',// Before passing in an FD to this parameter, the file must be created by the caller and granted with the read and write permissions. Example value: eg.fd://45.
rotation:0,// The value can be 0, 90, 180, or 270. If any other value is used, prepare() reports an error.
url:'fd://',// Before passing in an FD to this parameter, the file must be created by the caller and granted with the read and write permissions. Example value: eg.fd://45.
rotation:0,// The value can be 0, 90, 180, or 270. If any other value is used, prepare() reports an error.
location:{latitude:30,longitude:130}
}
avRecorder.prepare(AVRecorderConfig,(err)=>{
if(err==null){
console.info('prepare success');
}else{
console.info('prepare failed and error is '+err.message);
}
if(err==null){
console.info('prepare success');
}else{
console.error('prepare failed and error is '+err.message);
}
})
```
...
...
@@ -1832,30 +1836,30 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
// Configure the parameters based on those supported by the hardware device.
url:'fd://',// Before passing in an FD to this parameter, the file must be created by the caller and granted with the read and write permissions. Example value: eg.fd://45.
rotation:0,// The value can be 0, 90, 180, or 270. If any other value is used, prepare() reports an error.
url:'fd://',// Before passing in an FD to this parameter, the file must be created by the caller and granted with the read and write permissions. Example value: eg.fd://45.
rotation:0,// The value can be 0, 90, 180, or 270. If any other value is used, prepare() reports an error.
location:{latitude:30,longitude:130}
}
avRecorder.prepare(AVRecorderConfig).then(()=>{
console.info('prepare success');
console.info('prepare success');
}).catch((err)=>{
console.info('prepare failed and catch error is '+err.message);
console.error('prepare failed and catch error is '+err.message);
});
```
...
...
@@ -1894,12 +1898,12 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
letsurfaceID=null;// The surfaceID is transferred to the camera API to create a videoOutput instance.
avRecorder.getInputSurface((err,surfaceId)=>{
if(err==null){
console.info('getInputSurface success');
surfaceID=surfaceId;
}else{
console.info('getInputSurface failed and error is '+err.message);
}
if(err==null){
console.info('getInputSurface success');
surfaceID=surfaceId;
}else{
console.error('getInputSurface failed and error is '+err.message);
}
});
```
...
...
@@ -1938,10 +1942,10 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
letsurfaceID=null;// The surfaceID is transferred to the camera API to create a videoOutput instance.
avRecorder.getInputSurface().then((surfaceId)=>{
console.info('getInputSurface success');
surfaceID=surfaceId;
console.info('getInputSurface success');
surfaceID=surfaceId;
}).catch((err)=>{
console.info('getInputSurface failed and catch error is '+err.message);
console.error('getInputSurface failed and catch error is '+err.message);
});
```
...
...
@@ -1975,11 +1979,11 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avRecorder.start((err)=>{
if(err==null){
console.info('start AVRecorder success');
}else{
console.info('start AVRecorder failed and error is '+err.message);
}
if(err==null){
console.info('start AVRecorder success');
}else{
console.error('start AVRecorder failed and error is '+err.message);
}
});
```
...
...
@@ -2013,9 +2017,9 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avRecorder.start().then(()=>{
console.info('start AVRecorder success');
console.info('start AVRecorder success');
}).catch((err)=>{
console.info('start AVRecorder failed and catch error is '+err.message);
console.error('start AVRecorder failed and catch error is '+err.message);
});
```
...
...
@@ -2049,11 +2053,11 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avRecorder.pause((err)=>{
if(err==null){
console.info('pause AVRecorder success');
}else{
console.info('pause AVRecorder failed and error is '+err.message);
}
if(err==null){
console.info('pause AVRecorder success');
}else{
console.error('pause AVRecorder failed and error is '+err.message);
}
});
```
...
...
@@ -2087,9 +2091,9 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avRecorder.pause().then(()=>{
console.info('pause AVRecorder success');
console.info('pause AVRecorder success');
}).catch((err)=>{
console.info('pause AVRecorder failed and catch error is '+err.message);
console.error('pause AVRecorder failed and catch error is '+err.message);
});
```
...
...
@@ -2123,11 +2127,11 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avRecorder.resume((err)=>{
if(err==null){
console.info('resume AVRecorder success');
}else{
console.info('resume AVRecorder failed and error is '+err.message);
}
if(err==null){
console.info('resume AVRecorder success');
}else{
console.error('resume AVRecorder failed and error is '+err.message);
}
});
```
...
...
@@ -2161,9 +2165,9 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avRecorder.resume().then(()=>{
console.info('resume AVRecorder success');
console.info('resume AVRecorder success');
}).catch((err)=>{
console.info('resume AVRecorder failed and catch error is '+err.message);
console.error('resume AVRecorder failed and catch error is '+err.message);
});
```
...
...
@@ -2199,11 +2203,11 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avRecorder.stop((err)=>{
if(err==null){
console.info('stop AVRecorder success');
}else{
console.info('stop AVRecorder failed and error is '+err.message);
}
if(err==null){
console.info('stop AVRecorder success');
}else{
console.error('stop AVRecorder failed and error is '+err.message);
}
});
```
...
...
@@ -2239,9 +2243,9 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avRecorder.stop().then(()=>{
console.info('stop AVRecorder success');
console.info('stop AVRecorder success');
}).catch((err)=>{
console.info('stop AVRecorder failed and catch error is '+err.message);
console.error('stop AVRecorder failed and catch error is '+err.message);
});
```
...
...
@@ -2274,11 +2278,11 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avRecorder.reset((err)=>{
if(err==null){
console.info('reset AVRecorder success');
}else{
console.info('reset AVRecorder failed and error is '+err.message);
}
if(err==null){
console.info('reset AVRecorder success');
}else{
console.error('reset AVRecorder failed and error is '+err.message);
}
});
```
...
...
@@ -2311,9 +2315,9 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avRecorder.reset().then(()=>{
console.info('reset AVRecorder success');
console.info('reset AVRecorder success');
}).catch((err)=>{
console.info('reset AVRecorder failed and catch error is '+err.message);
console.error('reset AVRecorder failed and catch error is '+err.message);
});
```
...
...
@@ -2345,11 +2349,11 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avRecorder.release((err)=>{
if(err==null){
console.info('release AVRecorder success');
}else{
console.info('release AVRecorder failed and error is '+err.message);
}
if(err==null){
console.info('release AVRecorder success');
}else{
console.error('release AVRecorder failed and error is '+err.message);
}
});
```
...
...
@@ -2381,9 +2385,9 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avRecorder.release().then(()=>{
console.info('release AVRecorder success');
console.info('release AVRecorder success');
}).catch((err)=>{
console.info('release AVRecorder failed and catch error is '+err.message);
console.error('release AVRecorder failed and catch error is '+err.message);
});
```
...
...
@@ -2406,7 +2410,7 @@ Subscribes to AVRecorder state changes. An application can subscribe to only one
| rotation | number | No | Rotation angle of the recorded video. The value can only be 0, 90, 180, or 270. |
| location | [Location](#location) | No | Geographical location of the recorded video. |
| rotation | number | No | Rotation angle of the recorded video. The value can only be 0 (default), 90, 180, or 270. |
| location | [Location](#location) | No | Geographical location of the recorded video. By default, the geographical location information is not recorded. |
The **audioSourceType** and **videoSourceType** parameters are used to distinguish audio-only recording, video-only recording, and audio and video recording. For audio-only recording, set only **audioSourceType**. For video-only recording, set only **videoSourceType**. For audio and video recording, set both **audioSourceType** and **videoSourceType**.
...
...
@@ -2642,34 +2646,34 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
// Configure the parameters based on those supported by the hardware device.
letvideoProfile={
audioBitrate:48000,
audioChannels:2,
audioCodec:'audio/mp4a-latm',
audioSampleRate:48000,
fileFormat:'mp4',
videoBitrate:2000000,
videoCodec:'video/avc',
videoFrameWidth:640,
videoFrameHeight:480,
videoFrameRate:30
audioBitrate:48000,
audioChannels:2,
audioCodec:'audio/mp4a-latm',
audioSampleRate:48000,
fileFormat:'mp4',
videoBitrate:2000000,
videoCodec:'video/avc',
videoFrameWidth:640,
videoFrameHeight:480,
videoFrameRate:30
}
letvideoConfig={
audioSourceType:1,
videoSourceType:0,
profile:videoProfile,
url:'fd://xx',// The file must be created by the caller and granted with proper permissions.
orientationHint:0,
location:{latitude:30,longitude:130},
audioSourceType:1,
videoSourceType:0,
profile:videoProfile,
url:'fd://xx',// The file must be created by the caller and granted with proper permissions.
orientationHint:0,
location:{latitude:30,longitude:130},
}
// asyncallback
videoRecorder.prepare(videoConfig,(err)=>{
if(err==null){
console.info('prepare success');
}else{
console.info('prepare failed and error is '+err.message);
}
if(err==null){
console.info('prepare success');
}else{
console.error('prepare failed and error is '+err.message);
}
})
```
...
...
@@ -2713,32 +2717,32 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
// Configure the parameters based on those supported by the hardware device.
letvideoProfile={
audioBitrate:48000,
audioChannels:2,
audioCodec:'audio/mp4a-latm',
audioSampleRate:48000,
fileFormat:'mp4',
videoBitrate:2000000,
videoCodec:'video/avc',
videoFrameWidth:640,
videoFrameHeight:480,
videoFrameRate:30
audioBitrate:48000,
audioChannels:2,
audioCodec:'audio/mp4a-latm',
audioSampleRate:48000,
fileFormat:'mp4',
videoBitrate:2000000,
videoCodec:'video/avc',
videoFrameWidth:640,
videoFrameHeight:480,
videoFrameRate:30
}
letvideoConfig={
audioSourceType:1,
videoSourceType:0,
profile:videoProfile,
url:'fd://xx',// The file must be created by the caller and granted with proper permissions.
orientationHint:0,
location:{latitude:30,longitude:130},
audioSourceType:1,
videoSourceType:0,
profile:videoProfile,
url:'fd://xx',// The file must be created by the caller and granted with proper permissions.
orientationHint:0,
location:{latitude:30,longitude:130},
}
// promise
videoRecorder.prepare(videoConfig).then(()=>{
console.info('prepare success');
console.info('prepare success');
}).catch((err)=>{
console.info('prepare failed and catch error is '+err.message);
console.error('prepare failed and catch error is '+err.message);
});
```
...
...
@@ -2778,12 +2782,12 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
// asyncallback
letsurfaceID=null;// Surface ID passed to the external system.
videoRecorder.getInputSurface((err,surfaceId)=>{
if(err==null){
console.info('getInputSurface success');
surfaceID=surfaceId;
}else{
console.info('getInputSurface failed and error is '+err.message);
}
if(err==null){
console.info('getInputSurface success');
surfaceID=surfaceId;
}else{
console.error('getInputSurface failed and error is '+err.message);
}
});
```
...
...
@@ -2823,10 +2827,10 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
// promise
letsurfaceID=null;// Surface ID passed to the external system.
| rotation | number | No | Rotation angle of the recorded video. The value can only be 0 (default), 90, 180, or 270. |
| location | [Location](#location) | No | Geographical location of the recorded video. By default, the geographical location information is not recorded. |