提交 aeb692f5 编写于 作者: Z zengyawen

fixed 296f3059 from https://gitee.com/zengyawen/docs/pulls/8421

update zh-cn/application-dev/reference/apis/js-apis-media.md.
Signed-off-by: Nzengyawen <zengyawen1@huawei.com>
上级 015ed1e5
...@@ -60,7 +60,7 @@ createVideoPlayer(callback: AsyncCallback\<[VideoPlayer](#videoplayer8)>): void ...@@ -60,7 +60,7 @@ createVideoPlayer(callback: AsyncCallback\<[VideoPlayer](#videoplayer8)>): void
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 @@ createVideoPlayer(): Promise<[VideoPlayer](#videoplayer8)> ...@@ -89,7 +89,7 @@ createVideoPlayer(): Promise<[VideoPlayer](#videoplayer8)>
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 {
...@@ -142,7 +142,7 @@ createVideoRecorder(callback: AsyncCallback\<[VideoRecorder](#videorecorder9)>): ...@@ -142,7 +142,7 @@ createVideoRecorder(callback: AsyncCallback\<[VideoRecorder](#videorecorder9)>):
let videoRecorder let videoRecorder
media.createVideoRecorder((error, video) => { media.createVideoRecorder((error, video) => {
if (typeof(video) != 'undefined') { if (video != null) {
videoRecorder = video; videoRecorder = video;
console.info('video createVideoRecorder success'); console.info('video createVideoRecorder success');
} else { } else {
...@@ -172,7 +172,7 @@ createVideoRecorder(): Promise<[VideoRecorder](#videorecorder9)> ...@@ -172,7 +172,7 @@ createVideoRecorder(): Promise<[VideoRecorder](#videorecorder9)>
let videoRecorder let videoRecorder
media.createVideoRecorder().then((video) => { media.createVideoRecorder().then((video) => {
if (typeof(video) != 'undefined') { if (video != null) {
videoRecorder = video; videoRecorder = video;
console.info('video createVideoRecorder success'); console.info('video createVideoRecorder success');
} else { } else {
...@@ -369,7 +369,7 @@ seek(timeMs: number): void ...@@ -369,7 +369,7 @@ seek(timeMs: number): void
```js ```js
audioPlayer.on('timeUpdate', (seekDoneTime) => { //设置'timeUpdate'事件回调 audioPlayer.on('timeUpdate', (seekDoneTime) => { //设置'timeUpdate'事件回调
if (typeof (seekDoneTime) == 'undefined') { if (seekDoneTime == null) {
console.info('audio seek fail'); console.info('audio seek fail');
return; return;
} }
...@@ -442,7 +442,7 @@ function printfDescription(obj) { ...@@ -442,7 +442,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]);
} }
...@@ -478,7 +478,7 @@ function printfDescription(obj) { ...@@ -478,7 +478,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');
...@@ -553,7 +553,7 @@ audioPlayer.on('reset', () => { //设置'reset'事件回调 ...@@ -553,7 +553,7 @@ audioPlayer.on('reset', () => { //设置'reset'事件回调
audioPlayer = undefined; audioPlayer = undefined;
}); });
audioPlayer.on('timeUpdate', (seekDoneTime) => { //设置'timeUpdate'事件回调 audioPlayer.on('timeUpdate', (seekDoneTime) => { //设置'timeUpdate'事件回调
if (typeof(seekDoneTime) == "undefined") { if (seekDoneTime == null) {
console.info('audio seek fail'); console.info('audio seek fail');
return; return;
} }
...@@ -608,7 +608,7 @@ on(type: 'timeUpdate', callback: Callback\<number>): void ...@@ -608,7 +608,7 @@ on(type: 'timeUpdate', callback: Callback\<number>): void
```js ```js
audioPlayer.on('timeUpdate', (seekDoneTime) => { //设置'timeUpdate'事件回调 audioPlayer.on('timeUpdate', (seekDoneTime) => { //设置'timeUpdate'事件回调
if (typeof (seekDoneTime) == 'undefined') { if (seekDoneTime == null) {
console.info('audio seek fail'); console.info('audio seek fail');
return; return;
} }
...@@ -726,7 +726,7 @@ setDisplaySurface(surfaceId: string, callback: AsyncCallback\<void>): void ...@@ -726,7 +726,7 @@ setDisplaySurface(surfaceId: string, callback: AsyncCallback\<void>): void
```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!');
...@@ -784,7 +784,7 @@ prepare(callback: AsyncCallback\<void>): void ...@@ -784,7 +784,7 @@ prepare(callback: AsyncCallback\<void>): void
```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!');
...@@ -834,7 +834,7 @@ play(callback: AsyncCallback\<void>): void; ...@@ -834,7 +834,7 @@ play(callback: AsyncCallback\<void>): void;
```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!');
...@@ -884,7 +884,7 @@ pause(callback: AsyncCallback\<void>): void ...@@ -884,7 +884,7 @@ pause(callback: AsyncCallback\<void>): void
```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!');
...@@ -934,7 +934,7 @@ stop(callback: AsyncCallback\<void>): void ...@@ -934,7 +934,7 @@ stop(callback: AsyncCallback\<void>): void
```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!');
...@@ -984,7 +984,7 @@ reset(callback: AsyncCallback\<void>): void ...@@ -984,7 +984,7 @@ reset(callback: AsyncCallback\<void>): void
```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!');
...@@ -1036,7 +1036,7 @@ seek(timeMs: number, callback: AsyncCallback\<number>): void ...@@ -1036,7 +1036,7 @@ seek(timeMs: number, callback: AsyncCallback\<number>): void
```js ```js
let seekTime = 5000; let seekTime = 5000;
videoPlayer.seek(seekTime, (err, result) => { videoPlayer.seek(seekTime, (err, result) => {
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!');
...@@ -1067,7 +1067,7 @@ import media from '@ohos.multimedia.media' ...@@ -1067,7 +1067,7 @@ import media from '@ohos.multimedia.media'
let seekTime = 5000; let seekTime = 5000;
let seekMode = media.SeekMode.SEEK_NEXT_SYNC; let seekMode = media.SeekMode.SEEK_NEXT_SYNC;
videoPlayer.seek(seekTime, seekMode, (err, result) => { videoPlayer.seek(seekTime, seekMode, (err, result) => {
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!');
...@@ -1133,7 +1133,7 @@ setVolume(vol: number, callback: AsyncCallback\<void>): void ...@@ -1133,7 +1133,7 @@ setVolume(vol: number, callback: AsyncCallback\<void>): void
```js ```js
let vol = 0.5; let vol = 0.5;
videoPlayer.setVolume(vol, (err, result) => { videoPlayer.setVolume(vol, (err, result) => {
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!');
...@@ -1190,7 +1190,7 @@ release(callback: AsyncCallback\<void>): void ...@@ -1190,7 +1190,7 @@ release(callback: AsyncCallback\<void>): void
```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!');
...@@ -1248,7 +1248,7 @@ function printfDescription(obj) { ...@@ -1248,7 +1248,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]);
} }
...@@ -1285,7 +1285,7 @@ function printfDescription(obj) { ...@@ -1285,7 +1285,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');
...@@ -1320,7 +1320,7 @@ import media from '@ohos.multimedia.media' ...@@ -1320,7 +1320,7 @@ import media from '@ohos.multimedia.media'
let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X; let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X;
videoPlayer.setSpeed(speed, (err, result) => { videoPlayer.setSpeed(speed, (err, result) => {
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!');
...@@ -1381,7 +1381,7 @@ selectBitrate(bitrate:number, callback: AsyncCallback\<number>): void ...@@ -1381,7 +1381,7 @@ selectBitrate(bitrate:number, callback: AsyncCallback\<number>): void
```js ```js
let bitrate = 1024000; let bitrate = 1024000;
videoPlayer.selectBitrate(bitrate, (err, result) => { videoPlayer.selectBitrate(bitrate, (err, result) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('selectBitrate success!'); console.info('selectBitrate success!');
} else { } else {
console.info('selectBitrate fail!'); console.info('selectBitrate fail!');
...@@ -1639,7 +1639,7 @@ function printfItemDescription(obj, key) { ...@@ -1639,7 +1639,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); //打印出每条轨道MD_KEY_TRACK_TYPE的值 printfItemDescription(arrlist[i], MD_KEY_TRACK_TYPE); //打印出每条轨道MD_KEY_TRACK_TYPE的值
} }
...@@ -1995,7 +1995,7 @@ let eventEmitter = new events.EventEmitter(); ...@@ -1995,7 +1995,7 @@ let eventEmitter = new events.EventEmitter();
eventEmitter.on('prepare', () => { eventEmitter.on('prepare', () => {
videoRecorder.prepare(videoConfig, (err) => { videoRecorder.prepare(videoConfig, (err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('prepare success'); console.info('prepare success');
} else { } else {
console.info('prepare failed and error is ' + err.message); console.info('prepare failed and error is ' + err.message);
...@@ -2004,7 +2004,7 @@ eventEmitter.on('prepare', () => { ...@@ -2004,7 +2004,7 @@ eventEmitter.on('prepare', () => {
}); });
media.createVideoRecorder((err, recorder) => { media.createVideoRecorder((err, recorder) => {
if (typeof (err) == 'undefined' && typeof (recorder) != 'undefined') { if (err == null && recorder) != null) {
videoRecorder = recorder; videoRecorder = recorder;
console.info('createVideoRecorder success'); console.info('createVideoRecorder success');
eventEmitter.emit('prepare'); // prepare事件触发 eventEmitter.emit('prepare'); // prepare事件触发
...@@ -2064,7 +2064,7 @@ let videoConfig = { ...@@ -2064,7 +2064,7 @@ let videoConfig = {
// promise // promise
let videoRecorder = null; let videoRecorder = null;
media.createVideoRecorder().then((recorder) => { media.createVideoRecorder().then((recorder) => {
if (typeof (recorder) != 'undefined') { if (recorder != null) {
videoRecorder = recorder; videoRecorder = recorder;
console.info('createVideoRecorder success'); console.info('createVideoRecorder success');
} else { } else {
...@@ -2105,7 +2105,7 @@ getInputSurface(callback: AsyncCallback\<string>): void; ...@@ -2105,7 +2105,7 @@ getInputSurface(callback: AsyncCallback\<string>): void;
// asyncallback // asyncallback
let surfaceID = null; // 传递给外界的surfaceID let surfaceID = null; // 传递给外界的surfaceID
videoRecorder.getInputSurface((err, surfaceId) => { videoRecorder.getInputSurface((err, surfaceId) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('getInputSurface success'); console.info('getInputSurface success');
surfaceID = surfaceId; surfaceID = surfaceId;
} else { } else {
...@@ -2166,7 +2166,7 @@ start(callback: AsyncCallback\<void>): void; ...@@ -2166,7 +2166,7 @@ start(callback: AsyncCallback\<void>): void;
```js ```js
// asyncallback // asyncallback
videoRecorder.start((err) => { videoRecorder.start((err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('start videorecorder success'); console.info('start videorecorder success');
} else { } else {
console.info('start videorecorder failed and error is ' + err.message); console.info('start videorecorder failed and error is ' + err.message);
...@@ -2222,7 +2222,7 @@ pause(callback: AsyncCallback\<void>): void; ...@@ -2222,7 +2222,7 @@ pause(callback: AsyncCallback\<void>): void;
```js ```js
// asyncallback // asyncallback
videoRecorder.pause((err) => { videoRecorder.pause((err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('pause videorecorder success'); console.info('pause videorecorder success');
} else { } else {
console.info('pause videorecorder failed and error is ' + err.message); console.info('pause videorecorder failed and error is ' + err.message);
...@@ -2276,7 +2276,7 @@ resume(callback: AsyncCallback\<void>): void; ...@@ -2276,7 +2276,7 @@ resume(callback: AsyncCallback\<void>): void;
```js ```js
// asyncallback // asyncallback
videoRecorder.resume((err) => { videoRecorder.resume((err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('resume videorecorder success'); console.info('resume videorecorder success');
} else { } else {
console.info('resume videorecorder failed and error is ' + err.message); console.info('resume videorecorder failed and error is ' + err.message);
...@@ -2330,7 +2330,7 @@ stop(callback: AsyncCallback\<void>): void; ...@@ -2330,7 +2330,7 @@ stop(callback: AsyncCallback\<void>): void;
```js ```js
// asyncallback // asyncallback
videoRecorder.stop((err) => { videoRecorder.stop((err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('stop videorecorder success'); console.info('stop videorecorder success');
} else { } else {
console.info('stop videorecorder failed and error is ' + err.message); console.info('stop videorecorder failed and error is ' + err.message);
...@@ -2384,7 +2384,7 @@ release(callback: AsyncCallback\<void>): void; ...@@ -2384,7 +2384,7 @@ release(callback: AsyncCallback\<void>): void;
```js ```js
// asyncallback // asyncallback
videoRecorder.release((err) => { videoRecorder.release((err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('release videorecorder success'); console.info('release videorecorder success');
} else { } else {
console.info('release videorecorder failed and error is ' + err.message); console.info('release videorecorder failed and error is ' + err.message);
...@@ -2438,7 +2438,7 @@ reset(callback: AsyncCallback\<void>): void; ...@@ -2438,7 +2438,7 @@ reset(callback: AsyncCallback\<void>): void;
```js ```js
// asyncallback // asyncallback
videoRecorder.reset((err) => { videoRecorder.reset((err) => {
if (typeof (err) == 'undefined') { if (err == null) {
console.info('reset videorecorder success'); console.info('reset videorecorder success');
} else { } else {
console.info('reset videorecorder failed and error is ' + err.message); console.info('reset videorecorder failed and error is ' + err.message);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册