提交 fe33a791 编写于 作者: G Gloria

Update docs against 15751+15922+15644

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 874ddfa3
...@@ -27,13 +27,22 @@ Before developing the audio data collection feature, configure the **ohos.permis ...@@ -27,13 +27,22 @@ Before developing the audio data collection feature, configure the **ohos.permis
For details about the APIs, see [AudioCapturer in Audio Management](../reference/apis/js-apis-audio.md#audiocapturer8). For details about the APIs, see [AudioCapturer in Audio Management](../reference/apis/js-apis-audio.md#audiocapturer8).
1. Use **createAudioCapturer()** to create an **AudioCapturer** instance. 1. Use **createAudioCapturer()** to create a global **AudioCapturer** instance.
Set parameters of the **AudioCapturer** instance in **audioCapturerOptions**. This instance is used to capture audio, control and obtain the recording state, and register a callback for notification. Set parameters of the **AudioCapturer** instance in **audioCapturerOptions**. This instance is used to capture audio, control and obtain the recording state, and register a callback for notification.
```js ```js
import audio from '@ohos.multimedia.audio'; import audio from '@ohos.multimedia.audio';
import fs from '@ohos.file.fs'; // It will be used for the call of the read function in step 3.
// Perform a self-test on APIs related to audio rendering.
@Entry
@Component
struct AudioRenderer {
@State message: string = 'Hello World'
private audioCapturer: audio.AudioCapturer; // It will be called globally.
async initAudioCapturer(){
let audioStreamInfo = { let audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
channels: audio.AudioChannel.CHANNEL_1, channels: audio.AudioChannel.CHANNEL_1,
...@@ -51,8 +60,10 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference ...@@ -51,8 +60,10 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
capturerInfo: audioCapturerInfo capturerInfo: audioCapturerInfo
} }
let audioCapturer = await audio.createAudioCapturer(audioCapturerOptions); this.audioCapturer = await audio.createAudioCapturer(audioCapturerOptions);
console.log('AudioRecLog: Create audio capturer success.'); console.log('AudioRecLog: Create audio capturer success.');
}
``` ```
2. Use **start()** to start audio recording. 2. Use **start()** to start audio recording.
...@@ -60,25 +71,20 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference ...@@ -60,25 +71,20 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
The capturer state will be **STATE_RUNNING** once the audio capturer is started. The application can then begin reading buffers. The capturer state will be **STATE_RUNNING** once the audio capturer is started. The application can then begin reading buffers.
```js ```js
import audio from '@ohos.multimedia.audio'; async startCapturer() {
let state = this.audioCapturer.state;
async function startCapturer() {
let state = audioCapturer.state;
// The audio capturer should be in the STATE_PREPARED, STATE_PAUSED, or STATE_STOPPED state after being started. // The audio capturer should be in the STATE_PREPARED, STATE_PAUSED, or STATE_STOPPED state after being started.
if (state != audio.AudioState.STATE_PREPARED || state != audio.AudioState.STATE_PAUSED || if (state == audio.AudioState.STATE_PREPARED || state == audio.AudioState.STATE_PAUSED ||
state != audio.AudioState.STATE_STOPPED) { state == audio.AudioState.STATE_STOPPED) {
console.info('Capturer is not in a correct state to start'); await this.audioCapturer.start();
return; state = this.audioCapturer.state;
}
await audioCapturer.start();
state = audioCapturer.state;
if (state == audio.AudioState.STATE_RUNNING) { if (state == audio.AudioState.STATE_RUNNING) {
console.info('AudioRecLog: Capturer started'); console.info('AudioRecLog: Capturer started');
} else { } else {
console.error('AudioRecLog: Capturer start failed'); console.error('AudioRecLog: Capturer start failed');
} }
} }
}
``` ```
3. Read the captured audio data and convert it to a byte stream. Call **read()** repeatedly to read the data until the application stops the recording. 3. Read the captured audio data and convert it to a byte stream. Call **read()** repeatedly to read the data until the application stops the recording.
...@@ -86,17 +92,15 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference ...@@ -86,17 +92,15 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
The following example shows how to write recorded data into a file. The following example shows how to write recorded data into a file.
```js ```js
import fs from '@ohos.file.fs'; async readData(){
let state = this.audioCapturer.state;
let state = audioCapturer.state;
// The read operation can be performed only when the state is STATE_RUNNING. // The read operation can be performed only when the state is STATE_RUNNING.
if (state != audio.AudioState.STATE_RUNNING) { if (state != audio.AudioState.STATE_RUNNING) {
console.info('Capturer is not in a correct state to read'); console.info('Capturer is not in a correct state to read');
return; return;
} }
const path = '/data/data/.pulse_dir/capture_js.wav'; // Path for storing the collected audio file. const path = '/data/data/.pulse_dir/capture_js.wav'; // Path for storing the collected audio file.
let file = fs.openSync(filePath, 0o2); let file = fs.openSync(path, 0o2);
let fd = file.fd; let fd = file.fd;
if (file !== null) { if (file !== null) {
console.info('AudioRecLog: file created'); console.info('AudioRecLog: file created');
...@@ -104,16 +108,14 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference ...@@ -104,16 +108,14 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
console.info('AudioRecLog: file create : FAILED'); console.info('AudioRecLog: file create : FAILED');
return; return;
} }
if (fd !== null) { if (fd !== null) {
console.info('AudioRecLog: file fd opened in append mode'); console.info('AudioRecLog: file fd opened in append mode');
} }
let numBuffersToCapture = 150; // Write data for 150 times. let numBuffersToCapture = 150; // Write data for 150 times.
let count = 0; let count = 0;
while (numBuffersToCapture) { while (numBuffersToCapture) {
let bufferSize = await audioCapturer.getBufferSize(); this.bufferSize = await this.audioCapturer.getBufferSize();
let buffer = await audioCapturer.read(bufferSize, true); let buffer = await this.audioCapturer.read(this.bufferSize, true);
let options = { let options = {
offset: count * this.bufferSize, offset: count * this.bufferSize,
length: this.bufferSize length: this.bufferSize
...@@ -127,22 +129,23 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference ...@@ -127,22 +129,23 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
numBuffersToCapture--; numBuffersToCapture--;
count++; count++;
} }
}
``` ```
4. Once the recording is complete, call **stop()** to stop the recording. 4. Once the recording is complete, call **stop()** to stop the recording.
```js ```js
async function StopCapturer() { async StopCapturer() {
let state = audioCapturer.state; let state = this.audioCapturer.state;
// The audio capturer can be stopped only when it is in STATE_RUNNING or STATE_PAUSED state. // The audio capturer can be stopped only when it is in STATE_RUNNING or STATE_PAUSED state.
if (state != audio.AudioState.STATE_RUNNING && state != audio.AudioState.STATE_PAUSED) { if (state != audio.AudioState.STATE_RUNNING && state != audio.AudioState.STATE_PAUSED) {
console.info('AudioRecLog: Capturer is not running or paused'); console.info('AudioRecLog: Capturer is not running or paused');
return; return;
} }
await audioCapturer.stop(); await this.audioCapturer.stop();
state = audioCapturer.state; state = this.audioCapturer.state;
if (state == audio.AudioState.STATE_STOPPED) { if (state == audio.AudioState.STATE_STOPPED) {
console.info('AudioRecLog: Capturer stopped'); console.info('AudioRecLog: Capturer stopped');
} else { } else {
...@@ -154,17 +157,17 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference ...@@ -154,17 +157,17 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
5. After the task is complete, call **release()** to release related resources. 5. After the task is complete, call **release()** to release related resources.
```js ```js
async function releaseCapturer() { async releaseCapturer() {
let state = audioCapturer.state; let state = this.audioCapturer.state;
// The audio capturer can be released only when it is not in the STATE_RELEASED or STATE_NEW state. // The audio capturer can be released only when it is not in the STATE_RELEASED or STATE_NEW state.
if (state == audio.AudioState.STATE_RELEASED || state == audio.AudioState.STATE_NEW) { if (state == audio.AudioState.STATE_RELEASED || state == audio.AudioState.STATE_NEW) {
console.info('AudioRecLog: Capturer already released'); console.info('AudioRecLog: Capturer already released');
return; return;
} }
await audioCapturer.release(); await this.audioCapturer.release();
state = audioCapturer.state; state = this.audioCapturer.state;
if (state == audio.AudioState.STATE_RELEASED) { if (state == audio.AudioState.STATE_RELEASED) {
console.info('AudioRecLog: Capturer released'); console.info('AudioRecLog: Capturer released');
} else { } else {
...@@ -178,23 +181,20 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference ...@@ -178,23 +181,20 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
You can use the following code to obtain the audio capturer information: You can use the following code to obtain the audio capturer information:
```js ```js
async getAudioCapturerInfo(){
// Obtain the audio capturer state. // Obtain the audio capturer state.
let state = audioCapturer.state; let state = this.audioCapturer.state;
// Obtain the audio capturer information. // Obtain the audio capturer information.
let audioCapturerInfo : audio.AuduioCapturerInfo = await audioCapturer.getCapturerInfo(); let audioCapturerInfo : audio.AudioCapturerInfo = await this.audioCapturer.getCapturerInfo();
// Obtain the audio stream information. // Obtain the audio stream information.
let audioStreamInfo : audio.AudioStreamInfo = await audioCapturer.getStreamInfo(); let audioStreamInfo : audio.AudioStreamInfo = await this.audioCapturer.getStreamInfo();
// Obtain the audio stream ID. // Obtain the audio stream ID.
let audioStreamId : number = await audioCapturer.getAudioStreamId(); let audioStreamId : number = await this.audioCapturer.getAudioStreamId();
// Obtain the Unix timestamp, in nanoseconds. // Obtain the Unix timestamp, in nanoseconds.
let audioTime : number = await audioCapturer.getAudioTime(); let audioTime : number = await this.audioCapturer.getAudioTime();
// Obtain a proper minimum buffer size. // Obtain a proper minimum buffer size.
let bufferSize : number = await audioCapturer.getBufferSize(); let bufferSize : number = await this.audioCapturer.getBufferSize();
}
``` ```
7. (Optional) Use **on('markReach')** to subscribe to the mark reached event, and use **off('markReach')** to unsubscribe from the event. 7. (Optional) Use **on('markReach')** to subscribe to the mark reached event, and use **off('markReach')** to unsubscribe from the event.
...@@ -202,12 +202,13 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference ...@@ -202,12 +202,13 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
After the mark reached event is subscribed to, when the number of frames collected by the audio capturer reaches the specified value, a callback is triggered and the specified value is returned. After the mark reached event is subscribed to, when the number of frames collected by the audio capturer reaches the specified value, a callback is triggered and the specified value is returned.
```js ```js
audioCapturer.on('markReach', (reachNumber) => { async markReach(){
this.audioCapturer.on('markReach', 10, (reachNumber) => {
console.info('Mark reach event Received'); console.info('Mark reach event Received');
console.info(`The Capturer reached frame: ${reachNumber}`); console.info(`The Capturer reached frame: ${reachNumber}`);
}); });
this.audioCapturer.off('markReach'); // Unsubscribe from the mark reached event. This event will no longer be listened for.
audioCapturer.off('markReach'); // Unsubscribe from the mark reached event. This event will no longer be listened for. }
``` ```
8. (Optional) Use **on('periodReach')** to subscribe to the period reached event, and use **off('periodReach')** to unsubscribe from the event. 8. (Optional) Use **on('periodReach')** to subscribe to the period reached event, and use **off('periodReach')** to unsubscribe from the event.
...@@ -215,18 +216,20 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference ...@@ -215,18 +216,20 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
After the period reached event is subscribed to, each time the number of frames collected by the audio capturer reaches the specified value, a callback is triggered and the specified value is returned. After the period reached event is subscribed to, each time the number of frames collected by the audio capturer reaches the specified value, a callback is triggered and the specified value is returned.
```js ```js
audioCapturer.on('periodReach', (reachNumber) => { async periodReach(){
this.audioCapturer.on('periodReach', 10, (reachNumber) => {
console.info('Period reach event Received'); console.info('Period reach event Received');
console.info(`In this period, the Capturer reached frame: ${reachNumber}`); console.info(`In this period, the Capturer reached frame: ${reachNumber}`);
}); });
this.audioCapturer.off('periodReach'); // Unsubscribe from the period reached event. This event will no longer be listened for.
audioCapturer.off('periodReach'); // Unsubscribe from the period reached event. This event will no longer be listened for. }
``` ```
9. If your application needs to perform some operations when the audio capturer state is updated, it can subscribe to the state change event. When the audio capturer state is updated, the application receives a callback containing the event type. 9. If your application needs to perform some operations when the audio capturer state is updated, it can subscribe to the state change event. When the audio capturer state is updated, the application receives a callback containing the event type.
```js ```js
audioCapturer.on('stateChange', (state) => { async stateChange(){
this.audioCapturer.on('stateChange', (state) => {
console.info(`AudioCapturerLog: Changed State to : ${state}`) console.info(`AudioCapturerLog: Changed State to : ${state}`)
switch (state) { switch (state) {
case audio.AudioState.STATE_PREPARED: case audio.AudioState.STATE_PREPARED:
...@@ -251,4 +254,5 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference ...@@ -251,4 +254,5 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
break; break;
} }
}); });
}
``` ```
...@@ -23,9 +23,9 @@ import audio from '@ohos.multimedia.audio'; ...@@ -23,9 +23,9 @@ import audio from '@ohos.multimedia.audio';
| Name | Type | Readable | Writable| Description | | Name | Type | Readable | Writable| Description |
| --------------------------------------- | ----------| ---- | ---- | ------------------ | | --------------------------------------- | ----------| ---- | ---- | ------------------ |
| LOCAL_NETWORK_ID<sup>9+</sup> | string | Yes | No | Network ID of the local device.<br>This is a system API.<br>**System capability**: SystemCapability.Multimedia.Audio.Device | | LOCAL_NETWORK_ID<sup>9+</sup> | string | Yes | No | Network ID of the local device.<br>This is a system API.<br> **System capability**: SystemCapability.Multimedia.Audio.Device |
| DEFAULT_VOLUME_GROUP_ID<sup>9+</sup> | number | Yes | No | Default volume group ID.<br>**System capability**: SystemCapability.Multimedia.Audio.Volume | | DEFAULT_VOLUME_GROUP_ID<sup>9+</sup> | number | Yes | No | Default volume group ID.<br> **System capability**: SystemCapability.Multimedia.Audio.Volume |
| DEFAULT_INTERRUPT_GROUP_ID<sup>9+</sup> | number | Yes | No | Default audio interruption group ID.<br>**System capability**: SystemCapability.Multimedia.Audio.Interrupt | | DEFAULT_INTERRUPT_GROUP_ID<sup>9+</sup> | number | Yes | No | Default audio interruption group ID.<br> **System capability**: SystemCapability.Multimedia.Audio.Interrupt |
**Example** **Example**
...@@ -1795,7 +1795,7 @@ Sets a device to the active state. This API uses a promise to return the result. ...@@ -1795,7 +1795,7 @@ Sets a device to the active state. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------------------- | ---- | ------------------ | | ---------- | ------------------------------------- | ---- | ------------------ |
| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type. | | deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type.|
| active | boolean | Yes | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite. | | active | boolean | Yes | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite. |
**Return value** **Return value**
...@@ -1860,7 +1860,7 @@ Checks whether a device is active. This API uses a promise to return the result. ...@@ -1860,7 +1860,7 @@ Checks whether a device is active. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------------------- | ---- | ------------------ | | ---------- | ------------------------------------- | ---- | ------------------ |
| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type. | | deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type.|
**Return value** **Return value**
...@@ -3956,6 +3956,7 @@ Describes the audio renderer change event. ...@@ -3956,6 +3956,7 @@ Describes the audio renderer change event.
**Example** **Example**
```js ```js
import audio from '@ohos.multimedia.audio'; import audio from '@ohos.multimedia.audio';
const audioManager = audio.getAudioManager(); const audioManager = audio.getAudioManager();
...@@ -4240,7 +4241,6 @@ audioRenderer.getStreamInfo().then((streamInfo) => { ...@@ -4240,7 +4241,6 @@ audioRenderer.getStreamInfo().then((streamInfo) => {
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err}`); console.error(`ERROR: ${err}`);
}); });
``` ```
### getAudioStreamId<sup>9+</sup> ### getAudioStreamId<sup>9+</sup>
...@@ -4263,7 +4263,6 @@ Obtains the stream ID of this **AudioRenderer** instance. This API uses an async ...@@ -4263,7 +4263,6 @@ Obtains the stream ID of this **AudioRenderer** instance. This API uses an async
audioRenderer.getAudioStreamId((err, streamid) => { audioRenderer.getAudioStreamId((err, streamid) => {
console.info(`Renderer GetStreamId: ${streamid}`); console.info(`Renderer GetStreamId: ${streamid}`);
}); });
``` ```
### getAudioStreamId<sup>9+</sup> ### getAudioStreamId<sup>9+</sup>
...@@ -4288,7 +4287,6 @@ audioRenderer.getAudioStreamId().then((streamid) => { ...@@ -4288,7 +4287,6 @@ audioRenderer.getAudioStreamId().then((streamid) => {
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err}`); console.error(`ERROR: ${err}`);
}); });
``` ```
### start<sup>8+</sup> ### start<sup>8+</sup>
...@@ -4315,7 +4313,6 @@ audioRenderer.start((err) => { ...@@ -4315,7 +4313,6 @@ audioRenderer.start((err) => {
console.info('Renderer start success.'); console.info('Renderer start success.');
} }
}); });
``` ```
### start<sup>8+</sup> ### start<sup>8+</sup>
...@@ -4340,7 +4337,6 @@ audioRenderer.start().then(() => { ...@@ -4340,7 +4337,6 @@ audioRenderer.start().then(() => {
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err}`); console.error(`ERROR: ${err}`);
}); });
``` ```
### pause<sup>8+</sup> ### pause<sup>8+</sup>
...@@ -4367,7 +4363,6 @@ audioRenderer.pause((err) => { ...@@ -4367,7 +4363,6 @@ audioRenderer.pause((err) => {
console.info('Renderer paused.'); console.info('Renderer paused.');
} }
}); });
``` ```
### pause<sup>8+</sup> ### pause<sup>8+</sup>
...@@ -4392,7 +4387,6 @@ audioRenderer.pause().then(() => { ...@@ -4392,7 +4387,6 @@ audioRenderer.pause().then(() => {
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err}`); console.error(`ERROR: ${err}`);
}); });
``` ```
### drain<sup>8+</sup> ### drain<sup>8+</sup>
...@@ -4419,7 +4413,6 @@ audioRenderer.drain((err) => { ...@@ -4419,7 +4413,6 @@ audioRenderer.drain((err) => {
console.info('Renderer drained.'); console.info('Renderer drained.');
} }
}); });
``` ```
### drain<sup>8+</sup> ### drain<sup>8+</sup>
...@@ -4444,7 +4437,6 @@ audioRenderer.drain().then(() => { ...@@ -4444,7 +4437,6 @@ audioRenderer.drain().then(() => {
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err}`); console.error(`ERROR: ${err}`);
}); });
``` ```
### stop<sup>8+</sup> ### stop<sup>8+</sup>
...@@ -4471,7 +4463,6 @@ audioRenderer.stop((err) => { ...@@ -4471,7 +4463,6 @@ audioRenderer.stop((err) => {
console.info('Renderer stopped.'); console.info('Renderer stopped.');
} }
}); });
``` ```
### stop<sup>8+</sup> ### stop<sup>8+</sup>
...@@ -4496,7 +4487,6 @@ audioRenderer.stop().then(() => { ...@@ -4496,7 +4487,6 @@ audioRenderer.stop().then(() => {
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err}`); console.error(`ERROR: ${err}`);
}); });
``` ```
### release<sup>8+</sup> ### release<sup>8+</sup>
...@@ -4523,7 +4513,6 @@ audioRenderer.release((err) => { ...@@ -4523,7 +4513,6 @@ audioRenderer.release((err) => {
console.info('Renderer released.'); console.info('Renderer released.');
} }
}); });
``` ```
### release<sup>8+</sup> ### release<sup>8+</sup>
...@@ -4548,7 +4537,6 @@ audioRenderer.release().then(() => { ...@@ -4548,7 +4537,6 @@ audioRenderer.release().then(() => {
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err}`); console.error(`ERROR: ${err}`);
}); });
``` ```
### write<sup>8+</sup> ### write<sup>8+</sup>
...@@ -4586,15 +4574,15 @@ let filePath = path + '/StarWars10s-2C-48000-4SW.wav'; ...@@ -4586,15 +4574,15 @@ let filePath = path + '/StarWars10s-2C-48000-4SW.wav';
let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY); let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
let stat = await fs.stat(path); let stat = await fs.stat(path);
let buf = new ArrayBuffer(bufferSize); let buf = new ArrayBuffer(bufferSize);
let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1); let len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1);
for (let i = 0;i < len; i++) { for (let i = 0;i < len; i++) {
let options = { let options = {
offset: i * this.bufferSize, offset: i * bufferSize,
length: this.bufferSize length: bufferSize
} }
let readsize = await fs.read(file.fd, buf, options) let readsize = await fs.read(file.fd, buf, options)
let writeSize = await new Promise((resolve,reject)=>{ let writeSize = await new Promise((resolve,reject)=>{
this.audioRenderer.write(buf,(err,writeSize)=>{ audioRenderer.write(buf,(err,writeSize)=>{
if(err){ if(err){
reject(err) reject(err)
}else{ }else{
...@@ -4604,7 +4592,6 @@ for (let i = 0;i < len; i++) { ...@@ -4604,7 +4592,6 @@ for (let i = 0;i < len; i++) {
}) })
} }
``` ```
### write<sup>8+</sup> ### write<sup>8+</sup>
...@@ -4641,20 +4628,19 @@ let filePath = path + '/StarWars10s-2C-48000-4SW.wav'; ...@@ -4641,20 +4628,19 @@ let filePath = path + '/StarWars10s-2C-48000-4SW.wav';
let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY); let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
let stat = await fs.stat(path); let stat = await fs.stat(path);
let buf = new ArrayBuffer(bufferSize); let buf = new ArrayBuffer(bufferSize);
let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1); let len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1);
for (let i = 0;i < len; i++) { for (let i = 0;i < len; i++) {
let options = { let options = {
offset: i * this.bufferSize, offset: i * bufferSize,
length: this.bufferSize length: bufferSize
} }
let readsize = await fs.read(file.fd, buf, options) let readsize = await fs.read(file.fd, buf, options)
try{ try{
let writeSize = await this.audioRenderer.write(buf); let writeSize = await audioRenderer.write(buf);
} catch(err) { } catch(err) {
console.error(`audioRenderer.write err: ${err}`); console.error(`audioRenderer.write err: ${err}`);
} }
} }
``` ```
### getAudioTime<sup>8+</sup> ### getAudioTime<sup>8+</sup>
...@@ -4677,7 +4663,6 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970). ...@@ -4677,7 +4663,6 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
audioRenderer.getAudioTime((err, timestamp) => { audioRenderer.getAudioTime((err, timestamp) => {
console.info(`Current timestamp: ${timestamp}`); console.info(`Current timestamp: ${timestamp}`);
}); });
``` ```
### getAudioTime<sup>8+</sup> ### getAudioTime<sup>8+</sup>
...@@ -4702,7 +4687,6 @@ audioRenderer.getAudioTime().then((timestamp) => { ...@@ -4702,7 +4687,6 @@ audioRenderer.getAudioTime().then((timestamp) => {
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err}`); console.error(`ERROR: ${err}`);
}); });
``` ```
### getBufferSize<sup>8+</sup> ### getBufferSize<sup>8+</sup>
...@@ -4727,7 +4711,6 @@ let bufferSize = audioRenderer.getBufferSize(async(err, bufferSize) => { ...@@ -4727,7 +4711,6 @@ let bufferSize = audioRenderer.getBufferSize(async(err, bufferSize) => {
console.error('getBufferSize error'); console.error('getBufferSize error');
} }
}); });
``` ```
### getBufferSize<sup>8+</sup> ### getBufferSize<sup>8+</sup>
...@@ -4754,7 +4737,6 @@ audioRenderer.getBufferSize().then((data) => { ...@@ -4754,7 +4737,6 @@ audioRenderer.getBufferSize().then((data) => {
}).catch((err) => { }).catch((err) => {
console.error(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`); console.error(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`);
}); });
``` ```
### setRenderRate<sup>8+</sup> ### setRenderRate<sup>8+</sup>
...@@ -4782,7 +4764,6 @@ audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err) => ...@@ -4782,7 +4764,6 @@ audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err) =>
console.info('Callback invoked to indicate a successful render rate setting.'); console.info('Callback invoked to indicate a successful render rate setting.');
} }
}); });
``` ```
### setRenderRate<sup>8+</sup> ### setRenderRate<sup>8+</sup>
...@@ -4813,7 +4794,6 @@ audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(() ...@@ -4813,7 +4794,6 @@ audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(()
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err}`); console.error(`ERROR: ${err}`);
}); });
``` ```
### getRenderRate<sup>8+</sup> ### getRenderRate<sup>8+</sup>
...@@ -4836,7 +4816,6 @@ Obtains the current render rate. This API uses an asynchronous callback to retur ...@@ -4836,7 +4816,6 @@ Obtains the current render rate. This API uses an asynchronous callback to retur
audioRenderer.getRenderRate((err, renderrate) => { audioRenderer.getRenderRate((err, renderrate) => {
console.info(`getRenderRate: ${renderrate}`); console.info(`getRenderRate: ${renderrate}`);
}); });
``` ```
### getRenderRate<sup>8+</sup> ### getRenderRate<sup>8+</sup>
...@@ -4861,9 +4840,7 @@ audioRenderer.getRenderRate().then((renderRate) => { ...@@ -4861,9 +4840,7 @@ audioRenderer.getRenderRate().then((renderRate) => {
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err}`); console.error(`ERROR: ${err}`);
}); });
``` ```
### setInterruptMode<sup>9+</sup> ### setInterruptMode<sup>9+</sup>
setInterruptMode(mode: InterruptMode): Promise&lt;void&gt; setInterruptMode(mode: InterruptMode): Promise&lt;void&gt;
...@@ -4893,9 +4870,7 @@ audioRenderer.setInterruptMode(mode).then(data=>{ ...@@ -4893,9 +4870,7 @@ audioRenderer.setInterruptMode(mode).then(data=>{
}).catch((err) => { }).catch((err) => {
console.error(`setInterruptMode Fail: ${err}`); console.error(`setInterruptMode Fail: ${err}`);
}); });
``` ```
### setInterruptMode<sup>9+</sup> ### setInterruptMode<sup>9+</sup>
setInterruptMode(mode: InterruptMode, callback: AsyncCallback\<void>): void setInterruptMode(mode: InterruptMode, callback: AsyncCallback\<void>): void
...@@ -4921,7 +4896,6 @@ audioRenderer.setInterruptMode(mode, (err, data)=>{ ...@@ -4921,7 +4896,6 @@ audioRenderer.setInterruptMode(mode, (err, data)=>{
} }
console.info('setInterruptMode Success!'); console.info('setInterruptMode Success!');
}); });
``` ```
### setVolume<sup>9+</sup> ### setVolume<sup>9+</sup>
...@@ -4952,9 +4926,7 @@ audioRenderer.setVolume(0.5).then(data=>{ ...@@ -4952,9 +4926,7 @@ audioRenderer.setVolume(0.5).then(data=>{
}).catch((err) => { }).catch((err) => {
console.error(`setVolume Fail: ${err}`); console.error(`setVolume Fail: ${err}`);
}); });
``` ```
### setVolume<sup>9+</sup> ### setVolume<sup>9+</sup>
setVolume(volume: number, callback: AsyncCallback\<void>): void setVolume(volume: number, callback: AsyncCallback\<void>): void
...@@ -4979,7 +4951,6 @@ audioRenderer.setVolume(0.5, (err, data)=>{ ...@@ -4979,7 +4951,6 @@ audioRenderer.setVolume(0.5, (err, data)=>{
} }
console.info('setVolume Success!'); console.info('setVolume Success!');
}); });
``` ```
### on('audioInterrupt')<sup>9+</sup> ### on('audioInterrupt')<sup>9+</sup>
...@@ -5059,7 +5030,6 @@ async function onAudioInterrupt(){ ...@@ -5059,7 +5030,6 @@ async function onAudioInterrupt(){
} }
}); });
} }
``` ```
### on('markReach')<sup>8+</sup> ### on('markReach')<sup>8+</sup>
...@@ -5086,7 +5056,6 @@ audioRenderer.on('markReach', 1000, (position) => { ...@@ -5086,7 +5056,6 @@ audioRenderer.on('markReach', 1000, (position) => {
console.info('ON Triggered successfully'); console.info('ON Triggered successfully');
} }
}); });
``` ```
...@@ -5108,7 +5077,6 @@ Unsubscribes from mark reached events. ...@@ -5108,7 +5077,6 @@ Unsubscribes from mark reached events.
```js ```js
audioRenderer.off('markReach'); audioRenderer.off('markReach');
``` ```
### on('periodReach') <sup>8+</sup> ### on('periodReach') <sup>8+</sup>
...@@ -5135,7 +5103,6 @@ audioRenderer.on('periodReach', 1000, (position) => { ...@@ -5135,7 +5103,6 @@ audioRenderer.on('periodReach', 1000, (position) => {
console.info('ON Triggered successfully'); console.info('ON Triggered successfully');
} }
}); });
``` ```
### off('periodReach') <sup>8+</sup> ### off('periodReach') <sup>8+</sup>
...@@ -5156,10 +5123,9 @@ Unsubscribes from period reached events. ...@@ -5156,10 +5123,9 @@ Unsubscribes from period reached events.
```js ```js
audioRenderer.off('periodReach') audioRenderer.off('periodReach')
``` ```
### on('stateChange')<sup>8+</sup> ### on('stateChange') <sup>8+</sup>
on(type: 'stateChange', callback: Callback<AudioState\>): void on(type: 'stateChange', callback: Callback<AudioState\>): void
...@@ -5185,7 +5151,6 @@ audioRenderer.on('stateChange', (state) => { ...@@ -5185,7 +5151,6 @@ audioRenderer.on('stateChange', (state) => {
console.info('audio renderer state is: STATE_RUNNING'); console.info('audio renderer state is: STATE_RUNNING');
} }
}); });
``` ```
## AudioCapturer<sup>8+</sup> ## AudioCapturer<sup>8+</sup>
...@@ -5204,7 +5169,6 @@ Provides APIs for audio capture. Before calling any API in **AudioCapturer**, yo ...@@ -5204,7 +5169,6 @@ Provides APIs for audio capture. Before calling any API in **AudioCapturer**, yo
```js ```js
let state = audioCapturer.state; let state = audioCapturer.state;
``` ```
### getCapturerInfo<sup>8+</sup> ### getCapturerInfo<sup>8+</sup>
...@@ -5233,7 +5197,6 @@ audioCapturer.getCapturerInfo((err, capturerInfo) => { ...@@ -5233,7 +5197,6 @@ audioCapturer.getCapturerInfo((err, capturerInfo) => {
console.info(`Capturer flags: ${capturerInfo.capturerFlags}`); console.info(`Capturer flags: ${capturerInfo.capturerFlags}`);
} }
}); });
``` ```
...@@ -5266,7 +5229,6 @@ audioCapturer.getCapturerInfo().then((audioParamsGet) => { ...@@ -5266,7 +5229,6 @@ audioCapturer.getCapturerInfo().then((audioParamsGet) => {
}).catch((err) => { }).catch((err) => {
console.error(`AudioFrameworkRecLog: CapturerInfo :ERROR: ${err}`); console.error(`AudioFrameworkRecLog: CapturerInfo :ERROR: ${err}`);
}); });
``` ```
### getStreamInfo<sup>8+</sup> ### getStreamInfo<sup>8+</sup>
...@@ -5297,7 +5259,6 @@ audioCapturer.getStreamInfo((err, streamInfo) => { ...@@ -5297,7 +5259,6 @@ audioCapturer.getStreamInfo((err, streamInfo) => {
console.info(`Capturer encoding type: ${streamInfo.encodingType}`); console.info(`Capturer encoding type: ${streamInfo.encodingType}`);
} }
}); });
``` ```
### getStreamInfo<sup>8+</sup> ### getStreamInfo<sup>8+</sup>
...@@ -5326,7 +5287,6 @@ audioCapturer.getStreamInfo().then((audioParamsGet) => { ...@@ -5326,7 +5287,6 @@ audioCapturer.getStreamInfo().then((audioParamsGet) => {
}).catch((err) => { }).catch((err) => {
console.error(`getStreamInfo :ERROR: ${err}`); console.error(`getStreamInfo :ERROR: ${err}`);
}); });
``` ```
### getAudioStreamId<sup>9+</sup> ### getAudioStreamId<sup>9+</sup>
...@@ -5349,7 +5309,6 @@ Obtains the stream ID of this **AudioCapturer** instance. This API uses an async ...@@ -5349,7 +5309,6 @@ Obtains the stream ID of this **AudioCapturer** instance. This API uses an async
audioCapturer.getAudioStreamId((err, streamid) => { audioCapturer.getAudioStreamId((err, streamid) => {
console.info(`audioCapturer GetStreamId: ${streamid}`); console.info(`audioCapturer GetStreamId: ${streamid}`);
}); });
``` ```
### getAudioStreamId<sup>9+</sup> ### getAudioStreamId<sup>9+</sup>
...@@ -5374,7 +5333,6 @@ audioCapturer.getAudioStreamId().then((streamid) => { ...@@ -5374,7 +5333,6 @@ audioCapturer.getAudioStreamId().then((streamid) => {
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err}`); console.error(`ERROR: ${err}`);
}); });
``` ```
### start<sup>8+</sup> ### start<sup>8+</sup>
...@@ -5401,7 +5359,6 @@ audioCapturer.start((err) => { ...@@ -5401,7 +5359,6 @@ audioCapturer.start((err) => {
console.info('Capturer start success.'); console.info('Capturer start success.');
} }
}); });
``` ```
...@@ -5433,7 +5390,6 @@ audioCapturer.start().then(() => { ...@@ -5433,7 +5390,6 @@ audioCapturer.start().then(() => {
}).catch((err) => { }).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer start :ERROR : ${err}`); console.info(`AudioFrameworkRecLog: Capturer start :ERROR : ${err}`);
}); });
``` ```
### stop<sup>8+</sup> ### stop<sup>8+</sup>
...@@ -5460,7 +5416,6 @@ audioCapturer.stop((err) => { ...@@ -5460,7 +5416,6 @@ audioCapturer.stop((err) => {
console.info('Capturer stopped.'); console.info('Capturer stopped.');
} }
}); });
``` ```
...@@ -5490,7 +5445,6 @@ audioCapturer.stop().then(() => { ...@@ -5490,7 +5445,6 @@ audioCapturer.stop().then(() => {
}).catch((err) => { }).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`); console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`);
}); });
``` ```
### release<sup>8+</sup> ### release<sup>8+</sup>
...@@ -5517,7 +5471,6 @@ audioCapturer.release((err) => { ...@@ -5517,7 +5471,6 @@ audioCapturer.release((err) => {
console.info('capturer released.'); console.info('capturer released.');
} }
}); });
``` ```
...@@ -5547,7 +5500,6 @@ audioCapturer.release().then(() => { ...@@ -5547,7 +5500,6 @@ audioCapturer.release().then(() => {
}).catch((err) => { }).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`); console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`);
}); });
``` ```
### read<sup>8+</sup> ### read<sup>8+</sup>
...@@ -5581,7 +5533,6 @@ audioCapturer.read(bufferSize, true, async(err, buffer) => { ...@@ -5581,7 +5533,6 @@ audioCapturer.read(bufferSize, true, async(err, buffer) => {
console.info('Success in reading the buffer data'); console.info('Success in reading the buffer data');
} }
}); });
``` ```
### read<sup>8+</sup> ### read<sup>8+</sup>
...@@ -5621,7 +5572,6 @@ audioCapturer.read(bufferSize, true).then((buffer) => { ...@@ -5621,7 +5572,6 @@ audioCapturer.read(bufferSize, true).then((buffer) => {
}).catch((err) => { }).catch((err) => {
console.info(`ERROR : ${err}`); console.info(`ERROR : ${err}`);
}); });
``` ```
### getAudioTime<sup>8+</sup> ### getAudioTime<sup>8+</sup>
...@@ -5644,7 +5594,6 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970). ...@@ -5644,7 +5594,6 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
audioCapturer.getAudioTime((err, timestamp) => { audioCapturer.getAudioTime((err, timestamp) => {
console.info(`Current timestamp: ${timestamp}`); console.info(`Current timestamp: ${timestamp}`);
}); });
``` ```
### getAudioTime<sup>8+</sup> ### getAudioTime<sup>8+</sup>
...@@ -5669,7 +5618,6 @@ audioCapturer.getAudioTime().then((audioTime) => { ...@@ -5669,7 +5618,6 @@ audioCapturer.getAudioTime().then((audioTime) => {
}).catch((err) => { }).catch((err) => {
console.info(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err}`); console.info(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err}`);
}); });
``` ```
### getBufferSize<sup>8+</sup> ### getBufferSize<sup>8+</sup>
...@@ -5699,7 +5647,6 @@ audioCapturer.getBufferSize((err, bufferSize) => { ...@@ -5699,7 +5647,6 @@ audioCapturer.getBufferSize((err, bufferSize) => {
}); });
} }
}); });
``` ```
### getBufferSize<sup>8+</sup> ### getBufferSize<sup>8+</sup>
...@@ -5726,7 +5673,6 @@ audioCapturer.getBufferSize().then((data) => { ...@@ -5726,7 +5673,6 @@ audioCapturer.getBufferSize().then((data) => {
}).catch((err) => { }).catch((err) => {
console.info(`AudioFrameworkRecLog: getBufferSize :ERROR : ${err}`); console.info(`AudioFrameworkRecLog: getBufferSize :ERROR : ${err}`);
}); });
``` ```
### on('markReach')<sup>8+</sup> ### on('markReach')<sup>8+</sup>
...@@ -5753,7 +5699,6 @@ audioCapturer.on('markReach', 1000, (position) => { ...@@ -5753,7 +5699,6 @@ audioCapturer.on('markReach', 1000, (position) => {
console.info('ON Triggered successfully'); console.info('ON Triggered successfully');
} }
}); });
``` ```
### off('markReach')<sup>8+</sup> ### off('markReach')<sup>8+</sup>
...@@ -5774,7 +5719,6 @@ Unsubscribes from mark reached events. ...@@ -5774,7 +5719,6 @@ Unsubscribes from mark reached events.
```js ```js
audioCapturer.off('markReach'); audioCapturer.off('markReach');
``` ```
### on('periodReach')<sup>8+</sup> ### on('periodReach')<sup>8+</sup>
...@@ -5801,7 +5745,6 @@ audioCapturer.on('periodReach', 1000, (position) => { ...@@ -5801,7 +5745,6 @@ audioCapturer.on('periodReach', 1000, (position) => {
console.info('ON Triggered successfully'); console.info('ON Triggered successfully');
} }
}); });
``` ```
### off('periodReach')<sup>8+</sup> ### off('periodReach')<sup>8+</sup>
...@@ -5822,10 +5765,9 @@ Unsubscribes from period reached events. ...@@ -5822,10 +5765,9 @@ Unsubscribes from period reached events.
```js ```js
audioCapturer.off('periodReach') audioCapturer.off('periodReach')
``` ```
### on('stateChange')<sup>8+</sup> ### on('stateChange') <sup>8+</sup>
on(type: 'stateChange', callback: Callback<AudioState\>): void on(type: 'stateChange', callback: Callback<AudioState\>): void
...@@ -5851,7 +5793,6 @@ audioCapturer.on('stateChange', (state) => { ...@@ -5851,7 +5793,6 @@ audioCapturer.on('stateChange', (state) => {
console.info('audio capturer state is: STATE_RUNNING'); console.info('audio capturer state is: STATE_RUNNING');
} }
}); });
``` ```
## ToneType<sup>9+</sup> ## ToneType<sup>9+</sup>
...@@ -5926,7 +5867,6 @@ tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_5, (err) => { ...@@ -5926,7 +5867,6 @@ tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_5, (err) => {
console.info('callback call load success'); console.info('callback call load success');
} }
}); });
``` ```
### load<sup>9+</sup> ### load<sup>9+</sup>
...@@ -5959,7 +5899,6 @@ tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_1).then(() => { ...@@ -5959,7 +5899,6 @@ tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_1).then(() => {
}).catch(() => { }).catch(() => {
console.error('promise call load fail'); console.error('promise call load fail');
}); });
``` ```
### start<sup>9+</sup> ### start<sup>9+</sup>
...@@ -5989,7 +5928,6 @@ tonePlayer.start((err) => { ...@@ -5989,7 +5928,6 @@ tonePlayer.start((err) => {
console.info('callback call start success'); console.info('callback call start success');
} }
}); });
``` ```
### start<sup>9+</sup> ### start<sup>9+</sup>
...@@ -6016,7 +5954,6 @@ tonePlayer.start().then(() => { ...@@ -6016,7 +5954,6 @@ tonePlayer.start().then(() => {
}).catch(() => { }).catch(() => {
console.error('promise call start fail'); console.error('promise call start fail');
}); });
``` ```
### stop<sup>9+</sup> ### stop<sup>9+</sup>
...@@ -6046,7 +5983,6 @@ tonePlayer.stop((err) => { ...@@ -6046,7 +5983,6 @@ tonePlayer.stop((err) => {
console.error('callback call stop success '); console.error('callback call stop success ');
} }
}); });
``` ```
### stop<sup>9+</sup> ### stop<sup>9+</sup>
...@@ -6073,7 +6009,6 @@ tonePlayer.stop().then(() => { ...@@ -6073,7 +6009,6 @@ tonePlayer.stop().then(() => {
}).catch(() => { }).catch(() => {
console.error('promise call stop fail'); console.error('promise call stop fail');
}); });
``` ```
### release<sup>9+</sup> ### release<sup>9+</sup>
...@@ -6103,7 +6038,6 @@ tonePlayer.release((err) => { ...@@ -6103,7 +6038,6 @@ tonePlayer.release((err) => {
console.info('callback call release success '); console.info('callback call release success ');
} }
}); });
``` ```
### release<sup>9+</sup> ### release<sup>9+</sup>
...@@ -6130,7 +6064,6 @@ tonePlayer.release().then(() => { ...@@ -6130,7 +6064,6 @@ tonePlayer.release().then(() => {
}).catch(() => { }).catch(() => {
console.error('promise call release fail'); console.error('promise call release fail');
}); });
``` ```
## ActiveDeviceType<sup>(deprecated)</sup> ## ActiveDeviceType<sup>(deprecated)</sup>
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
> **NOTE** > **NOTE**
> >
> The APIs of this module are supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version. > - The APIs of this module are supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version.
> - This API is deprecated since API version 9 and will be retained until API version 13.
> - Certain functionalities are changed as system APIs and can be used only by system applications. To use these functionalities, call [@ohos.filemanagement.userFileManager](js-apis-userFileManager.md).
> - The functionalities for selecting and storing media assets are still open to common applications. To use these functionalities, call [@ohos.file.picker](js-apis-file-picker.md).
## Modules to Import ## Modules to Import
```js ```js
...@@ -131,18 +134,13 @@ async function example() { ...@@ -131,18 +134,13 @@ async function example() {
console.info('fileAsset.displayName ' + '0 : ' + fileAsset.displayName); console.info('fileAsset.displayName ' + '0 : ' + fileAsset.displayName);
// Call getNextObject to obtain the next file until the last one. // Call getNextObject to obtain the next file until the last one.
for (let i = 1; i < count; i++) { for (let i = 1; i < count; i++) {
fetchFileResult.getNextObject((error, fileAsset) => { let fileAsset = await fetchFileResult.getNextObject();
if (fileAsset == undefined) {
console.error('get next object failed with error: ' + error);
return;
}
console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName); console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
})
} }
});
// Release the FetchFileResult instance and invalidate it. Other APIs can no longer be called. // Release the FetchFileResult instance and invalidate it. Other APIs can no longer be called.
fetchFileResult.close(); fetchFileResult.close();
}); });
});
} }
``` ```
...@@ -199,18 +197,15 @@ async function example() { ...@@ -199,18 +197,15 @@ async function example() {
console.info('fileAsset.displayName ' + '0 : ' + fileAsset.displayName); console.info('fileAsset.displayName ' + '0 : ' + fileAsset.displayName);
// Call getNextObject to obtain the next file until the last one. // Call getNextObject to obtain the next file until the last one.
for (let i = 1; i < count; i++) { for (let i = 1; i < count; i++) {
fetchFileResult.getNextObject().then((fileAsset) => { let fileAsset = await fetchFileResult.getNextObject();
console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName); console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
}).catch((error) => {
console.error('get next object failed with error: ' + error);
})
} }
// Release the FetchFileResult instance and invalidate it. Other APIs can no longer be called.
fetchFileResult.close();
}).catch((error) => { }).catch((error) => {
// Calling getFirstObject fails. // Calling getFirstObject fails.
console.error('get first object failed with error: ' + error); console.error('get first object failed with error: ' + error);
}); });
// Release the FetchFileResult instance and invalidate it. Other APIs can no longer be called.
fetchFileResult.close();
}).catch((error) => { }).catch((error) => {
// Calling getFileAssets fails. // Calling getFileAssets fails.
console.error('get file assets failed with error: ' + error); console.error('get file assets failed with error: ' + error);
...@@ -500,7 +495,7 @@ async function example() { ...@@ -500,7 +495,7 @@ async function example() {
### getAlbums<sup>7+</sup> ### getAlbums<sup>7+</sup>
getAlbums(options: MediaFetchOptions, callback: AsyncCallback<Array&lt;Album&gt;>): void getAlbums(options: MediaFetchOptions, callback: AsyncCallback&lt;Array&lt;Album&gt;&gt;): void
Obtains the albums. This API uses an asynchronous callback to return the result. Obtains the albums. This API uses an asynchronous callback to return the result.
...@@ -535,7 +530,7 @@ async function example() { ...@@ -535,7 +530,7 @@ async function example() {
### getAlbums<sup>7+</sup> ### getAlbums<sup>7+</sup>
getAlbums(options: MediaFetchOptions): Promise<Array&lt;Album&gt;> getAlbums(options: MediaFetchOptions): Promise&lt;Array&lt;Album&gt;&gt;
Obtains the albums. This API uses a promise to return the result. Obtains the albums. This API uses a promise to return the result.
...@@ -615,7 +610,7 @@ Call this API when you no longer need to use the APIs in the **MediaLibrary** in ...@@ -615,7 +610,7 @@ Call this API when you no longer need to use the APIs in the **MediaLibrary** in
media.release() media.release()
``` ```
### storeMediaAsset<sup>(deprecated)</sup> ### storeMediaAsset
storeMediaAsset(option: MediaAssetOption, callback: AsyncCallback&lt;string&gt;): void storeMediaAsset(option: MediaAssetOption, callback: AsyncCallback&lt;string&gt;): void
...@@ -623,7 +618,7 @@ Stores a media asset. This API uses an asynchronous callback to return the URI t ...@@ -623,7 +618,7 @@ Stores a media asset. This API uses an asynchronous callback to return the URI t
> **NOTE** > **NOTE**
> >
> This API is deprecated since API version 9. > This API is supported since API version 6 and can be used only by the FA model.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
...@@ -653,7 +648,7 @@ mediaLibrary.getMediaLibrary().storeMediaAsset(option, (error, value) => { ...@@ -653,7 +648,7 @@ mediaLibrary.getMediaLibrary().storeMediaAsset(option, (error, value) => {
``` ```
### storeMediaAsset<sup>(deprecated)</sup> ### storeMediaAsset
storeMediaAsset(option: MediaAssetOption): Promise&lt;string&gt; storeMediaAsset(option: MediaAssetOption): Promise&lt;string&gt;
...@@ -661,7 +656,7 @@ Stores a media asset. This API uses a promise to return the URI that stores the ...@@ -661,7 +656,7 @@ Stores a media asset. This API uses a promise to return the URI that stores the
> **NOTE** > **NOTE**
> >
> This API is deprecated since API version 9. > This API is supported since API version 6 and can be used only by the FA model.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
...@@ -694,15 +689,15 @@ mediaLibrary.getMediaLibrary().storeMediaAsset(option).then((value) => { ...@@ -694,15 +689,15 @@ mediaLibrary.getMediaLibrary().storeMediaAsset(option).then((value) => {
``` ```
### startImagePreview<sup>(deprecated)</sup> ### startImagePreview
startImagePreview(images: Array&lt;string&gt;, index: number, callback: AsyncCallback&lt;void&gt;): void startImagePreview(images: Array&lt;string&gt;, index: number, callback: AsyncCallback&lt;void&gt;): void
Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result. Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result.
> **NOTE** > **NOTE**
> > This API is supported since API version 6 and can be used only by the FA model.
> This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **\<Image>** component can be used to render and display local and online images. > You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **\<Image>** component can be used to render and display local and online images.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
...@@ -738,15 +733,15 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, index, (error) => { ...@@ -738,15 +733,15 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, index, (error) => {
``` ```
### startImagePreview<sup>(deprecated)</sup> ### startImagePreview
startImagePreview(images: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void startImagePreview(images: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void
Starts image preview. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result. Starts image preview. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result.
> **NOTE** > **NOTE**
> > This API is supported since API version 6 and can be used only by the FA model.
> This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **\<Image>** component can be used to render and display local and online images. > You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **\<Image>** component can be used to render and display local and online images.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
...@@ -780,15 +775,15 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, (error) => { ...@@ -780,15 +775,15 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, (error) => {
``` ```
### startImagePreview<sup>(deprecated)</sup> ### startImagePreview
startImagePreview(images: Array&lt;string&gt;, index?: number): Promise&lt;void&gt; startImagePreview(images: Array&lt;string&gt;, index?: number): Promise&lt;void&gt;
Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses a promise to return the execution result. Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses a promise to return the execution result.
> **NOTE** > **NOTE**
> > This API is supported since API version 6 and can be used only by the FA model.
> This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **\<Image>** component can be used to render and display local and online images. > You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **\<Image>** component can be used to render and display local and online images.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
...@@ -827,15 +822,15 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, index).then(() => { ...@@ -827,15 +822,15 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, index).then(() => {
``` ```
### startMediaSelect<sup>(deprecated)</sup> ### startMediaSelect
startMediaSelect(option: MediaSelectOption, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void startMediaSelect(option: MediaSelectOption, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
Starts media selection. This API uses an asynchronous callback to return the list of URIs that store the selected media assets. Starts media selection. This API uses an asynchronous callback to return the list of URIs that store the selected media assets.
> **NOTE** > **NOTE**
> > This API is supported since API version 6 and can be used only by the FA model.
> This API is deprecated since API version 9. You are advised to use the system app Gallery instead. Gallery is a built-in visual resource access application that provides features such as image and video management and browsing. For details about how to use Gallery, visit [OpenHarmony/applications_photos](https://gitee.com/openharmony/applications_photos). > You are advised to use the system app Gallery instead. Gallery is a built-in visual resource access application that provides features such as image and video management and browsing. For details about how to use Gallery, visit [OpenHarmony/applications_photos](https://gitee.com/openharmony/applications_photos).
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
...@@ -843,7 +838,7 @@ Starts media selection. This API uses an asynchronous callback to return the lis ...@@ -843,7 +838,7 @@ Starts media selection. This API uses an asynchronous callback to return the lis
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------------------------ | | -------- | ---------------------------------------- | ---- | ------------------------------------ |
| option | [MediaSelectOption](#mediaselectoptiondeprecated) | Yes | Media selection option. | | option | [MediaSelectOption](#mediaselectoption) | Yes | Media selection option. |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback used to return the list of URIs (starting with **datashare://**) that store the selected media assets.| | callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback used to return the list of URIs (starting with **datashare://**) that store the selected media assets.|
**Example** **Example**
...@@ -864,15 +859,15 @@ mediaLibrary.getMediaLibrary().startMediaSelect(option, (error, value) => { ...@@ -864,15 +859,15 @@ mediaLibrary.getMediaLibrary().startMediaSelect(option, (error, value) => {
``` ```
### startMediaSelect<sup>(deprecated)</sup> ### startMediaSelect
startMediaSelect(option: MediaSelectOption): Promise&lt;Array&lt;string&gt;&gt; startMediaSelect(option: MediaSelectOption): Promise&lt;Array&lt;string&gt;&gt;
Starts media selection. This API uses a promise to return the list of URIs that store the selected media assets. Starts media selection. This API uses a promise to return the list of URIs that store the selected media assets.
> **NOTE** > **NOTE**
> > This API is supported since API version 6 and can be used only by the FA model.
> This API is deprecated since API version 9. You are advised to use the system app Gallery instead. Gallery is a built-in visual resource access application that provides features such as image and video management and browsing. For details about how to use Gallery, visit [OpenHarmony/applications_photos](https://gitee.com/openharmony/applications_photos). > You are advised to use the system app Gallery instead. Gallery is a built-in visual resource access application that provides features such as image and video management and browsing. For details about how to use Gallery, visit [OpenHarmony/applications_photos](https://gitee.com/openharmony/applications_photos).
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
...@@ -880,7 +875,7 @@ Starts media selection. This API uses a promise to return the list of URIs that ...@@ -880,7 +875,7 @@ Starts media selection. This API uses a promise to return the list of URIs that
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | --------------------------------------- | ---- | ------- | | ------ | --------------------------------------- | ---- | ------- |
| option | [MediaSelectOption](#mediaselectoptiondeprecated) | Yes | Media selection option.| | option | [MediaSelectOption](#mediaselectoption) | Yes | Media selection option.|
**Return value** **Return value**
...@@ -1041,7 +1036,6 @@ async function example() { ...@@ -1041,7 +1036,6 @@ async function example() {
Provides APIs for encapsulating file asset attributes. Provides APIs for encapsulating file asset attributes.
> **NOTE** > **NOTE**
>
> 1. The system attempts to parse the file content if the file is an audio or video file. The actual field values will be restored from the passed values during scanning on some devices. > 1. The system attempts to parse the file content if the file is an audio or video file. The actual field values will be restored from the passed values during scanning on some devices.
> 2. Some devices may not support the modification of **orientation**. You are advised to use [ModifyImageProperty](js-apis-image.md#modifyimageproperty9) of the **image** module. > 2. Some devices may not support the modification of **orientation**. You are advised to use [ModifyImageProperty](js-apis-image.md#modifyimageproperty9) of the **image** module.
...@@ -1923,9 +1917,9 @@ async function example() { ...@@ -1923,9 +1917,9 @@ async function example() {
if(i == fetchCount - 1) { if(i == fetchCount - 1) {
var result = fetchFileResult.isAfterLast(); var result = fetchFileResult.isAfterLast();
console.info('mediaLibrary fileAsset isAfterLast result: ' + result); console.info('mediaLibrary fileAsset isAfterLast result: ' + result);
fetchFileResult.close();
} }
} }
fetchFileResult.close();
} }
``` ```
...@@ -1985,8 +1979,8 @@ async function example() { ...@@ -1985,8 +1979,8 @@ async function example() {
return; return;
} }
console.info('getFirstObject successfully, displayName : ' + fileAsset.displayName); console.info('getFirstObject successfully, displayName : ' + fileAsset.displayName);
})
fetchFileResult.close(); fetchFileResult.close();
})
} }
``` ```
...@@ -2018,10 +2012,10 @@ async function example() { ...@@ -2018,10 +2012,10 @@ async function example() {
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getFirstObject().then((fileAsset) => { fetchFileResult.getFirstObject().then((fileAsset) => {
console.info('getFirstObject successfully, displayName: ' + fileAsset.displayName); console.info('getFirstObject successfully, displayName: ' + fileAsset.displayName);
fetchFileResult.close();
}).catch((error) => { }).catch((error) => {
console.error('getFirstObject failed with error: ' + error); console.error('getFirstObject failed with error: ' + error);
}); });
fetchFileResult.close();
} }
``` ```
...@@ -2055,16 +2049,16 @@ async function example() { ...@@ -2055,16 +2049,16 @@ async function example() {
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
let fileAsset = await fetchFileResult.getFirstObject(); let fileAsset = await fetchFileResult.getFirstObject();
if (! fetchFileResult.isAfterLast) { if (!fileAsset.isAfterLast) {
fetchFileResult.getNextObject((error, fileAsset) => { fetchFileResult.getNextObject((error, fileAsset) => {
if (error) { if (error) {
console.error('fetchFileResult getNextObject failed with error: ' + error); console.error('fetchFileResult getNextObject failed with error: ' + error);
return; return;
} }
console.log('fetchFileResult getNextObject successfully, displayName: ' + fileAsset.displayName); console.log('fetchFileResult getNextObject successfully, displayName: ' + fileAsset.displayName);
fetchFileResult.close();
}) })
} }
fetchFileResult.close();
} }
``` ```
...@@ -2099,14 +2093,14 @@ async function example() { ...@@ -2099,14 +2093,14 @@ async function example() {
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
let fileAsset = await fetchFileResult.getFirstObject(); let fileAsset = await fetchFileResult.getFirstObject();
if (! fetchFileResult.isAfterLast) { if (!fileAsset.isAfterLast) {
fetchFileResult.getNextObject().then((fileAsset) => { fetchFileResult.getNextObject().then((fileAsset) => {
console.info('fetchFileResult getNextObject successfully, displayName: ' + fileAsset.displayName); console.info('fetchFileResult getNextObject successfully, displayName: ' + fileAsset.displayName);
fetchFileResult.close();
}).catch((error) => { }).catch((error) => {
console.error('fetchFileResult getNextObject failed with error: ' + error); console.error('fetchFileResult getNextObject failed with error: ' + error);
}) })
} }
fetchFileResult.close();
} }
``` ```
...@@ -2142,8 +2136,8 @@ async function example() { ...@@ -2142,8 +2136,8 @@ async function example() {
return; return;
} }
console.info('getLastObject successfully, displayName: ' + fileAsset.displayName); console.info('getLastObject successfully, displayName: ' + fileAsset.displayName);
})
fetchFileResult.close(); fetchFileResult.close();
})
} }
``` ```
...@@ -2175,10 +2169,10 @@ async function example() { ...@@ -2175,10 +2169,10 @@ async function example() {
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getLastObject().then((fileAsset) => { fetchFileResult.getLastObject().then((fileAsset) => {
console.info('getLastObject successfully, displayName: ' + fileAsset.displayName); console.info('getLastObject successfully, displayName: ' + fileAsset.displayName);
fetchFileResult.close();
}).catch((error) => { }).catch((error) => {
console.error('getLastObject failed with error: ' + error); console.error('getLastObject failed with error: ' + error);
}); });
fetchFileResult.close();
} }
``` ```
...@@ -2215,8 +2209,8 @@ async function example() { ...@@ -2215,8 +2209,8 @@ async function example() {
return; return;
} }
console.info('getPositionObject successfully, displayName: ' + fileAsset.displayName); console.info('getPositionObject successfully, displayName: ' + fileAsset.displayName);
})
fetchFileResult.close(); fetchFileResult.close();
})
} }
``` ```
...@@ -2254,10 +2248,10 @@ async function example() { ...@@ -2254,10 +2248,10 @@ async function example() {
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getPositionObject(0).then((fileAsset) => { fetchFileResult.getPositionObject(0).then((fileAsset) => {
console.info('getPositionObject successfully, displayName: ' + fileAsset.displayName); console.info('getPositionObject successfully, displayName: ' + fileAsset.displayName);
fetchFileResult.close();
}).catch((error) => { }).catch((error) => {
console.error('getPositionObject failed with error: ' + error); console.error('getPositionObject failed with error: ' + error);
}); });
fetchFileResult.close();
} }
``` ```
...@@ -2295,8 +2289,8 @@ async function example() { ...@@ -2295,8 +2289,8 @@ async function example() {
for (let i = 0; i < fetchFileResult.getCount(); i++) { for (let i = 0; i < fetchFileResult.getCount(); i++) {
console.info('getAllObject fileAssetList ' + i + ' displayName: ' + fileAssetList[i].displayName); console.info('getAllObject fileAssetList ' + i + ' displayName: ' + fileAssetList[i].displayName);
} }
})
fetchFileResult.close(); fetchFileResult.close();
})
} }
``` ```
...@@ -2330,10 +2324,10 @@ async function example() { ...@@ -2330,10 +2324,10 @@ async function example() {
for (let i = 0; i < fetchFileResult.getCount(); i++) { for (let i = 0; i < fetchFileResult.getCount(); i++) {
console.info('getAllObject fileAssetList ' + i + ' displayName: ' + fileAssetList[i].displayName); console.info('getAllObject fileAssetList ' + i + ' displayName: ' + fileAssetList[i].displayName);
} }
fetchFileResult.close();
}).catch((error) => { }).catch((error) => {
console.error('getAllObject failed with error: ' + error); console.error('getAllObject failed with error: ' + error);
}); });
fetchFileResult.close();
} }
``` ```
...@@ -2465,10 +2459,10 @@ async function example() { ...@@ -2465,10 +2459,10 @@ async function example() {
console.error('album getFileAssets failed with error: ' + error); console.error('album getFileAssets failed with error: ' + error);
return; return;
} }
let count = fetchFileResult.getcount(); let count = fetchFileResult.getCount();
console.info('album getFileAssets successfully, count: ' + count); console.info('album getFileAssets successfully, count: ' + count);
});
fetchFileResult.close(); fetchFileResult.close();
});
} }
``` ```
...@@ -2510,13 +2504,13 @@ async function example() { ...@@ -2510,13 +2504,13 @@ async function example() {
const albumList = await media.getAlbums(AlbumNoArgsfetchOp); const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
const album = albumList[0]; const album = albumList[0];
// Obtain an album from the album list and obtain all media assets that meet the retrieval options in the album. // Obtain an album from the album list and obtain all media assets that meet the retrieval options in the album.
album.getFileAssets(fileNoArgsfetchOp).then((albumFetchFileResult) => { album.getFileAssets(fileNoArgsfetchOp).then((fetchFileResult) => {
let count = fetchFileResult.getcount(); let count = fetchFileResult.getCount();
console.info('album getFileAssets successfully, count: ' + count); console.info('album getFileAssets successfully, count: ' + count);
fetchFileResult.close();
}).catch((error) => { }).catch((error) => {
console.error('album getFileAssets failed with error: ' + error); console.error('album getFileAssets failed with error: ' + error);
}); });
fetchFileResult.close();
} }
``` ```
...@@ -2555,7 +2549,6 @@ Enumerates media types. ...@@ -2555,7 +2549,6 @@ Enumerates media types.
Enumerates key file information. Enumerates key file information.
> **NOTE** > **NOTE**
>
> The **bucket_id** field may change after file rename or movement. Therefore, you must obtain the field again before using it. > The **bucket_id** field may change after file rename or movement. Therefore, you must obtain the field again before using it.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
...@@ -2641,14 +2634,10 @@ Describes the image size. ...@@ -2641,14 +2634,10 @@ Describes the image size.
| width | number | Yes | Yes | Image width, in pixels.| | width | number | Yes | Yes | Image width, in pixels.|
| height | number | Yes | Yes | Image height, in pixels.| | height | number | Yes | Yes | Image height, in pixels.|
## MediaAssetOption<sup>(deprecated)</sup> ## MediaAssetOption
Implements the media asset option. Implements the media asset option.
> **NOTE**
>
> This API is deprecated since API version 9.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
...@@ -2658,17 +2647,13 @@ Implements the media asset option. ...@@ -2658,17 +2647,13 @@ Implements the media asset option.
| mimeType | string | Yes | Yes | Multipurpose Internet Mail Extensions (MIME) type of the media.<br>The value can be 'image/\*', 'video/\*', 'audio/\*' or 'file\*'.| | mimeType | string | Yes | Yes | Multipurpose Internet Mail Extensions (MIME) type of the media.<br>The value can be 'image/\*', 'video/\*', 'audio/\*' or 'file\*'.|
| relativePath | string | Yes | Yes | Custom path for storing media assets, for example, 'Pictures/'. If this parameter is unspecified, media assets are stored in the default path.<br> Default path of images: 'Pictures/'<br> Default path of videos: 'Videos/'<br> Default path of audios: 'Audios/'<br> Default path of files: 'Documents/'| | relativePath | string | Yes | Yes | Custom path for storing media assets, for example, 'Pictures/'. If this parameter is unspecified, media assets are stored in the default path.<br> Default path of images: 'Pictures/'<br> Default path of videos: 'Videos/'<br> Default path of audios: 'Audios/'<br> Default path of files: 'Documents/'|
## MediaSelectOption<sup>(deprecated)</sup> ## MediaSelectOption
Describes media selection option. Describes media selection option.
> **NOTE**
>
> This API is deprecated since API version 9.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ----- | ------ | ---- | ---- | -------------------- | | ----- | ------ | ---- | ---- | -------------------- |
| type | 'image' &#124; 'video' &#124; 'media' | Yes | Yes | Media type, which can be **image**, **media**, or **video**. Currently, only **media** is supported.| | type | 'image' &#124; 'video' &#124; 'media' | Yes | Yes | Media type, which can be **image**, **media**, or **video**. Currently, only **media** is supported.|
| count | number | Yes | Yes | Number of media assets selected. The value starts from 1, which indicates that one media asset can be selected. | | count | number | Yes | Yes | Maximum number of media assets that can be selected. The value starts from 1, which indicates that one media asset can be selected. |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册