提交 962a9d03 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 bb4603ba
...@@ -39,36 +39,36 @@ function printfDescription(obj) { ...@@ -39,36 +39,36 @@ function printfDescription(obj) {
// Set the player callbacks. // Set the player callbacks.
function setCallBack(audioPlayer) { 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'); 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.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'); console.info('audio play success');
audioPlayer.pause(); // Trigger the 'pause' event callback and pause the playback. 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'); console.info('audio pause success');
audioPlayer.seek(5000); // Trigger the 'timeUpdate' event callback, and seek to 5000 ms for playback. 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'); console.info('audio stop success');
audioPlayer.reset(); // Trigger the 'reset' event callback, and reconfigure the src attribute to switch to the next song. 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'); console.info('audio reset success');
audioPlayer.release(); // Release the AudioPlayer resources. audioPlayer.release(); // Release the AudioPlayer resources.
audioPlayer = undefined; audioPlayer = undefined;
}); });
audioPlayer.on('timeUpdate', (seekDoneTime) => {// Set the 'timeUpdate' event callback. audioPlayer.on('timeUpdate', (seekDoneTime) => {// Set the timeUpdate event callback.
if (typeof(seekDoneTime) == 'undefined') { if (typeof(seekDoneTime) == 'undefined') {
console.info('audio seek fail'); console.info('audio seek fail');
return; return;
} }
console.info('audio seek success, and seek time is ' + seekDoneTime); console.info('audio seek success, and seek time is ' + seekDoneTime);
audioPlayer.setVolume(0.5); // Trigger the 'volumeChange' event callback. 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'); console.info('audio volumeChange success');
audioPlayer.getTrackDescription((error, arrlist) => { // Obtain the audio track information in callback mode. audioPlayer.getTrackDescription((error, arrlist) => { // Obtain the audio track information in callback mode.
if (typeof (arrlist) != 'undefined') { if (typeof (arrlist) != 'undefined') {
...@@ -78,13 +78,13 @@ function setCallBack(audioPlayer) { ...@@ -78,13 +78,13 @@ function setCallBack(audioPlayer) {
} else { } else {
console.log(`audio getTrackDescription fail, error:${error.message}`); console.log(`audio getTrackDescription fail, error:${error.message}`);
} }
audioPlayer.stop(); // Trigger the 'stop' event callback to stop the playback. audioPlayer.stop(); // Trigger the stop event callback to stop the playback.
}); });
}); });
audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. audioPlayer.on('finish', () => { // Set the finish event callback, which is triggered when the playback is complete.
console.info('audio play finish'); console.info('audio play finish');
}); });
audioPlayer.on('error', (error) => { // Set the 'error' event callback. audioPlayer.on('error', (error) => { // Set the error event callback.
console.info(`audio error called, errName is ${error.name}`); console.info(`audio error called, errName is ${error.name}`);
console.info(`audio error called, errCode is ${error.code}`); console.info(`audio error called, errCode is ${error.code}`);
console.info(`audio error called, errMessage is ${error.message}`); console.info(`audio error called, errMessage is ${error.message}`);
...@@ -92,10 +92,10 @@ function setCallBack(audioPlayer) { ...@@ -92,10 +92,10 @@ function setCallBack(audioPlayer) {
} }
async function audioPlayerDemo() { async function audioPlayerDemo() {
// 1. Create an audioPlayer instance. // 1. Create an AudioPlayer instance.
let audioPlayer = media.createAudioPlayer(); let audioPlayer = media.createAudioPlayer();
setCallBack(audioPlayer); // Set the event callbacks. setCallBack(audioPlayer); // Set the event callbacks.
// 2. Set the URI of the audio file selected by the user. // 2. Set the URI of the audio file.
let fdPath = 'fd://' let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3';
...@@ -107,7 +107,7 @@ async function audioPlayerDemo() { ...@@ -107,7 +107,7 @@ async function audioPlayerDemo() {
}).catch((err) => { }).catch((err) => {
console.info('open fd failed err is' + 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,14 +119,14 @@ import fileIO from '@ohos.fileio' ...@@ -119,14 +119,14 @@ import fileIO from '@ohos.fileio'
export class AudioDemo { export class AudioDemo {
// Set the player callbacks. // Set the player callbacks.
setCallBack(audioPlayer) { 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'); console.info('audio set source success');
audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. 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'); console.info('audio play success');
}); });
audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. audioPlayer.on('finish', () => { // Set the finish event callback, which is triggered when the playback is complete.
console.info('audio play finish'); console.info('audio play finish');
audioPlayer.release(); // Release the AudioPlayer resources. audioPlayer.release(); // Release the AudioPlayer resources.
audioPlayer = undefined; audioPlayer = undefined;
...@@ -147,7 +147,7 @@ export class AudioDemo { ...@@ -147,7 +147,7 @@ export class AudioDemo {
}).catch((err) => { }).catch((err) => {
console.info('open fd failed err is' + 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 { ...@@ -161,15 +161,15 @@ export class AudioDemo {
// Set the player callbacks. // Set the player callbacks.
private isNextMusic = false; private isNextMusic = false;
setCallBack(audioPlayer) { 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'); console.info('audio set source success');
audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. 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'); console.info('audio play success');
audioPlayer.reset(); // Call the reset() API and trigger the 'reset' event callback. 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'); console.info('audio play success');
if (!this.isNextMusic) { // When isNextMusic is false, changing songs is implemented. if (!this.isNextMusic) { // When isNextMusic is false, changing songs is implemented.
this.nextMusic(audioPlayer); // Changing songs is implemented. this.nextMusic(audioPlayer); // Changing songs is implemented.
...@@ -193,7 +193,7 @@ export class AudioDemo { ...@@ -193,7 +193,7 @@ export class AudioDemo {
}).catch((err) => { }).catch((err) => {
console.info('open fd failed err is' + err); console.info('open fd failed err is' + err);
}); });
audioPlayer.src = nextFdPath; // Set the src attribute and trigger the 'dataLoad' event callback. audioPlayer.src = nextFdPath; // Set the src attribute and trigger the dataLoad event callback.
} }
async audioPlayerDemo() { async audioPlayerDemo() {
...@@ -210,7 +210,7 @@ export class AudioDemo { ...@@ -210,7 +210,7 @@ export class AudioDemo {
}).catch((err) => { }).catch((err) => {
console.info('open fd failed err is' + 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.
} }
} }
``` ```
...@@ -223,12 +223,12 @@ import fileIO from '@ohos.fileio' ...@@ -223,12 +223,12 @@ import fileIO from '@ohos.fileio'
export class AudioDemo { export class AudioDemo {
// Set the player callbacks. // Set the player callbacks.
setCallBack(audioPlayer) { 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'); console.info('audio set source success');
audioPlayer.loop = true; // Set the loop playback attribute. audioPlayer.loop = true; // Set the loop playback attribute.
audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. audioPlayer.play(); // Call the play() API to start the playback and trigger the play event callback.
}); });
audioPlayer.on('play', () => { // Sets the 'play' event callback to start loop playback. audioPlayer.on('play', () => { // Sets the play event callback to start loop playback.
console.info('audio play success'); console.info('audio play success');
}); });
} }
...@@ -247,7 +247,7 @@ export class AudioDemo { ...@@ -247,7 +247,7 @@ export class AudioDemo {
}).catch((err) => { }).catch((err) => {
console.info('open fd failed err is' + 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.
} }
} }
``` ```
...@@ -256,7 +256,7 @@ export class AudioDemo { ...@@ -256,7 +256,7 @@ export class AudioDemo {
The following samples are provided to help you better understand how to develop audio playback: The following samples are provided to help you better understand how to develop audio playback:
- [`JsDistributedMusicPlayer`: Distributed Music Player (JS) (API7)](https://gitee.com/openharmony/app_samples/tree/master/ability/JsDistributedMusicPlayer) - [<idp:inline class="- topic/inline " val="code" displayname="code" id="code04927441464" tempcmdid="code04927441464">JsDistributedMusicPlayer</idp:inline>: Distributed Music Player (JS, API version 7)](https://gitee.com/openharmony/app_samples/tree/master/ability/JsDistributedMusicPlayer)
- [`JsAudioPlayer`: Audio Playback and Management (JS, API 7)](https://gitee.com/openharmony/app_samples/tree/master/media/JsAudioPlayer) - [<idp:inline class="- topic/inline " val="code" displayname="code" id="code4276559568" tempcmdid="code4276559568">JsAudioPlayer</idp:inline>: Audio Playback and Management (JS, API version 7)](https://gitee.com/openharmony/app_samples/tree/master/media/JsAudioPlayer)
- [`eTsAudioPlayer`: Audio Player (eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) - [<idp:inline class="- topic/inline " val="code" displayname="code" id="code246413101579" tempcmdid="code246413101579">eTsAudioPlayer</idp:inline>: Audio Player (eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets)
- [Audio Player](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS) - [Audio Player](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS)
...@@ -30,35 +30,35 @@ export class AudioRecorderDemo { ...@@ -30,35 +30,35 @@ export class AudioRecorderDemo {
// Set the callbacks related to audio recording. // Set the callbacks related to audio recording.
setCallBack(audioRecorder) { setCallBack(audioRecorder) {
audioRecorder.on('prepare', () => { // Set the 'prepare' event callback. audioRecorder.on('prepare', () => { // Set the prepare event callback.
console.log('prepare success'); console.log('prepare success');
audioRecorder.start(); // Call the start API to start recording and trigger the 'start' event callback. audioRecorder.start(); // Call the start API to 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'); console.log('audio recorder start success');
audioRecorder.pause(); // Call the pause API to pause recording and trigger the 'pause' event callback. audioRecorder.pause(); // Call the pause API to pause recording and trigger the pause event callback.
}); });
audioRecorder.on('pause', () => { // Set the 'pause' event callback. audioRecorder.on('pause', () => { // Set the pause event callback.
console.log('audio recorder pause success'); console.log('audio recorder pause success');
audioRecorder.resume(); // Call the resume API to resume recording and trigger the 'resume' event callback. audioRecorder.resume(); // Call the resume API to resume recording and trigger the resume event callback.
}); });
audioRecorder.on('resume', () => { // Set the 'resume' event callback. audioRecorder.on('resume', () => { // Set the resume event callback.
console.log('audio recorder resume success'); console.log('audio recorder resume success');
audioRecorder.stop(); // Call the stop API to stop recording and trigger the 'stop' event callback. audioRecorder.stop(); // Call the stop API to stop recording and trigger the stop event callback.
}); });
audioRecorder.on('stop', () => { // Set the 'stop' event callback. audioRecorder.on('stop', () => { // Set the stop event callback.
console.log('audio recorder stop success'); console.log('audio recorder stop success');
audioRecorder.reset(); // Call the reset API to reset the recorder and trigger the 'reset' event callback. audioRecorder.reset(); // Call the reset API to reset the recorder and trigger the reset event callback.
}); });
audioRecorder.on('reset', () => { // Set the 'reset' event callback. audioRecorder.on('reset', () => { // Set the reset event callback.
console.log('audio recorder reset success'); console.log('audio recorder reset success');
audioRecorder.release(); // Call the release API to release resources and trigger the 'release' event callback. audioRecorder.release(); // Call the release API to release resources and trigger the release event callback.
}); });
audioRecorder.on('release', () => { // Set the 'release' event callback. audioRecorder.on('release', () => { // Set the release event callback.
console.log('audio recorder release success'); console.log('audio recorder release success');
audioRecorder = undefined; audioRecorder = undefined;
}); });
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, errName is ${error.name}`);
console.info(`audio error called, errCode is ${error.code}`); console.info(`audio error called, errCode is ${error.code}`);
console.info(`audio error called, errMessage is ${error.message}`); console.info(`audio error called, errMessage is ${error.message}`);
...@@ -103,7 +103,7 @@ export class AudioRecorderDemo { ...@@ -103,7 +103,7 @@ export class AudioRecorderDemo {
audioEncoderMime : media.CodecMimeType.AUDIO_AAC, audioEncoderMime : media.CodecMimeType.AUDIO_AAC,
fileFormat : media.ContainerFormatType.CFT_MPEG_4A, fileFormat : media.ContainerFormatType.CFT_MPEG_4A,
} }
audioRecorder.prepare(audioRecorderConfig); // Call the prepare method to trigger the 'prepare' event callback. audioRecorder.prepare(audioRecorderConfig); // Call the prepare method to trigger the prepare event callback.
} }
} }
``` ```
...@@ -120,23 +120,23 @@ export class AudioRecorderDemo { ...@@ -120,23 +120,23 @@ export class AudioRecorderDemo {
// Set the callbacks related to audio recording. // Set the callbacks related to audio recording.
setCallBack(audioRecorder) { setCallBack(audioRecorder) {
audioRecorder.on('prepare', () => { // Set the 'prepare' event callback. audioRecorder.on('prepare', () => { // Set the prepare event callback.
console.log('prepare success'); console.log('prepare success');
audioRecorder.start(); // Call the start API to start recording and trigger the 'start' event callback. audioRecorder.start(); // Call the start API to 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'); console.log('audio recorder start success');
audioRecorder.stop(); // Call the stop API to stop recording and trigger the 'stop' event callback. audioRecorder.stop(); // Call the stop API to stop recording and trigger the stop event callback.
}); });
audioRecorder.on('stop', () => { // Set the 'stop' event callback. audioRecorder.on('stop', () => { // Set the stop event callback.
console.log('audio recorder stop success'); console.log('audio recorder stop success');
audioRecorder.release(); // Call the release API to release resources and trigger the 'release' event callback. audioRecorder.release(); // Call the release API to release resources and trigger the release event callback.
}); });
audioRecorder.on('release', () => { // Set the 'release' event callback. audioRecorder.on('release', () => { // Set the release event callback.
console.log('audio recorder release success'); console.log('audio recorder release success');
audioRecorder = undefined; audioRecorder = undefined;
}); });
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, errName is ${error.name}`);
console.info(`audio error called, errCode is ${error.code}`); console.info(`audio error called, errCode is ${error.code}`);
console.info(`audio error called, errMessage is ${error.message}`); console.info(`audio error called, errMessage is ${error.message}`);
...@@ -181,7 +181,7 @@ export class AudioRecorderDemo { ...@@ -181,7 +181,7 @@ export class AudioRecorderDemo {
audioEncoderMime : media.CodecMimeType.AUDIO_AAC, audioEncoderMime : media.CodecMimeType.AUDIO_AAC,
fileFormat : media.ContainerFormatType.CFT_MPEG_4A, fileFormat : media.ContainerFormatType.CFT_MPEG_4A,
} }
audioRecorder.prepare(audioRecorderConfig); // Call the prepare method to trigger the 'prepare' event callback. audioRecorder.prepare(audioRecorderConfig); // Call the prepare method to trigger the prepare event callback.
} }
} }
``` ```
...@@ -190,6 +190,7 @@ export class AudioRecorderDemo { ...@@ -190,6 +190,7 @@ export class AudioRecorderDemo {
The following samples are provided to help you better understand how to develop audio recording: The following samples are provided to help you better understand how to develop audio recording:
- [`Recorder`: Recorder (eTS, API 8)](https://gitee.com/openharmony/app_samples/tree/master/media/Recorder) - [<idp:inline class="- topic/inline " val="code" displayname="code" id="code15884933169" tempcmdid="code15884933169">Recorder</idp:inline>: Recorder (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/media/Recorder)
- [`eTsAudioPlayer`: Audio Player (eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) - [<idp:inline class="- topic/inline " val="code" displayname="code" id="code563211231612" tempcmdid="code563211231612">JsRecorder</idp:inline>: Recorder (JS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/media/JSRecorder)
- [<idp:inline class="- topic/inline " val="code" displayname="code" id="code7932192919168" tempcmdid="code7932192919168">eTsAudioPlayer</idp:inline>: Audio Player (eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets)
- [Audio Player](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS) - [Audio Player](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS)
...@@ -76,7 +76,7 @@ export class VideoPlayerDemo { ...@@ -76,7 +76,7 @@ export class VideoPlayerDemo {
async videoPlayerDemo() { async videoPlayerDemo() {
let videoPlayer = undefined; let videoPlayer = undefined;
let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent interface. For details about the document link, see the method of creating the XComponent. let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent API. For details about the document link, see the method of creating the XComponent.
let fdPath = 'fd://' let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command. // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4'; let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4';
...@@ -97,7 +97,7 @@ export class VideoPlayerDemo { ...@@ -97,7 +97,7 @@ export class VideoPlayerDemo {
console.info('createVideoPlayer fail!'); console.info('createVideoPlayer fail!');
} }
}, this.failureCallback).catch(this.catchCallback); }, this.failureCallback).catch(this.catchCallback);
// Set the playback source URL for the player. // Set the playback source for the player.
videoPlayer.url = fdPath; videoPlayer.url = fdPath;
// Set the surface ID to display the video image. // Set the surface ID to display the video image.
...@@ -134,19 +134,19 @@ export class VideoPlayerDemo { ...@@ -134,19 +134,19 @@ export class VideoPlayerDemo {
this.printfDescription(arrayDescription[i]); this.printfDescription(arrayDescription[i]);
} }
// Seek to the 50s position. For details about the input parameters, see the interface document. // Seek to the 50s position. For details about the input parameters, see the API document.
let seekTime = 50000; let seekTime = 50000;
await videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => { await videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
console.info('seek success'); console.info('seek success');
}, this.failureCallback).catch(this.catchCallback); }, this.failureCallback).catch(this.catchCallback);
// Set the volume. For details about the input parameters, see the interface document. // Set the volume. For details about the input parameters, see the API document.
let volume = 0.5; let volume = 0.5;
await videoPlayer.setVolume(volume).then(() => { await videoPlayer.setVolume(volume).then(() => {
console.info('setVolume success'); console.info('setVolume success');
}, this.failureCallback).catch(this.catchCallback); }, this.failureCallback).catch(this.catchCallback);
// Set the playback speed. For details about the input parameters, see the interface document. // Set the playback speed. For details about the input parameters, see the API document.
let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X; let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X;
await videoPlayer.setSpeed(speed).then(() => { await videoPlayer.setSpeed(speed).then(() => {
console.info('setSpeed success'); console.info('setSpeed success');
...@@ -205,7 +205,7 @@ export class VideoPlayerDemo { ...@@ -205,7 +205,7 @@ export class VideoPlayerDemo {
async videoPlayerDemo() { async videoPlayerDemo() {
let videoPlayer = undefined; let videoPlayer = undefined;
let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent interface. For details about the document link, see the method of creating the XComponent. let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent API. For details about the document link, see the method of creating the XComponent.
let fdPath = 'fd://' let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command. // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4'; let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4';
...@@ -292,7 +292,7 @@ export class VideoPlayerDemo { ...@@ -292,7 +292,7 @@ export class VideoPlayerDemo {
async videoPlayerDemo() { async videoPlayerDemo() {
let videoPlayer = undefined; let videoPlayer = undefined;
let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent interface. For details about the document link, see the method of creating the XComponent. let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent API. For details about the document link, see the method of creating the XComponent.
let fdPath = 'fd://' let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command. // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4'; let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4';
...@@ -350,7 +350,7 @@ export class VideoPlayerDemo { ...@@ -350,7 +350,7 @@ export class VideoPlayerDemo {
// Set the second video playback source. // Set the second video playback source.
videoPlayer.url = fdPath; videoPlayer.url = fdPath;
// Call the prepare interface to prepare for playback. // Call the prepare API to prepare for playback.
await videoPlayer.prepare().then(() => { await videoPlayer.prepare().then(() => {
console.info('prepare success'); console.info('prepare success');
}, this.failureCallback).catch(this.catchCallback); }, this.failureCallback).catch(this.catchCallback);
...@@ -407,7 +407,7 @@ export class VideoPlayerDemo { ...@@ -407,7 +407,7 @@ export class VideoPlayerDemo {
async videoPlayerDemo() { async videoPlayerDemo() {
let videoPlayer = undefined; let videoPlayer = undefined;
let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent interface. For details about the document link, see the method of creating the XComponent. let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent API. For details about the document link, see the method of creating the XComponent.
let fdPath = 'fd://' let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command. // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4'; let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4';
...@@ -462,3 +462,7 @@ export class VideoPlayerDemo { ...@@ -462,3 +462,7 @@ export class VideoPlayerDemo {
} }
} }
``` ```
## Samples
The following samples are provided to help you better understand how to develop video playback:
- [`VideoPlayer`: Video Playback (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/media/VideoPlayer)
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
- [Getting Started with JavaScript in the Low-Code Approach](quick-start/start-with-js-low-code.md) - [Getting Started with JavaScript in the Low-Code Approach](quick-start/start-with-js-low-code.md)
- Development Fundamentals - Development Fundamentals
- [Application Package Structure Configuration File (FA Model)](quick-start/package-structure.md) - [Application Package Structure Configuration File (FA Model)](quick-start/package-structure.md)
- [Application Package Structure Configuration File (Stage Model)](quick-start/module-structure.md) - [Application Package Structure Configuration File (Stage Model)](quick-start/stage-structure.md)
- [Resource File Categories](quick-start/basic-resource-file-categories.md) - [Resource File Categories](quick-start/basic-resource-file-categories.md)
- [SysCap Usage Guidelines](quick-start/syscap.md) - [SysCap](quick-start/syscap.md)
- Development - Development
- Ability Development - Ability Development
- [Ability Framework Overview](ability/ability-brief.md) - [Ability Framework Overview](ability/ability-brief.md)
...@@ -22,19 +22,20 @@ ...@@ -22,19 +22,20 @@
- [Page Ability Development](ability/fa-pageability.md) - [Page Ability Development](ability/fa-pageability.md)
- [Service Ability Development](ability/fa-serviceability.md) - [Service Ability Development](ability/fa-serviceability.md)
- [Data Ability Development](ability/fa-dataability.md) - [Data Ability Development](ability/fa-dataability.md)
- [FA Widget Development](ability/fa-formability.md) - [FA Widget Development](ability/fa-formability.md)
- Stage Model - Stage Model
- [Stage Model Overview](ability/stage-brief.md) - [Stage Model Overview](ability/stage-brief.md)
- [Ability Development](ability/stage-ability.md) - [Ability Development](ability/stage-ability.md)
- [Service Extension Ability Development](ability/stage-serviceextension.md) - [Service Extension Ability Development](ability/stage-serviceextension.md)
- [Ability Continuation Development](ability/stage-ability-continuation.md) - [Ability Continuation Development](ability/stage-ability-continuation.md)
- [Ability Call Developmen](ability/stage-call.md) - [Ability Call Development](ability/stage-call.md)
- [Stage Widget Development](ability/stage-formextension.md) - [Stage Widget Development](ability/stage-formextension.md)
- Other - Other
- [WantAgent Development](ability/wantagent.md) - [WantAgent Development](ability/wantagent.md)
- [Ability Assistant Usage](ability/ability-assistant-guidelines.md) - [Ability Assistant Usage](ability/ability-assistant-guidelines.md)
- [Test Framework Usage](ability/ability-delegator.md) - [Test Framework Usage](ability/ability-delegator.md)
- UI - UI Development
- [ArkUI Overview](ui/arkui-overview.md) - [ArkUI Overview](ui/arkui-overview.md)
- JavaScript-based Web-Like Development Paradigm - JavaScript-based Web-Like Development Paradigm
- [Overview](ui/ui-js-overview.md) - [Overview](ui/ui-js-overview.md)
...@@ -126,7 +127,7 @@ ...@@ -126,7 +127,7 @@
- General UI Description Specifications - General UI Description Specifications
- [Basic Concepts](ui/ts-general-ui-concepts.md) - [Basic Concepts](ui/ts-general-ui-concepts.md)
- Declarative UI Description Specifications - Declarative UI Description Specifications
- [Parameterless Configuration](ui/ts-parameterless-configuration.md) - [Configuration Without Parameters](ui/ts-parameterless-configuration.md)
- [Configuration with Mandatory Parameters](ui/ts-configuration-with-mandatory-parameters.md) - [Configuration with Mandatory Parameters](ui/ts-configuration-with-mandatory-parameters.md)
- [Attribution Configuration](ui/ts-attribution-configuration.md) - [Attribution Configuration](ui/ts-attribution-configuration.md)
- [Event Configuration](ui/ts-event-configuration.md) - [Event Configuration](ui/ts-event-configuration.md)
...@@ -159,7 +160,7 @@ ...@@ -159,7 +160,7 @@
- [LazyForEach](ui/ts-rending-control-syntax-lazyforeach.md) - [LazyForEach](ui/ts-rending-control-syntax-lazyforeach.md)
- About @Component - About @Component
- [build Function](ui/ts-function-build.md) - [build Function](ui/ts-function-build.md)
- [Custom Component Initialization](ui/ts-custom-component-initialization.md) - [Initialization of Custom Components' Member Variables](ui/ts-custom-component-initialization.md)
- [Custom Component Lifecycle Callbacks](ui/ts-custom-component-lifecycle-callbacks.md) - [Custom Component Lifecycle Callbacks](ui/ts-custom-component-lifecycle-callbacks.md)
- [Example: Component Creation and Re-Initialization](ui/ts-component-creation-re-initialization.md) - [Example: Component Creation and Re-Initialization](ui/ts-component-creation-re-initialization.md)
- [Syntactic Sugar](ui/ts-syntactic-sugar.md) - [Syntactic Sugar](ui/ts-syntactic-sugar.md)
...@@ -233,7 +234,7 @@ ...@@ -233,7 +234,7 @@
- [Socket Connection](connectivity/socket-connection.md) - [Socket Connection](connectivity/socket-connection.md)
- IPC & RPC - IPC & RPC
- [IPC & RPC Overview](connectivity/ipc-rpc-overview.md) - [IPC & RPC Overview](connectivity/ipc-rpc-overview.md)
- [IPC & RPC Development Guidelines](connectivity/ipc-rpc-development-guideline.md) - [IPC & RPC Development](connectivity/ipc-rpc-development-guideline.md)
- [Subscribing to State Changes of a Remote Object](connectivity/subscribe-remote-state.md) - [Subscribing to State Changes of a Remote Object](connectivity/subscribe-remote-state.md)
- Telephony - Telephony
- [Telephony Service Overview](telephony/telephony-overview.md) - [Telephony Service Overview](telephony/telephony-overview.md)
...@@ -243,7 +244,7 @@ ...@@ -243,7 +244,7 @@
- Distributed Data Service - Distributed Data Service
- [Distributed Data Service Overview](database/database-mdds-overview.md) - [Distributed Data Service Overview](database/database-mdds-overview.md)
- [Distributed Data Service Development](database/database-mdds-guidelines.md) - [Distributed Data Service Development](database/database-mdds-guidelines.md)
- Relational Database Overview - Relational Database
- [RDB Overview](database/database-relational-overview.md) - [RDB Overview](database/database-relational-overview.md)
- [RDB Development](database/database-relational-guidelines.md) - [RDB Development](database/database-relational-guidelines.md)
- Lightweight Data Store - Lightweight Data Store
...@@ -252,7 +253,7 @@ ...@@ -252,7 +253,7 @@
- Distributed Data Object - Distributed Data Object
- [Distributed Data Object Overview](database/database-distributedobject-overview.md) - [Distributed Data Object Overview](database/database-distributedobject-overview.md)
- [Distributed Data Object Development](database/database-distributedobject-guidelines.md) - [Distributed Data Object Development](database/database-distributedobject-guidelines.md)
- Agent-Powered Scheduled Reminders - Agent-Powered Scheduled Reminder
- [Agent-Powered Scheduled Reminder Overview](background-agent-scheduled-reminder/background-agent-scheduled-reminder-overview.md) - [Agent-Powered Scheduled Reminder Overview](background-agent-scheduled-reminder/background-agent-scheduled-reminder-overview.md)
- [Agent-Powered Scheduled Reminder Development](background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md) - [Agent-Powered Scheduled Reminder Development](background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md)
- Background Task Management - Background Task Management
...@@ -282,7 +283,7 @@ ...@@ -282,7 +283,7 @@
- DFX - DFX
- Application Event Logging - Application Event Logging
- [Overview of Application Event Logging](dfx/hiappevent-overview.md) - [Overview of Application Event Logging](dfx/hiappevent-overview.md)
- [Development Guidelines on Application Event Logging](dfx/hiappevent-guidelines.md) - [Development of Application Event Logging](dfx/hiappevent-guidelines.md)
- Performance Tracing - Performance Tracing
- [Overview of Performance Tracing](dfx/hitracemeter-overview.md) - [Overview of Performance Tracing](dfx/hitracemeter-overview.md)
- [Development of Performance Tracing](dfx/hitracemeter-guidelines.md) - [Development of Performance Tracing](dfx/hitracemeter-guidelines.md)
...@@ -290,12 +291,13 @@ ...@@ -290,12 +291,13 @@
- [Overview of Distributed Call Chain Tracing](dfx/hitracechain-overview.md) - [Overview of Distributed Call Chain Tracing](dfx/hitracechain-overview.md)
- [Development of Distributed Call Chain Tracing](dfx/hitracechain-guidelines.md) - [Development of Distributed Call Chain Tracing](dfx/hitracechain-guidelines.md)
- Internationalization - Internationalization
- [Overview](internationalization/international-overview.md) - [Internationalization Overview](internationalization/international-overview.md)
- [Internationalization Development (intl)](internationalization/intl-guidelines.md) - [Internationalization Development (intl)](internationalization/intl-guidelines.md)
- [Internationalization Development (i18n)](internationalization/i18n-guidelines.md) - [Internationalization Development (i18n)](internationalization/i18n-guidelines.md)
- -
- [Using Native APIs in Application Projects](napi/napi-guidelines.md) - [Using Native APIs in Application Projects](napi/napi-guidelines.md)
- Tools - Tools
- [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md) - [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md)
- Hands-On Tutorials - Hands-On Tutorials
- [Samples](https://gitee.com/openharmony/app_samples/blob/master/README.md) - [Samples](https://gitee.com/openharmony/app_samples/blob/master/README.md)
...@@ -595,10 +597,11 @@ ...@@ -595,10 +597,11 @@
- [MissionSnapshot](reference/apis/js-apis-application-MissionSnapshot.md) - [MissionSnapshot](reference/apis/js-apis-application-MissionSnapshot.md)
- [PermissionRequestResult](reference/apis/js-apis-permissionrequestresult.md) - [PermissionRequestResult](reference/apis/js-apis-permissionrequestresult.md)
- [ProcessRunningInfo](reference/apis/js-apis-processrunninginfo.md) - [ProcessRunningInfo](reference/apis/js-apis-processrunninginfo.md)
- [ServiceExtensionContext](reference/apis/js-apis-service-extension-context.md) - [ServiceExtensionContext](reference/apis/js-apis-service-extension-context.md)
- [shellCmdResult](reference/apis/js-apis-application-shellCmdResult.md) - [shellCmdResult](reference/apis/js-apis-application-shellCmdResult.md)
- Common Event and Notification - Common Event and Notification
- [@ohos.commonEvent](reference/apis/js-apis-commonEvent.md) - [@ohos.commonEvent](reference/apis/js-apis-commonEvent.md)
- [@ohos.events.emitter](reference/apis/js-apis-emitter.md) - [@ohos.events.emitter](reference/apis/js-apis-emitter.md)
- [@ohos.notification](reference/apis/js-apis-notification.md) - [@ohos.notification](reference/apis/js-apis-notification.md)
...@@ -656,9 +659,10 @@ ...@@ -656,9 +659,10 @@
- [@ohos.data.preferences](reference/apis/js-apis-data-preferences.md) - [@ohos.data.preferences](reference/apis/js-apis-data-preferences.md)
- [@ohos.data.rdb](reference/apis/js-apis-data-rdb.md) - [@ohos.data.rdb](reference/apis/js-apis-data-rdb.md)
- [@ohos.settings](reference/apis/js-apis-settings.md) - [@ohos.settings](reference/apis/js-apis-settings.md)
- [resultSet](reference/apis/js-apis-data-resultset.md)
- [resultSet](reference/apis/js-apis-data-resultset.md)
- File Management - File Management
- [@ohos.document](reference/apis/js-apis-document.md) - [@ohos.document](reference/apis/js-apis-document.md)
- [@ohos.environment](reference/apis/js-apis-environment.md) - [@ohos.environment](reference/apis/js-apis-environment.md)
- [@ohos.fileio](reference/apis/js-apis-fileio.md) - [@ohos.fileio](reference/apis/js-apis-fileio.md)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册