| type | string | Yes | Event type, which is **'bufferingUpdate'** in this case. |
| type | string | Yes | Event type, which is **'bufferingUpdate'** in this case. |
| callback | function | Yes | Callback invoked when the event is triggered.<br>When [BufferingInfoType](#bufferinginfotype8) is set to **BUFFERING_PERCENT** or **CACHED_DURATION**, **value** is valid. Otherwise, **value** is fixed at **0**.|
**Example**
...
...
@@ -554,7 +554,7 @@ audioPlayer.on('reset', () => { // Set the 'reset' event callback.
audioPlayer=undefined;
});
audioPlayer.on('timeUpdate',(seekDoneTime)=>{// Set the 'timeUpdate' event callback.
if(typeof(seekDoneTime)=="undefined"){
if(seekDoneTime==null){
console.info('audio seek fail');
return;
}
...
...
@@ -602,14 +602,14 @@ Subscribes to the **'timeUpdate'** event.
| type | string | Yes | Event type, which is **'timeUpdate'** in this case.<br>The **'timeUpdate'** event is triggered when the [seek()](#audioplayer_seek) API is called.|
| type | string | Yes | Event type, which is **'timeUpdate'** in this case.<br>The **'timeUpdate'** event is triggered when the [seek()](#audioplayer_seek) API is called.|
| callback | Callback\<number> | Yes | Callback invoked when the event is triggered. The input parameter of the callback is the time when the seek operation is successful. |
**Example**
```js
audioPlayer.on('timeUpdate',(seekDoneTime)=>{// Set the 'timeUpdate' event callback.
if(typeof(seekDoneTime)=='undefined'){
if(seekDoneTime==null){
console.info('audio seek fail');
return;
}
...
...
@@ -630,7 +630,7 @@ Subscribes to audio playback error events. After an error event is reported, you
| type | string | Yes | Event type, which is **'error'** in this case.<br>The **'error'** event is triggered when an error occurs during audio playback.|
| type | string | Yes | Event type, which is **'error'** in this case.<br>The **'error'** event is triggered when an error occurs during audio playback.|
| callback | ErrorCallback | Yes | Callback invoked when the event is triggered. |
**Example**
...
...
@@ -727,7 +727,7 @@ Sets **SurfaceId**. This API uses a callback to return the result.
```js
videoPlayer.setDisplaySurface(surfaceId,(err)=>{
if(typeof(err)=='undefined'){
if(err==null){
console.info('setDisplaySurface success!');
}else{
console.info('setDisplaySurface fail!');
...
...
@@ -785,7 +785,7 @@ Prepares for video playback. This API uses a callback to return the result.
```js
videoPlayer.prepare((err)=>{
if(typeof(err)=='undefined'){
if(err==null){
console.info('prepare success!');
}else{
console.info('prepare fail!');
...
...
@@ -835,7 +835,7 @@ Starts to play video resources. This API uses a callback to return the result.
```js
videoPlayer.play((err)=>{
if(typeof(err)=='undefined'){
if(err==null){
console.info('play success!');
}else{
console.info('play fail!');
...
...
@@ -885,7 +885,7 @@ Pauses video playback. This API uses a callback to return the result.
```js
videoPlayer.pause((err)=>{
if(typeof(err)=='undefined'){
if(err==null){
console.info('pause success!');
}else{
console.info('pause fail!');
...
...
@@ -935,7 +935,7 @@ Stops video playback. This API uses a callback to return the result.
```js
videoPlayer.stop((err)=>{
if(typeof(err)=='undefined'){
if(err==null){
console.info('stop success!');
}else{
console.info('stop fail!');
...
...
@@ -985,7 +985,7 @@ Switches the video resource to be played. This API uses a callback to return the
```js
videoPlayer.reset((err)=>{
if(typeof(err)=='undefined'){
if(err==null){
console.info('reset success!');
}else{
console.info('reset fail!');
...
...
@@ -1037,7 +1037,7 @@ Seeks to the specified playback position. The next key frame at the specified po
```js
letseekTime=5000;
videoPlayer.seek(seekTime,(err,result)=>{
if(typeof(err)=='undefined'){
if(err==null){
console.info('seek success!');
}else{
console.info('seek fail!');
...
...
@@ -1068,7 +1068,7 @@ import media from '@ohos.multimedia.media'
| type | string | Yes | Event type, which is **'bufferingUpdate'** in this case. |
| type | string | Yes | Event type, which is **'bufferingUpdate'** in this case. |
| callback | function | Yes | Callback invoked when the event is triggered.<br>When [BufferingInfoType](#bufferinginfotype8) is set to **BUFFERING_PERCENT** or **CACHED_DURATION**, **value** is valid. Otherwise, **value** is fixed at **0**.|
**Example**
...
...
@@ -1480,7 +1480,7 @@ Subscribes to the frame rendering start event.
| type | string | Yes | Event type, which is **'videoSizeChanged'** in this case.|
| type | string | Yes | Event type, which is **'videoSizeChanged'** in this case.|
| callback | function | Yes | Callback invoked when the event is triggered. **width** indicates the video width, and **height** indicates the video height. |
**Example**
...
...
@@ -1527,7 +1527,7 @@ Subscribes to video playback error events. After an error event is reported, you
| type | string | Yes | Event type, which is **'error'** in this case.<br>The **'error'** event is triggered when an error occurs during video playback.|
| type | string | Yes | Event type, which is **'error'** in this case.<br>The **'error'** event is triggered when an error occurs during video playback.|
| callback | ErrorCallback | Yes | Callback invoked when the event is triggered. |
**Example**
...
...
@@ -1640,7 +1640,7 @@ function printfItemDescription(obj, key) {
| type | string | Yes | Event type, which is **'error'** in this case.<br>The **'error'** event is triggered when an error occurs during audio recording.|
| type | string | Yes | Event type, which is **'error'** in this case.<br>The **'error'** event is triggered when an error occurs during audio recording.|
| callback | ErrorCallback | Yes | Callback invoked when the event is triggered. |
**Example**
...
...
@@ -1996,7 +1996,7 @@ let eventEmitter = new events.EventEmitter();
eventEmitter.on('prepare',()=>{
videoRecorder.prepare(videoConfig,(err)=>{
if(typeof(err)=='undefined'){
if(err==null){
console.info('prepare success');
}else{
console.info('prepare failed and error is '+err.message);
| type | string | Yes | Event type, which is **'error'** in this case.<br>The **'error'** event is triggered when an error occurs during video recording.|
| type | string | Yes | Event type, which is **'error'** in this case.<br>The **'error'** event is triggered when an error occurs during video recording.|
| callback | ErrorCallback | Yes | Callback invoked when the event is triggered. |
**Example**
```js
videoRecorder.on('error',(error)=>{// Set the 'error event' callback.
videoRecorder.on('error',(error)=>{// Set the 'error' event callback.
console.info(`audio error called, errName is ${error.name}`);// Print the error name.
console.info(`audio error called, errCode is ${error.code}`);// Print the error code.
console.info(`audio error called, errMessage is ${error.message}`);// Print the detailed description of the error type.