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

!8490 翻译完成:8465 【轻量级 PR】:update zh-cn/application-dev/reference/apis/js-apis-media.md.

Merge pull request !8490 from wusongqing/TR8465
...@@ -60,7 +60,7 @@ Creates a **VideoPlayer** instance in asynchronous mode. This API uses a callbac ...@@ -60,7 +60,7 @@ Creates a **VideoPlayer** instance in asynchronous mode. This API uses a callbac
let videoPlayer let videoPlayer
media.createVideoPlayer((error, video) => { media.createVideoPlayer((error, video) => {
if (typeof(video) != 'undefined') { if (video != null) {
videoPlayer = video; videoPlayer = video;
console.info('video createVideoPlayer success'); console.info('video createVideoPlayer success');
} else { } else {
...@@ -89,7 +89,7 @@ Creates a **VideoPlayer** instance in asynchronous mode. This API uses a promise ...@@ -89,7 +89,7 @@ Creates a **VideoPlayer** instance in asynchronous mode. This API uses a promise
let videoPlayer let videoPlayer
media.createVideoPlayer().then((video) => { media.createVideoPlayer().then((video) => {
if (typeof(video) != 'undefined') { if (video != null) {
videoPlayer = video; videoPlayer = video;
console.info('video createVideoPlayer success'); console.info('video createVideoPlayer success');
} else { } else {
...@@ -307,7 +307,7 @@ Seeks to the specified playback position. ...@@ -307,7 +307,7 @@ Seeks to the specified playback position.
```js ```js
audioPlayer.on('timeUpdate', (seekDoneTime) => { // Set the 'timeUpdate' event callback. audioPlayer.on('timeUpdate', (seekDoneTime) => { // Set the 'timeUpdate' event callback.
if (typeof (seekDoneTime) == 'undefined') { if (seekDoneTime == null) {
console.info('audio seek fail'); console.info('audio seek fail');
return; return;
} }
...@@ -380,7 +380,7 @@ function printfDescription(obj) { ...@@ -380,7 +380,7 @@ function printfDescription(obj) {
} }
audioPlayer.getTrackDescription((error, arrlist) => { audioPlayer.getTrackDescription((error, arrlist) => {
if (typeof (arrlist) != 'undefined') { if (arrlist != null) {
for (let i = 0; i < arrlist.length; i++) { for (let i = 0; i < arrlist.length; i++) {
printfDescription(arrlist[i]); printfDescription(arrlist[i]);
} }
...@@ -416,7 +416,7 @@ function printfDescription(obj) { ...@@ -416,7 +416,7 @@ function printfDescription(obj) {
} }
audioPlayer.getTrackDescription().then((arrlist) => { audioPlayer.getTrackDescription().then((arrlist) => {
if (typeof (arrlist) != 'undefined') { if (arrlist != null) {
arrayDescription = arrlist; arrayDescription = arrlist;
} else { } else {
console.log('audio getTrackDescription fail'); console.log('audio getTrackDescription fail');
...@@ -491,7 +491,7 @@ audioPlayer.on('reset', () => { // Set the 'reset' event callback. ...@@ -491,7 +491,7 @@ audioPlayer.on('reset', () => { // Set the 'reset' event callback.
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 (seekDoneTime == null) {
console.info('audio seek fail'); console.info('audio seek fail');
return; return;
} }
...@@ -546,7 +546,7 @@ Subscribes to the 'timeUpdate' event. ...@@ -546,7 +546,7 @@ Subscribes to the 'timeUpdate' event.
```js ```js
audioPlayer.on('timeUpdate', (seekDoneTime) => { // Set the 'timeUpdate' event callback. audioPlayer.on('timeUpdate', (seekDoneTime) => { // Set the 'timeUpdate' event callback.
if (typeof (seekDoneTime) == 'undefined') { if (seekDoneTime == null) {
console.info('audio seek fail'); console.info('audio seek fail');
return; return;
} }
...@@ -595,7 +595,6 @@ Enumerates the audio playback states. You can obtain the state through the **sta ...@@ -595,7 +595,6 @@ Enumerates the audio playback states. You can obtain the state through the **sta
| stopped | string | Audio playback is stopped. | | stopped | string | Audio playback is stopped. |
| error<sup>8+</sup> | string | Audio playback is in the error state. | | error<sup>8+</sup> | string | Audio playback is in the error state. |
## VideoPlayer<sup>8+</sup> ## VideoPlayer<sup>8+</sup>
Provides APIs to manage and play video. Before calling an API of **VideoPlayer**, you must call [createVideoPlayer()](#mediacreatevideoplayer8) to create a [VideoPlayer](#videoplayer8) instance. Provides APIs to manage and play video. Before calling an API of **VideoPlayer**, you must call [createVideoPlayer()](#mediacreatevideoplayer8) to create a [VideoPlayer](#videoplayer8) instance.
...@@ -635,7 +634,7 @@ Sets **SurfaceId**. This API uses a callback to return the result. ...@@ -635,7 +634,7 @@ Sets **SurfaceId**. This API uses a callback to return the result.
```js ```js
videoPlayer.setDisplaySurface(surfaceId, (err) => { videoPlayer.setDisplaySurface(surfaceId, (err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('setDisplaySurface success!'); console.info('setDisplaySurface success!');
} else { } else {
console.info('setDisplaySurface fail!'); console.info('setDisplaySurface fail!');
...@@ -691,7 +690,7 @@ Prepares for video playback. This API uses a callback to return the result. ...@@ -691,7 +690,7 @@ Prepares for video playback. This API uses a callback to return the result.
```js ```js
videoPlayer.prepare((err) => { videoPlayer.prepare((err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('prepare success!'); console.info('prepare success!');
} else { } else {
console.info('prepare fail!'); console.info('prepare fail!');
...@@ -741,7 +740,7 @@ Starts to play video resources. This API uses a callback to return the result. ...@@ -741,7 +740,7 @@ Starts to play video resources. This API uses a callback to return the result.
```js ```js
videoPlayer.play((err) => { videoPlayer.play((err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('play success!'); console.info('play success!');
} else { } else {
console.info('play fail!'); console.info('play fail!');
...@@ -791,7 +790,7 @@ Pauses video playback. This API uses a callback to return the result. ...@@ -791,7 +790,7 @@ Pauses video playback. This API uses a callback to return the result.
```js ```js
videoPlayer.pause((err) => { videoPlayer.pause((err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('pause success!'); console.info('pause success!');
} else { } else {
console.info('pause fail!'); console.info('pause fail!');
...@@ -841,7 +840,7 @@ Stops video playback. This API uses a callback to return the result. ...@@ -841,7 +840,7 @@ Stops video playback. This API uses a callback to return the result.
```js ```js
videoPlayer.stop((err) => { videoPlayer.stop((err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('stop success!'); console.info('stop success!');
} else { } else {
console.info('stop fail!'); console.info('stop fail!');
...@@ -891,7 +890,7 @@ Switches the video resource to be played. This API uses a callback to return the ...@@ -891,7 +890,7 @@ Switches the video resource to be played. This API uses a callback to return the
```js ```js
videoPlayer.reset((err) => { videoPlayer.reset((err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('reset success!'); console.info('reset success!');
} else { } else {
console.info('reset fail!'); console.info('reset fail!');
...@@ -942,7 +941,7 @@ Seeks to the specified playback position. The next key frame at the specified po ...@@ -942,7 +941,7 @@ Seeks to the specified playback position. The next key frame at the specified po
```js ```js
videoPlayer.seek((seekTime, err) => { videoPlayer.seek((seekTime, err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('seek success!'); console.info('seek success!');
} else { } else {
console.info('seek fail!'); console.info('seek fail!');
...@@ -970,7 +969,7 @@ Seeks to the specified playback position. This API uses a callback to return the ...@@ -970,7 +969,7 @@ Seeks to the specified playback position. This API uses a callback to return the
```js ```js
videoPlayer.seek((seekTime, seekMode, err) => { videoPlayer.seek((seekTime, seekMode, err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('seek success!'); console.info('seek success!');
} else { } else {
console.info('seek fail!'); console.info('seek fail!');
...@@ -1034,7 +1033,7 @@ Sets the volume. This API uses a callback to return the result. ...@@ -1034,7 +1033,7 @@ Sets the volume. This API uses a callback to return the result.
```js ```js
videoPlayer.setVolume((vol, err) => { videoPlayer.setVolume((vol, err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('setVolume success!'); console.info('setVolume success!');
} else { } else {
console.info('setVolume fail!'); console.info('setVolume fail!');
...@@ -1090,7 +1089,7 @@ Releases the video playback resource. This API uses a callback to return the res ...@@ -1090,7 +1089,7 @@ Releases the video playback resource. This API uses a callback to return the res
```js ```js
videoPlayer.release((err) => { videoPlayer.release((err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('release success!'); console.info('release success!');
} else { } else {
console.info('release fail!'); console.info('release fail!');
...@@ -1148,7 +1147,7 @@ function printfDescription(obj) { ...@@ -1148,7 +1147,7 @@ function printfDescription(obj) {
} }
videoPlayer.getTrackDescription((error, arrlist) => { videoPlayer.getTrackDescription((error, arrlist) => {
if (typeof (arrlist) != 'undefined') { if (arrlist != null) {
for (let i = 0; i < arrlist.length; i++) { for (let i = 0; i < arrlist.length; i++) {
printfDescription(arrlist[i]); printfDescription(arrlist[i]);
} }
...@@ -1185,7 +1184,7 @@ function printfDescription(obj) { ...@@ -1185,7 +1184,7 @@ function printfDescription(obj) {
let arrayDescription; let arrayDescription;
videoPlayer.getTrackDescription().then((arrlist) => { videoPlayer.getTrackDescription().then((arrlist) => {
if (typeof (arrlist) != 'undefined') { if (arrlist != null) {
arrayDescription = arrlist; arrayDescription = arrlist;
} else { } else {
console.log('video getTrackDescription fail'); console.log('video getTrackDescription fail');
...@@ -1217,7 +1216,7 @@ Sets the video playback speed. This API uses a callback to return the result. ...@@ -1217,7 +1216,7 @@ Sets the video playback speed. This API uses a callback to return the result.
```js ```js
videoPlayer.setSpeed((speed:number, err) => { videoPlayer.setSpeed((speed:number, err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('setSpeed success!'); console.info('setSpeed success!');
} else { } else {
console.info('setSpeed fail!'); console.info('setSpeed fail!');
...@@ -1438,7 +1437,7 @@ function printfItemDescription(obj, key) { ...@@ -1438,7 +1437,7 @@ function printfItemDescription(obj, key) {
} }
audioPlayer.getTrackDescription((error, arrlist) => { audioPlayer.getTrackDescription((error, arrlist) => {
if (typeof (arrlist) != 'undefined') { if (arrlist != null) {
for (let i = 0; i < arrlist.length; i++) { for (let i = 0; i < arrlist.length; i++) {
printfItemDescription(arrlist[i], MD_KEY_TRACK_TYPE); // Print the MD_KEY_TRACK_TYPE value of each track. printfItemDescription(arrlist[i], MD_KEY_TRACK_TYPE); // Print the MD_KEY_TRACK_TYPE value of each track.
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册