提交 6620b5bd 编写于 作者: G Gloria

Update docs against 17738+18286+17995+16616+17842+17829

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 43011586
......@@ -46,14 +46,14 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
**Example**
```js
let avPlayer
let avPlayer;
media.createAVPlayer((error, video) => {
if (video != null) {
avPlayer = video;
console.info('createAVPlayer success');
} else {
console.info(`createAVPlayer fail, error:${error}`);
console.error(`createAVPlayer fail, error message:${error.message}`);
}
});
```
......@@ -83,17 +83,17 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
**Example**
```js
let avPlayer
let avPlayer;
media.createAVPlayer().then((video) => {
if (video != null) {
avPlayer = video;
console.info('createAVPlayer success');
} else {
console.info('createAVPlayer fail');
console.error('createAVPlayer fail');
}
}).catch((error) => {
console.info(`AVPlayer catchCallback, error:${error}`);
console.error(`AVPlayer catchCallback, error message:${error.message}`);
});
```
......@@ -123,14 +123,14 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
**Example**
```js
let avRecorder
let avRecorder;
media.createAVRecorder((error, recorder) => {
if (recorder != null) {
avRecorder = recorder;
console.info('createAVRecorder success');
} else {
console.info(`createAVRecorder fail, error:${error}`);
console.error(`createAVRecorder fail, error message:${error.message}`);
}
});
```
......@@ -161,17 +161,17 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
**Example**
```js
let avRecorder
let avRecorder;
media.createAVRecorder().then((recorder) => {
if (recorder != null) {
avRecorder = recorder;
console.info('createAVRecorder success');
} else {
console.info('createAVRecorder fail');
console.error('createAVRecorder fail');
}
}).catch((error) => {
console.info(`createAVRecorder catchCallback, error:${error}`);
console.error(`createAVRecorder catchCallback, error message:${error.message}`);
});
```
......@@ -203,14 +203,14 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
**Example**
```js
let videoRecorder
let videoRecorder;
media.createVideoRecorder((error, video) => {
if (video != null) {
videoRecorder = video;
console.info('video createVideoRecorder success');
} else {
console.info(`video createVideoRecorder fail, error:${error}`);
console.error(`video createVideoRecorder fail, error message:${error.message}`);
}
});
```
......@@ -243,17 +243,17 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
**Example**
```js
let videoRecorder
let videoRecorder;
media.createVideoRecorder().then((video) => {
if (video != null) {
videoRecorder = video;
console.info('video createVideoRecorder success');
} else {
console.info('video createVideoRecorder fail');
console.error('video createVideoRecorder fail');
}
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error message:${error.message}`);
});
```
......@@ -360,15 +360,15 @@ For details about the audio and video playback demo, see [Audio Playback](../../
| Name | Type | Readable| Writable| Description |
| --------------------------------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ |
| 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>![](figures/en-us_image_url.png)<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><a name=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.|
......@@ -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)
})
```
......@@ -932,7 +932,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
**Example**
```js
printfDescription(obj) {
function printfDescription(obj) {
for (let item in obj) {
let property = obj[item];
console.info('audio key is ' + item);
......@@ -978,7 +978,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
let arrayDescription;
printfDescription(obj) {
function printfDescription(obj) {
for (let item in obj) {
let property = obj[item];
console.info('audio key is ' + item);
......@@ -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.
This API is not supported in the live mode.
**System capability**: SystemCapability.Multimedia.Media.AVPlayer
......@@ -1012,7 +1013,7 @@ Seeks to the specified playback position. This API can be called only when the A
| Name| Type | Mandatory| Description |
| ------ | ---------------------- | ---- | ------------------------------------------------------------ |
| 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**
......@@ -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.
This API is not supported in the live mode.
**System capability**: SystemCapability.Multimedia.Media.AVPlayer
......@@ -1346,6 +1348,7 @@ avPlayer.off('endOfStream')
on(type: 'timeUpdate', callback: Callback\<number>): void
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.
**System capability**: SystemCapability.Multimedia.Media.AVPlayer
......@@ -1389,6 +1392,7 @@ avPlayer.off('timeUpdate')
on(type: 'durationUpdate', callback: Callback\<number>): void
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.
**System capability**: SystemCapability.Multimedia.Media.AVPlayer
......@@ -1785,7 +1789,7 @@ avRecorder.prepare(AVRecorderConfig, (err) => {
if (err == null) {
console.info('prepare success');
} else {
console.info('prepare failed and error is ' + err.message);
console.error('prepare failed and error is ' + err.message);
}
})
```
......@@ -1855,7 +1859,7 @@ let AVRecorderConfig = {
avRecorder.prepare(AVRecorderConfig).then(() => {
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);
});
```
......@@ -1898,7 +1902,7 @@ avRecorder.getInputSurface((err, surfaceId) => {
console.info('getInputSurface success');
surfaceID = surfaceId;
} else {
console.info('getInputSurface failed and error is ' + err.message);
console.error('getInputSurface failed and error is ' + err.message);
}
});
......@@ -1941,7 +1945,7 @@ avRecorder.getInputSurface().then((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);
});
```
......@@ -1978,7 +1982,7 @@ avRecorder.start((err) => {
if (err == null) {
console.info('start AVRecorder success');
} else {
console.info('start AVRecorder failed and error is ' + err.message);
console.error('start AVRecorder failed and error is ' + err.message);
}
});
```
......@@ -2015,7 +2019,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
avRecorder.start().then(() => {
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);
});
```
......@@ -2052,7 +2056,7 @@ avRecorder.pause((err) => {
if (err == null) {
console.info('pause AVRecorder success');
} else {
console.info('pause AVRecorder failed and error is ' + err.message);
console.error('pause AVRecorder failed and error is ' + err.message);
}
});
```
......@@ -2089,7 +2093,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
avRecorder.pause().then(() => {
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);
});
```
......@@ -2126,7 +2130,7 @@ avRecorder.resume((err) => {
if (err == null) {
console.info('resume AVRecorder success');
} else {
console.info('resume AVRecorder failed and error is ' + err.message);
console.error('resume AVRecorder failed and error is ' + err.message);
}
});
```
......@@ -2163,7 +2167,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
avRecorder.resume().then(() => {
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);
});
```
......@@ -2202,7 +2206,7 @@ avRecorder.stop((err) => {
if (err == null) {
console.info('stop AVRecorder success');
} else {
console.info('stop AVRecorder failed and error is ' + err.message);
console.error('stop AVRecorder failed and error is ' + err.message);
}
});
```
......@@ -2241,7 +2245,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
avRecorder.stop().then(() => {
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);
});
```
......@@ -2277,7 +2281,7 @@ avRecorder.reset((err) => {
if (err == null) {
console.info('reset AVRecorder success');
} else {
console.info('reset AVRecorder failed and error is ' + err.message);
console.error('reset AVRecorder failed and error is ' + err.message);
}
});
```
......@@ -2313,7 +2317,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
avRecorder.reset().then(() => {
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);
});
```
......@@ -2348,7 +2352,7 @@ avRecorder.release((err) => {
if (err == null) {
console.info('release AVRecorder success');
} else {
console.info('release AVRecorder failed and error is ' + err.message);
console.error('release AVRecorder failed and error is ' + err.message);
}
});
```
......@@ -2383,7 +2387,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
avRecorder.release().then(() => {
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);
});
```
......@@ -2460,7 +2464,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
avRecorder.on('error', (err) => {
console.info('case avRecorder.on(error) called, errMessage is ' + err.message);
console.error('case avRecorder.on(error) called, errMessage is ' + err.message);
});
```
......@@ -2521,8 +2525,8 @@ Describes the audio and video recording parameters.
| videoSourceType | [VideoSourceType](#videosourcetype9) | No | Type of the video source to record. This parameter is mandatory for video recording. |
| profile | [AVRecorderProfile](#avrecorderprofile9) | Yes | Recording profile. This parameter is mandatory. |
| url | string | Yes | Recording output URL: fd://xx (fd number).<br>![img](figures/en-us_image_url.png)<br>This parameter is mandatory.|
| 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**.
......@@ -2668,7 +2672,7 @@ videoRecorder.prepare(videoConfig, (err) => {
if (err == null) {
console.info('prepare success');
} else {
console.info('prepare failed and error is ' + err.message);
console.error('prepare failed and error is ' + err.message);
}
})
```
......@@ -2738,7 +2742,7 @@ let videoConfig = {
videoRecorder.prepare(videoConfig).then(() => {
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);
});
```
......@@ -2782,7 +2786,7 @@ videoRecorder.getInputSurface((err, surfaceId) => {
console.info('getInputSurface success');
surfaceID = surfaceId;
} else {
console.info('getInputSurface failed and error is ' + err.message);
console.error('getInputSurface failed and error is ' + err.message);
}
});
```
......@@ -2826,7 +2830,7 @@ videoRecorder.getInputSurface().then((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);
});
```
......@@ -2866,7 +2870,7 @@ videoRecorder.start((err) => {
if (err == null) {
console.info('start videorecorder success');
} else {
console.info('start videorecorder failed and error is ' + err.message);
console.error('start videorecorder failed and error is ' + err.message);
}
});
```
......@@ -2906,7 +2910,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
videoRecorder.start().then(() => {
console.info('start videorecorder success');
}).catch((err) => {
console.info('start videorecorder failed and catch error is ' + err.message);
console.error('start videorecorder failed and catch error is ' + err.message);
});
```
......@@ -2946,7 +2950,7 @@ videoRecorder.pause((err) => {
if (err == null) {
console.info('pause videorecorder success');
} else {
console.info('pause videorecorder failed and error is ' + err.message);
console.error('pause videorecorder failed and error is ' + err.message);
}
});
```
......@@ -2986,7 +2990,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
videoRecorder.pause().then(() => {
console.info('pause videorecorder success');
}).catch((err) => {
console.info('pause videorecorder failed and catch error is ' + err.message);
console.error('pause videorecorder failed and catch error is ' + err.message);
});
```
......@@ -3024,7 +3028,7 @@ videoRecorder.resume((err) => {
if (err == null) {
console.info('resume videorecorder success');
} else {
console.info('resume videorecorder failed and error is ' + err.message);
console.error('resume videorecorder failed and error is ' + err.message);
}
});
```
......@@ -3062,7 +3066,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
videoRecorder.resume().then(() => {
console.info('resume videorecorder success');
}).catch((err) => {
console.info('resume videorecorder failed and catch error is ' + err.message);
console.error('resume videorecorder failed and catch error is ' + err.message);
});
```
......@@ -3102,7 +3106,7 @@ videoRecorder.stop((err) => {
if (err == null) {
console.info('stop videorecorder success');
} else {
console.info('stop videorecorder failed and error is ' + err.message);
console.error('stop videorecorder failed and error is ' + err.message);
}
});
```
......@@ -3142,7 +3146,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
videoRecorder.stop().then(() => {
console.info('stop videorecorder success');
}).catch((err) => {
console.info('stop videorecorder failed and catch error is ' + err.message);
console.error('stop videorecorder failed and catch error is ' + err.message);
});
```
......@@ -3178,7 +3182,7 @@ videoRecorder.release((err) => {
if (err == null) {
console.info('release videorecorder success');
} else {
console.info('release videorecorder failed and error is ' + err.message);
console.error('release videorecorder failed and error is ' + err.message);
}
});
```
......@@ -3214,7 +3218,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
videoRecorder.release().then(() => {
console.info('release videorecorder success');
}).catch((err) => {
console.info('release videorecorder failed and catch error is ' + err.message);
console.error('release videorecorder failed and catch error is ' + err.message);
});
```
......@@ -3253,7 +3257,7 @@ videoRecorder.reset((err) => {
if (err == null) {
console.info('reset videorecorder success');
} else {
console.info('reset videorecorder failed and error is ' + err.message);
console.error('reset videorecorder failed and error is ' + err.message);
}
});
```
......@@ -3292,7 +3296,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
videoRecorder.reset().then(() => {
console.info('reset videorecorder success');
}).catch((err) => {
console.info('reset videorecorder failed and catch error is ' + err.message);
console.error('reset videorecorder failed and catch error is ' + err.message);
});
```
......@@ -3325,7 +3329,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco
```js
// This event is reported when an error occurs during the retrieval of videoRecordState.
videoRecorder.on('error', (error) => { // Set the 'error' event callback.
console.info(`audio error called, error: ${error}`);
console.error(`audio error called, error: ${error}`);
})
```
......@@ -3359,8 +3363,8 @@ Describes the video recording parameters.
| audioSourceType | [AudioSourceType](#audiosourcetype9) | Yes | Type of the audio source for video recording. |
| videoSourceType | [VideoSourceType](#videosourcetype9) | Yes | Type of the video source for video recording. |
| profile | [VideoRecorderProfile](#videorecorderprofile9) | Yes | Video recording profile. |
| rotation | number | No | Rotation angle of the recorded video. |
| 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. |
| url | string | Yes | Video output URL. Supported: fd://xx (fd number)<br>![](figures/en-us_image_url.png) |
## VideoRecorderProfile<sup>9+</sup>
......@@ -3429,14 +3433,14 @@ Creates a **VideoPlayer** instance. This API uses an asynchronous callback to re
**Example**
```js
let videoPlayer
let videoPlayer;
media.createVideoPlayer((error, video) => {
if (video != null) {
videoPlayer = video;
console.info('video createVideoPlayer success');
} else {
console.info(`video createVideoPlayer fail, error:${error}`);
console.error(`video createVideoPlayer fail, error:${error}`);
}
});
```
......@@ -3462,17 +3466,17 @@ Creates a **VideoPlayer** instance. This API uses a promise to return the result
**Example**
```js
let videoPlayer
let videoPlayer;
media.createVideoPlayer().then((video) => {
if (video != null) {
videoPlayer = video;
console.info('video createVideoPlayer success');
} else {
console.info('video createVideoPlayer fail');
console.error('video createVideoPlayer fail');
}
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -3834,7 +3838,7 @@ audioPlayer.on('finish', () => { // Set the 'finish' event callbac
audioPlayer.stop(); // Stop the playback and trigger the 'stop' event callback.
});
audioPlayer.on('error', (error) => { // Set the 'error' event callback.
console.info(`audio error called, error: ${error}`);
console.error(`audio error called, error: ${error}`);
});
// Set the FD (local playback) of the audio file selected by the user.
......@@ -3899,7 +3903,7 @@ Subscribes to audio playback error events. After an error event is reported, you
```js
audioPlayer.on('error', (error) => { // Set the 'error' event callback.
console.info(`audio error called, error: ${error}`);
console.error(`audio error called, error: ${error}`);
});
audioPlayer.setVolume(3); // Set volume to an invalid value to trigger the 'error' event.
```
......@@ -3972,7 +3976,7 @@ videoPlayer.setDisplaySurface(surfaceId, (err) => {
if (err == null) {
console.info('setDisplaySurface success!');
} else {
console.info('setDisplaySurface fail!');
console.error('setDisplaySurface fail!');
}
});
```
......@@ -4006,7 +4010,7 @@ let surfaceId = null;
videoPlayer.setDisplaySurface(surfaceId).then(() => {
console.info('setDisplaySurface success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4031,7 +4035,7 @@ videoPlayer.prepare((err) => {
if (err == null) {
console.info('prepare success!');
} else {
console.info('prepare fail!');
console.error('prepare fail!');
}
});
```
......@@ -4056,7 +4060,7 @@ Prepares for video playback. This API uses a promise to return the result.
videoPlayer.prepare().then(() => {
console.info('prepare success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4081,7 +4085,7 @@ videoPlayer.play((err) => {
if (err == null) {
console.info('play success!');
} else {
console.info('play fail!');
console.error('play fail!');
}
});
```
......@@ -4106,7 +4110,7 @@ Starts to play video assets. This API uses a promise to return the result.
videoPlayer.play().then(() => {
console.info('play success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4156,7 +4160,7 @@ Pauses video playback. This API uses a promise to return the result.
videoPlayer.pause().then(() => {
console.info('pause success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4181,7 +4185,7 @@ videoPlayer.stop((err) => {
if (err == null) {
console.info('stop success!');
} else {
console.info('stop fail!');
console.error('stop fail!');
}
});
```
......@@ -4206,7 +4210,7 @@ Stops video playback. This API uses a promise to return the result.
videoPlayer.stop().then(() => {
console.info('stop success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4231,7 +4235,7 @@ videoPlayer.reset((err) => {
if (err == null) {
console.info('reset success!');
} else {
console.info('reset fail!');
console.error('reset fail!');
}
});
```
......@@ -4256,7 +4260,7 @@ Resets the video asset to be played. This API uses a promise to return the resul
videoPlayer.reset().then(() => {
console.info('reset success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4283,7 +4287,7 @@ videoPlayer.seek(seekTime, (err, result) => {
if (err == null) {
console.info('seek success!');
} else {
console.info('seek fail!');
console.error('seek fail!');
}
});
```
......@@ -4313,7 +4317,7 @@ videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC, (err, result) => {
if (err == null) {
console.info('seek success!');
} else {
console.info('seek fail!');
console.error('seek fail!');
}
});
```
......@@ -4331,7 +4335,7 @@ Seeks to the specified playback position. If **mode** is not specified, the prev
| Name| Type | Mandatory| Description |
| ------ | ---------------------- | ---- | ------------------------------------------------------------ |
| timeMs | number | Yes | Position to seek to, in ms. The value range is [0, duration].|
| mode | [SeekMode](#seekmode8) | No | Seek mode. |
| mode | [SeekMode](#seekmode8) | No | Seek mode based on the video I frame. The default value is **SEEK_PREV_SYNC**. |
**Return value**
......@@ -4347,13 +4351,13 @@ let seekTime = 5000;
videoPlayer.seek(seekTime).then((seekDoneTime) => { // seekDoneTime indicates the position after the seek operation is complete.
console.info('seek success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
console.info('seek success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4380,7 +4384,7 @@ videoPlayer.setVolume(vol, (err, result) => {
if (err == null) {
console.info('setVolume success!');
} else {
console.info('setVolume fail!');
console.error('setVolume fail!');
}
});
```
......@@ -4412,7 +4416,7 @@ let vol = 0.5;
videoPlayer.setVolume(vol).then(() => {
console.info('setVolume success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4437,7 +4441,7 @@ videoPlayer.release((err) => {
if (err == null) {
console.info('release success!');
} else {
console.info('release fail!');
console.error('release fail!');
}
});
```
......@@ -4462,7 +4466,7 @@ Releases the video playback resources. This API uses a promise to return the res
videoPlayer.release().then(() => {
console.info('release success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4567,7 +4571,7 @@ videoPlayer.setSpeed(speed, (err, result) => {
if (err == null) {
console.info('setSpeed success!');
} else {
console.info('setSpeed fail!');
console.error('setSpeed fail!');
}
});
```
......@@ -4601,7 +4605,7 @@ let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X;
videoPlayer.setSpeed(speed).then(() => {
console.info('setSpeed success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4718,7 +4722,7 @@ Subscribes to video playback error events. After an error event is reported, you
```js
videoPlayer.on('error', (error) => { // Set the 'error' event callback.
console.info(`video error called, error: ${error}`);
console.error(`video error called, error: ${error}`);
});
videoPlayer.url = 'fd://error'; // Set an incorrect URL to trigger the 'error' event.
```
......@@ -4974,7 +4978,7 @@ let audioRecorderConfig = {
location : { latitude : 30, longitude : 130},
}
audioRecorder.on('error', (error) => { // Set the 'error' event callback.
console.info(`audio error called, error: ${error}`);
console.error(`audio error called, error: ${error}`);
});
audioRecorder.prepare(audioRecorderConfig); // Do no set any parameter in prepare and trigger the 'error' event callback.
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册