未验证 提交 ecf442cb 编写于 作者: O openharmony_ci 提交者: Gitee

!8217 翻译完成:6863+6894+6966+7216+7520+7599+7584+7053 media uri描述方式修改,需要翻译

Merge pull request !8217 from wusongqing/TR6863
......@@ -39,28 +39,28 @@ function printfDescription(obj) {
// Set the player callbacks.
function setCallBack(audioPlayer) {
audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully.
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(); // 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.
audioPlayer.on('play', () => { // Set the 'play' event callback.
console.info('audio play success');
audioPlayer.pause(); // Trigger the 'pause' event callback and pause the playback.
});
audioPlayer.on('pause', () => { // Set the `pause` event callback.
audioPlayer.on('pause', () => { // Set the 'pause' event callback.
console.info('audio pause success');
audioPlayer.seek(5000); // Trigger the 'timeUpdate' event callback, and seek to 5000 ms for playback.
});
audioPlayer.on('stop', () => { // Set the `stop` event callback.
audioPlayer.on('stop', () => { // Set the 'stop' event callback.
console.info('audio stop success');
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.
audioPlayer.on('reset', () => { // Set the 'reset' event callback.
console.info('audio reset success');
audioPlayer.release(); // Release the AudioPlayer instance.
audioPlayer = undefined;
});
audioPlayer.on('timeUpdate', (seekDoneTime) => { // Set the `timeUpdate` event callback.
audioPlayer.on('timeUpdate', (seekDoneTime) => { // Set the 'timeUpdate' event callback.
if (typeof(seekDoneTime) == 'undefined') {
console.info('audio seek fail');
return;
......@@ -68,7 +68,7 @@ function setCallBack(audioPlayer) {
console.info('audio seek success, and seek time is ' + seekDoneTime);
audioPlayer.setVolume(0.5); // Trigger the 'volumeChange' event callback.
});
audioPlayer.on('volumeChange', () => { // Set the `volumeChange` event callback.
audioPlayer.on('volumeChange', () => { // Set the 'volumeChange' event callback.
console.info('audio volumeChange success');
audioPlayer.getTrackDescription((error, arrlist) => { // Obtain the audio track information in callback mode.
if (typeof (arrlist) != 'undefined') {
......@@ -107,7 +107,7 @@ async function audioPlayerDemo() {
}).catch((err) => {
console.info('open fd failed err is' + err);
});
audioPlayer.src = fdPath; // Set the src attribute and trigger the `dataLoad` event callback.
audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback.
}
```
......@@ -119,11 +119,11 @@ import fileIO from '@ohos.fileio'
export class AudioDemo {
// Set the player callbacks.
setCallBack(audioPlayer) {
audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully.
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.
});
audioPlayer.on('play', () => { // Set the `play` event callback.
audioPlayer.on('play', () => { // Set the 'play' event callback.
console.info('audio play success');
});
audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete.
......@@ -147,7 +147,7 @@ export class AudioDemo {
}).catch((err) => {
console.info('open fd failed err is' + err);
});
audioPlayer.src = fdPath; // Set the src attribute and trigger the `dataLoad` event callback.
audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback.
}
}
```
......@@ -161,15 +161,15 @@ export class AudioDemo {
// Set the player callbacks.
private isNextMusic = false;
setCallBack(audioPlayer) {
audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully.
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.
});
audioPlayer.on('play', () => { // Set the `play` event callback.
audioPlayer.on('play', () => { // Set the 'play' event callback.
console.info('audio play success');
audioPlayer.reset(); // Call the reset() API and trigger the 'reset' event callback.
});
audioPlayer.on('reset', () => { // Set the `reset` event callback.
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.
......@@ -223,7 +223,7 @@ import fileIO from '@ohos.fileio'
export class AudioDemo {
// Set the player callbacks.
setCallBack(audioPlayer) {
audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully.
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.loop = true; // Set the loop playback attribute.
audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback.
......@@ -247,7 +247,7 @@ export class AudioDemo {
}).catch((err) => {
console.info('open fd failed err is' + err);
});
audioPlayer.src = fdPath; // Set the src attribute and trigger the `dataLoad` event callback.
audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback.
}
}
```
......@@ -106,6 +106,7 @@ media.createVideoPlayer().then((video) => {
createAudioRecorder(): AudioRecorder
Creates an **AudioRecorder** instance to control audio recording.
Only one **AudioRecorder** instance can be created per device.
**System capability**: SystemCapability.Multimedia.Media.AudioRecorder
......@@ -126,6 +127,7 @@ let audioRecorder = media.createAudioRecorder();
createVideoRecorder(callback: AsyncCallback\<[VideoRecorder](#videorecorder9)>): void
Creates a **VideoRecorder** instance in asynchronous mode. This API uses a callback to return the result.
Only one **AudioRecorder** instance can be created per device.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
......@@ -155,6 +157,7 @@ media.createVideoRecorder((error, video) => {
createVideoRecorder(): Promise<[VideoRecorder](#videorecorder9)>
Creates a **VideoRecorder** instance in asynchronous mode. This API uses a promise to return the result.
Only one **AudioRecorder** instance can be created per device.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
......@@ -272,14 +275,15 @@ For details about the audio playback demo, see [Audio Playback Development](../.
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer
| Name | Type | Readable| Writable| Description |
| ----------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
| src | string | Yes | Yes | Audio media URI. The mainstream audio formats (MPEG-4, AAC, MPEG-3, OGG, and WAV) are supported.<br>**Example of supported URIs**:<br>1. FD playback: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP network playback: http://xx<br>3. HTTPS network playback: https://xx<br>**Note**:<br>To use media materials, you must declare the read permission. Otherwise, the media materials cannot be played properly.|
| loop | boolean | Yes | Yes | Whether to loop audio playback. The value **true** means to loop audio playback, and **false** means the opposite. |
| currentTime | number | Yes | No | Current audio playback position. |
| duration | number | Yes | No | Audio duration. |
| state | [AudioState](#audiostate) | Yes | No | Audio playback state. |
| Name | Type | Readable| Writable| Description |
| ------------------------------- | ----------------------------------- | ---- | ---- | ------------------------------------------------------------ |
| src | string | Yes | Yes | Audio file URI. The mainstream audio formats (M4A, AAC, MPEG-3, OGG, and WAV) are supported.<br>**Examples of supported URI schemes**:<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<br>**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.INTERNET (The latter is required only when online resources are used.)|
| fdSrc<sup>9+</sup> | [AVFileDescriptor](#interruptmode9) | Yes | Yes | Description of the audio file. This attribute is required when audio resources of an application are continuously stored in a file.<br>**Example:**<br>Assume that a music file that stores continuous music resources consists of the following:<br>Music 1 (address offset: 0, byte length: 100)<br>Music 2 (address offset: 101; byte length: 50)<br>Music 3 (address offset: 151, byte length: 150)<br>1. To play music 1: AVFileDescriptor {fd = resource handle; offset = 0; length = 100; }<br>2. To play music 2: AVFileDescriptor {fd = resource handle; offset = 101; length = 50; }<br>3. To play music 3: AVFileDescriptor {fd = resource handle; offset = 151; length = 150; }<br>If the file is an independent music file, use **src=fd://xx**.<br> <br>**Required permissions**: ohos.permission.READ_MEDIA|
| loop | boolean | Yes | Yes | Whether to loop audio playback. The value **true** means to loop audio playback, and **false** means the opposite. |
| audioInterruptMode<sup>9+</sup> | [InterruptMode](#interruptmode9) | Yes | Yes | Audio interruption mode. |
| currentTime | number | Yes | No | Current audio playback position, in ms. |
| duration | number | Yes | No | Audio duration, in ms. |
| state | [AudioState](#audiostate) | Yes | No | Audio playback state. This state cannot be used as the condition for triggering the call of **play()**, **pause()**, or **stop()**.|
### play<a name=audioplayer_play></a>
play(): void
......@@ -501,7 +505,7 @@ Subscribes to the audio buffering update event.
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type, which is 'bufferingUpdate' in this case. |
| type | string | Yes | Event type, which is **'bufferingUpdate'** in this case. |
| callback | function | Yes | Callback invoked when the event is triggered.<br>When [BufferingInfoType](#bufferinginfotype8) is set to **BUFFERING_PERCENT** or **CACHED_DURATION**, **value** is valid. Otherwise, **value** is fixed at **0**.|
**Example**
......@@ -590,7 +594,7 @@ audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' e
on(type: 'timeUpdate', callback: Callback\<number>): void
Subscribes to the 'timeUpdate' event.
Subscribes to the **'timeUpdate'** event.
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer
......@@ -598,7 +602,7 @@ Subscribes to the 'timeUpdate' event.
| Name | Type | Mandatory| Description |
| -------- | ----------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type, which is 'timeUpdate' in this case.<br>The 'timeUpdate' event is triggered when the [seek()](#audioplayer_seek) API is called.|
| type | string | Yes | Event type, which is **'timeUpdate'** in this case.<br>The **'timeUpdate'** event is triggered when the [seek()](#audioplayer_seek) API is called. |
| callback | Callback\<number> | Yes | Callback invoked when the event is triggered. The input parameter of the callback is the time when the seek operation is successful. |
**Example**
......@@ -618,7 +622,7 @@ audioPlayer.seek(30000); // Seek to 30000 ms.
on(type: 'error', callback: ErrorCallback): void
Subscribes to the audio playback error event.
Subscribes to audio playback error events. After an error event is reported, you must handle the event and exit the playback.
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer
......@@ -626,13 +630,13 @@ Subscribes to the audio playback error event.
| Name | Type | Mandatory| Description |
| -------- | ------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type, which is 'error' in this case.<br>The 'error' event is triggered when an error occurs during audio playback.|
| type | string | Yes | Event type, which is **'error'** in this case.<br>The **'error'** event is triggered when an error occurs during audio playback. |
| callback | ErrorCallback | Yes | Callback invoked when the event is triggered. |
**Example**
```js
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}`); // 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.
......@@ -646,13 +650,38 @@ Enumerates the audio playback states. You can obtain the state through the **sta
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer
| Name | Type | Description |
| ------------------ | ------ | -------------- |
| idle | string | The audio player is idle.|
| playing | string | Audio playback is in progress.|
| paused | string | Audio playback is paused.|
| stopped | string | Audio playback is stopped.|
| error<sup>8+</sup> | string | Audio playback is in the error state. |
| Name | Type | Description |
| ------------------ | ------ | ---------------------------------------------- |
| idle | string | No audio playback is in progress. The audio player is in this state after the **'dataload'** or **'reset'** event is triggered.|
| playing | string | Audio playback is in progress. The audio player is in this state after the **'play'** event is triggered. |
| paused | string | Audio playback is paused. The audio player is in this state after the **'pause'** event is triggered. |
| stopped | string | Audio playback is stopped. The audio player is in this state after the **'stop'** event is triggered. |
| error<sup>8+</sup> | string | Audio playback is in the error state. |
## AVFileDescriptor<sup>9+</sup>
Describes audio and video file resources. It is used to specify a particular resource for playback based on its offset and length within a file.
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| fd | number | Yes | Resource handle, which is obtained by calling **resourceManager.getRawFileDescriptor**. |
| offset | number | Yes | Resource offset, which needs to be entered based on the preset resource information. An invalid value causes a failure to parse audio and video resources.|
| length | number | Yes | Resource length, which needs to be entered based on the preset resource information. An invalid value causes a failure to parse audio and video resources.|
## InterruptMode<sup>9+</sup>
Describes the audio interruption mode.
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer
| Name | Default Value| Description |
| ---------------------------- | ------ | ---------- |
| SHARE_MODE | 0 | Shared mode.|
| INDEPENDENT_MODE| 1 | Independent mode. |
## VideoPlayer<sup>8+</sup>
......@@ -666,13 +695,16 @@ For details about the video playback demo, see [Video Playback Development](../.
| Name | Type | Readable| Writable| Description |
| ------------------------ | ---------------------------------- | ---- | ---- | ------------------------------------------------------------ |
| url<sup>8+</sup> | string | Yes | Yes | Video media URL. The mainstream video formats (MPEG-4, MPEG-TS, WebM, and MKV) are supported.<br>**Example of supported URIs**:<br>1. FD playback: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP network playback: http://xx<br>3. HTTPS network playback: https://xx<br>3. HLS network playback: http://xx or https://xx<br>**Note**:<br>To use media materials, you must declare the read permission. Otherwise, the media materials cannot be played properly.|
| url<sup>8+</sup> | string | Yes | Yes | Video media URL. The mainstream video formats (MPEG-4, MPEG-TS, WebM, and MKV) are supported.<br>**Example of supported URIs**:<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<br>**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.INTERNET (The latter is required only when online resources are used.)|
| fdSrc<sup>9+</sup> | [AVFileDescriptor](#interruptmode9) | Yes| Yes| Description of a video file. This attribute is required when video resources of an application are continuously stored in a file.<br>**Example:**<br>Assume that a music file that stores continuous music resources 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 video file, use **src=fd://xx**.<br>**Note**:<br>**Required permissions**: ohos.permission.READ_MEDIA|
| loop<sup>8+</sup> | boolean | Yes | Yes | Whether to loop video playback. The value **true** means to loop video playback, and **false** means the opposite. |
| currentTime<sup>8+</sup> | number | Yes | No | Current video playback position. |
| duration<sup>8+</sup> | number | Yes | No | Video duration. The value **-1** indicates the live streaming mode. |
| videoScaleType<sup>9+</sup> | [VideoScaleType](#videoscaletype9) | Yes | Yes | Video scale type. |
| audioInterruptMode<sup>9+</sup> | [InterruptMode](#interruptmode9) | Yes | Yes | Audio interruption mode. |
| currentTime<sup>8+</sup> | number | Yes | No | Current video playback position, in ms. |
| duration<sup>8+</sup> | number | Yes | No | Video duration, in ms. The value **-1** indicates the live mode. |
| state<sup>8+</sup> | [VideoPlayState](#videoplaystate8) | Yes | No | Video playback state. |
| width<sup>8+</sup> | number | Yes | No | Video width. |
| height<sup>8+</sup> | number | Yes | No | Video height. |
| width<sup>8+</sup> | number | Yes | No | Video width, in pixels. |
| height<sup>8+</sup> | number | Yes | No | Video height, in pixels. |
### setDisplaySurface<sup>8+</sup>
......@@ -1334,7 +1366,7 @@ videoPlayer.setSpeed(speed).then() => {
selectBitrate(bitrate:number, callback: AsyncCallback\<number>): void
Selects a bit rate from available bit rates. This API uses a callback to return the result. The available bit rates can be obtained by calling [availableBitrateCollected](#on('availableBitrateCollected')<sup>9+</sup>).
Selects a bit rate from available ones, which can be obtained by calling [availableBitratesCollect](#onavailablebitratescollect9). This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Media.VideoPlayer
......@@ -1362,7 +1394,7 @@ videoPlayer.selectBitrate(bitrate, (err, result) => {
selectBitrate(bitrate:number): Promise\<number>
Selects a bit rate from available bit rates. This API uses a promise to return the result. The available bit rates can be obtained by calling [availableBitrateCollected](#on('availableBitrateCollected')<sup>9+</sup>).
Selects a bit rate from available ones, which can be obtained by calling [availableBitratesCollect](#onavailablebitratescollect9). This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Media.VideoPlayer
......@@ -1401,7 +1433,7 @@ Subscribes to the video playback completion event.
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ----------------------------------------------------------- |
| type | string | Yes | Event type, which is 'playbackCompleted' in this case.|
| type | string | Yes | Event type, which is **'playbackCompleted'** in this case. |
| callback | function | Yes | Callback invoked when the event is triggered. |
**Example**
......@@ -1424,7 +1456,7 @@ Subscribes to the video buffering update event.
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type, which is 'bufferingUpdate' in this case. |
| type | string | Yes | Event type, which is **'bufferingUpdate'** in this case. |
| callback | function | Yes | Callback invoked when the event is triggered.<br>When [BufferingInfoType](#bufferinginfotype8) is set to **BUFFERING_PERCENT** or **CACHED_DURATION**, **value** is valid. Otherwise, **value** is fixed at **0**.|
**Example**
......@@ -1448,7 +1480,7 @@ Subscribes to the frame rendering start event.
| Name | Type | Mandatory| Description |
| -------- | --------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type, which is 'startRenderFrame' in this case.|
| type | string | Yes | Event type, which is **'startRenderFrame'** in this case. |
| callback | Callback\<void> | Yes | Callback invoked when the event is triggered. |
**Example**
......@@ -1471,7 +1503,7 @@ Subscribes to the video width and height change event.
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type, which is 'videoSizeChanged' in this case.|
| type | string | Yes | Event type, which is **'videoSizeChanged'** in this case. |
| callback | function | Yes | Callback invoked when the event is triggered. **width** indicates the video width, and **height** indicates the video height. |
**Example**
......@@ -1487,7 +1519,7 @@ videoPlayer.on('videoSizeChanged', (width, height) => {
on(type: 'error', callback: ErrorCallback): void
Subscribes to the video playback error event.
Subscribes to video playback error events. After an error event is reported, you must handle the event and exit the playback.
**System capability**: SystemCapability.Multimedia.Media.VideoPlayer
......@@ -1495,7 +1527,7 @@ Subscribes to the video playback error event.
| Name | Type | Mandatory| Description |
| -------- | ------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type, which is 'error' in this case.<br>The 'error' event is triggered when an error occurs during video playback.|
| type | string | Yes | Event type, which is **'error'** in this case.<br>The **'error'** event is triggered when an error occurs during video playback. |
| callback | ErrorCallback | Yes | Callback invoked when the event is triggered. |
**Example**
......@@ -1506,12 +1538,12 @@ videoPlayer.on('error', (error) => { // Set the 'error' event callback.
console.info(`video error called, errCode is ${error.code}`); // Print the error code.
console.info(`video error called, errMessage is ${error.message}`);// Print the detailed description of the error type.
});
videoPlayer.setVolume(3); // Set volume to an invalid value to trigger the 'error' event.
videoPlayer.url = 'fd://error'; // Set an incorrect URL to trigger the 'error' event.
```
### on('availableBitrateCollected')<sup>9+</sup>
### on('availableBitratesCollect')<sup>9+</sup>
on(type: 'availableBitrateCollected', callback: (bitrates: Array<number>) => void): void
on(type: 'availableBitratesCollect', callback: (bitrates: Array\<number>) => void): void
Subscribes to the video playback bit rate reporting event.
......@@ -1521,15 +1553,15 @@ Subscribes to the video playback bit rate reporting event.
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type, which is 'availableBitrateCollected' in this case. This event is reported only once when the playback starts.|
| callback | function | Yes | Callback used to return supported bit rates, in an array. |
| type | string | Yes | Event type, which is **'availableBitratesCollect'** in this case. This event is reported only once when the playback starts.|
| callback | function | Yes | Callback used to return supported bit rates, in an array. |
**Example**
```js
videoPlayer.on('availableBitrateCollected', (bitrates) => {
videoPlayer.on('availableBitratesCollect', (bitrates) => {
for (let i = 0; i < bitrates.length; i++) {
console.info('case availableBitrateCollected bitrates: ' + bitrates[i]); // Print bit rates.
console.info('case availableBitratesCollect bitrates: ' + bitrates[i]); // Print bit rates.
}
});
```
......@@ -1574,6 +1606,17 @@ Enumerates the video playback speeds, which can be passed in the **setSpeed** AP
| SPEED_FORWARD_1_75_X | 3 | Plays the video at 1.75 times the normal speed.|
| SPEED_FORWARD_2_00_X | 4 | Plays the video at 2.00 times the normal speed.|
## VideoScaleType<sup>9+</sup>
Enumerates the video scale modes.
**System capability**: SystemCapability.Multimedia.Media.VideoPlayer
| Name | Default Value| Description |
| ---------------------------- | ------ | ---------- |
| VIDEO_SCALE_TYPE_FIT | 0 | The video will be stretched to fit the window.|
| VIDEO_SCALE_TYPE_FIT_CROP| 1 | The video will be stretched to fit the window, without changing its aspect ratio. The content may be cropped. |
## MediaDescription<sup>8+</sup>
### [key : string] : Object
......@@ -1765,7 +1808,7 @@ Subscribes to the audio recording events.
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The following events are supported: 'prepare'\|'start'\| 'pause' \| 'resume' \|'stop'\|'release'\|'reset'<br>- The 'prepare' event is triggered when the [prepare](#audiorecorder_prepare) API is called and the audio recording parameters are set.<br>- The 'start' event is triggered when the [start](#audiorecorder_start) API is called and audio recording starts.<br>- The 'pause' event is triggered when the [pause](#audiorecorder_pause) API is called and audio recording is paused.<br>- The 'resume' event is triggered when the [resume](#audiorecorder_resume) API is called and audio recording is resumed.<br>- The 'stop' event is triggered when the [stop](#audiorecorder_stop) API is called and audio recording stops.<br>- The 'release' event is triggered when the [release](#audiorecorder_release) API is called and the recording resource is released.<br>- The 'reset' event is triggered when the [reset](#audiorecorder_reset) API is called and audio recording is reset.|
| type | string | Yes | Event type. The following events are supported:<br>- 'prepare': triggered when the [prepare](#audiorecorder_prepare) API is called and the audio recording parameters are set.<br>- 'start': triggered when the [start](#audiorecorder_start) API is called and audio recording starts.<br>- 'pause': triggered when the [pause](#audiorecorder_pause) API is called and audio recording is paused.<br>- 'resume': triggered when the [resume](#audiorecorder_resume) API is called and audio recording is resumed.<br>- 'stop': triggered when the [stop](#audiorecorder_stop) API is called and audio recording stops.<br>- 'release': triggered when the [release](#audiorecorder_release) API is called and the recording resource is released.<br>- 'reset': triggered when the [reset](#audiorecorder_reset) API is called and audio recording is reset. |
| callback | ()=>void | Yes | Callback invoked when the event is triggered. |
**Example**
......@@ -1781,41 +1824,41 @@ let audioRecorderConfig = {
uri : 'fd://xx', // The file must be created by the caller and granted with proper permissions.
location : { latitude : 30, longitude : 130},
}
audioRecorder.on('error', (error) => { // Set the error event callback.
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('prepare', () => { // Set the prepare event callback.
audioRecorder.on('prepare', () => { // Set the 'prepare' event callback.
console.log('prepare success');
audioRecorder.start(); // Start recording and trigger the start event callback.
audioRecorder.start(); // Start recording and trigger the 'start' event callback.
});
audioRecorder.on('start', () => { // Set the start event callback.
audioRecorder.on('start', () => { // Set the 'start' event callback.
console.log('audio recorder start success');
});
audioRecorder.on('pause', () => { // Set the pause event callback.
audioRecorder.on('pause', () => { // Set the 'pause' event callback.
console.log('audio recorder pause success');
});
audioRecorder.on('resume', () => { // Set the resume event callback.
audioRecorder.on('resume', () => { // Set the 'resume' event callback.
console.log('audio recorder resume success');
});
audioRecorder.on('stop', () => { // Set the stop event callback.
audioRecorder.on('stop', () => { // Set the 'stop' event callback.
console.log('audio recorder stop success');
});
audioRecorder.on('release', () => { // Set the release event callback.
audioRecorder.on('release', () => { // Set the 'release' event callback.
console.log('audio recorder release success');
});
audioRecorder.on('reset', () => { // Set the reset event callback.
audioRecorder.on('reset', () => { // Set the 'reset' event callback.
console.log('audio recorder reset success');
});
audioRecorder.prepare(audioRecorderConfig) // Set recording parameters and trigger the prepare event callback.
audioRecorder.prepare(audioRecorderConfig) // Set recording parameters and trigger the 'prepare' event callback.
```
### on('error')
on(type: 'error', callback: ErrorCallback): void
Subscribes to the audio recording error event.
Subscribes to audio recording error events. After an error event is reported, you must handle the event and exit the recording.
**System capability**: SystemCapability.Multimedia.Media.AudioRecorder
......@@ -1823,18 +1866,18 @@ Subscribes to the audio recording error event.
| Name | Type | Mandatory| Description |
| -------- | ------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type, which is 'error' in this case.<br>The 'error' event is triggered when an error occurs during audio recording.|
| type | string | Yes | Event type, which is **'error'** in this case.<br>The **'error'** event is triggered when an error occurs during audio recording. |
| callback | ErrorCallback | Yes | Callback invoked when the event is triggered. |
**Example**
```js
audioRecorder.on('error', (error) => { // Set the error event callback.
audioRecorder.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.
});
audioRecorder.prepare(); // Do no set any parameter in prepare and trigger the error event callback.
audioRecorder.prepare(); // Do no set any parameter in prepare and trigger the 'error' event callback.
```
## AudioRecorderConfig
......@@ -1978,7 +2021,7 @@ prepare(config: VideoRecorderConfig): Promise\<void>;
Sets video recording parameters in asynchronous mode. This API uses a promise to return the result.
**Required permissions:** ohos.permission.MICROPHONE and ohos.permission.CAMERA
**Required permissions:** ohos.permission.MICROPHONE
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
......@@ -2109,7 +2152,7 @@ start(callback: AsyncCallback\<void>): void;
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.
This API can be called only after [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface9) are called, because the data source must pass data to the surface first.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
......@@ -2138,7 +2181,7 @@ start(): Promise\<void>;
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.
This API can be called only after [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface9) are called, because the data source must pass data to the surface first.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
......@@ -2273,7 +2316,7 @@ stop(callback: AsyncCallback\<void>): void;
Stops video recording in asynchronous mode. This API uses a callback to return the result.
To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) again.
To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface9) again.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
......@@ -2302,7 +2345,7 @@ stop(): Promise\<void>;
Stops video recording in asynchronous mode. This API uses a promise to return the result.
To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) again.
To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface9) again.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
......@@ -2381,7 +2424,7 @@ reset(callback: AsyncCallback\<void>): void;
Resets video recording in asynchronous mode. This API uses a callback to return the result.
To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) again.
To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface9) again.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
......@@ -2410,7 +2453,7 @@ reset(): Promise\<void>;
Resets video recording in asynchronous mode. This API uses a promise to return the result.
To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) again.
To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface9) again.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
......@@ -2435,7 +2478,7 @@ videoRecorder.reset().then(() => {
on(type: 'error', callback: ErrorCallback): void
Subscribes to the video recording error event.
Subscribes to video recording error events. After an error event is reported, you must handle the event and exit the recording.
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder
......@@ -2443,13 +2486,13 @@ Subscribes to the video recording error event.
| Name | Type | Mandatory| Description |
| -------- | ------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type, which is 'error' in this case.<br>The 'error' event is triggered when an error occurs during video recording.|
| type | string | Yes | Event type, which is **'error'** in this case.<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.
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.
......@@ -2485,7 +2528,7 @@ Describes the video recording parameters.
| 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. |
| url | string | Yes | Video output URL. Supported: fd://xx (fd number)<br>![](figures/en-us_image_url.png) <br>The file must be created by the caller and granted with proper permissions.|
| url | string | Yes | Video output URL. Supported: fd://xx (fd number)<br>![](figures/en-us_image_url.png) <br>**Required permissions**: ohos.permission.READ_MEDIA|
## AudioSourceType<sup>9+</sup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册