提交 8b7ff71f 编写于 作者: F fulizhong 提交者: zengyawen

fixed b8fc36bf from https://gitee.com/zengyawen/docs/pulls/14636

modify docs  Signed-off-by: FULIZHONG<fulizhong1@huawei.com>
Signed-off-by: Nfulizhong <fulizhong@huawei.com>
上级 efa2da03
...@@ -38,7 +38,7 @@ AudioPlayer支持的src媒体源输入类型可参考:[src属性说明](../ref ...@@ -38,7 +38,7 @@ AudioPlayer支持的src媒体源输入类型可参考:[src属性说明](../ref
```js ```js
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import fs from '@ohos.file.fs'
// 打印码流轨道信息 // 打印码流轨道信息
function printfDescription(obj) { function printfDescription(obj) {
...@@ -112,14 +112,8 @@ async function audioPlayerDemo() { ...@@ -112,14 +112,8 @@ async function audioPlayerDemo() {
let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。 let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。
// path路径的码流可通过"hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" 命令,将其推送到设备上 // path路径的码流可通过"hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" 命令,将其推送到设备上
let path = pathDir + '/01.mp3' let path = pathDir + '/01.mp3'
await fileIO.open(path).then((fdNumber) => { let file = await fs.open(path);
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + file.fd;
console.info('open fd success fd is' + fdPath);
}, (err) => {
console.info('open fd failed err is' + err);
}).catch((err) => {
console.info('open fd failed err is' + err);
});
audioPlayer.src = fdPath; // 设置src属性,并触发'dataLoad'事件回调 audioPlayer.src = fdPath; // 设置src属性,并触发'dataLoad'事件回调
} }
``` ```
...@@ -128,7 +122,7 @@ async function audioPlayerDemo() { ...@@ -128,7 +122,7 @@ async function audioPlayerDemo() {
```js ```js
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import fs from '@ohos.file.fs'
export class AudioDemo { export class AudioDemo {
// 设置播放器回调函数 // 设置播放器回调函数
...@@ -154,14 +148,8 @@ export class AudioDemo { ...@@ -154,14 +148,8 @@ export class AudioDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。 let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。
// path路径的码流可通过"hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" 命令,将其推送到设备上 // path路径的码流可通过"hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" 命令,将其推送到设备上
let path = pathDir + '/01.mp3' let path = pathDir + '/01.mp3'
await fileIO.open(path).then((fdNumber) => { let file = await fs.open(path);
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + file.fd;
console.info('open fd success fd is' + fdPath);
}, (err) => {
console.info('open fd failed err is' + err);
}).catch((err) => {
console.info('open fd failed err is' + err);
});
audioPlayer.src = fdPath; // 设置src属性,并触发'dataLoad'事件回调 audioPlayer.src = fdPath; // 设置src属性,并触发'dataLoad'事件回调
} }
} }
...@@ -171,7 +159,7 @@ export class AudioDemo { ...@@ -171,7 +159,7 @@ export class AudioDemo {
```js ```js
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import fs from '@ohos.file.fs'
export class AudioDemo { export class AudioDemo {
// 设置播放器回调函数 // 设置播放器回调函数
...@@ -202,14 +190,8 @@ export class AudioDemo { ...@@ -202,14 +190,8 @@ export class AudioDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。 let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。
// path路径的码流可通过"hdc file send D:\xxx\02.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" 命令,将其推送到设备上 // path路径的码流可通过"hdc file send D:\xxx\02.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" 命令,将其推送到设备上
let nextpath = pathDir + '/02.mp3' let nextpath = pathDir + '/02.mp3'
await fileIO.open(nextpath).then((fdNumber) => { let nextFile = await fs.open(nextpath);
nextFdPath = nextFdPath + '' + fdNumber; nextFdPath = nextFdPath + '' + nextFile.fd;
console.info('open fd success fd is' + nextFdPath);
}, (err) => {
console.info('open fd failed err is' + err);
}).catch((err) => {
console.info('open fd failed err is' + err);
});
audioPlayer.src = nextFdPath; // 设置src属性,并重新触发触发'dataLoad'事件回调 audioPlayer.src = nextFdPath; // 设置src属性,并重新触发触发'dataLoad'事件回调
} }
...@@ -220,14 +202,8 @@ export class AudioDemo { ...@@ -220,14 +202,8 @@ export class AudioDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。 let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。
// path路径的码流可通过"hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" 命令,将其推送到设备上 // path路径的码流可通过"hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" 命令,将其推送到设备上
let path = pathDir + '/01.mp3' let path = pathDir + '/01.mp3'
await fileIO.open(path).then((fdNumber) => { let file = await fs.open(path);
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + file.fd;
console.info('open fd success fd is' + fdPath);
}, (err) => {
console.info('open fd failed err is' + err);
}).catch((err) => {
console.info('open fd failed err is' + err);
});
audioPlayer.src = fdPath; // 设置src属性,并触发'dataLoad'事件回调 audioPlayer.src = fdPath; // 设置src属性,并触发'dataLoad'事件回调
} }
} }
...@@ -237,7 +213,7 @@ export class AudioDemo { ...@@ -237,7 +213,7 @@ export class AudioDemo {
```js ```js
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import fs from '@ohos.file.fs'
export class AudioDemo { export class AudioDemo {
// 设置播放器回调函数 // 设置播放器回调函数
...@@ -259,14 +235,8 @@ export class AudioDemo { ...@@ -259,14 +235,8 @@ export class AudioDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。 let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。
// path路径的码流可通过"hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" 命令,将其推送到设备上 // path路径的码流可通过"hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" 命令,将其推送到设备上
let path = pathDir + '/01.mp3' let path = pathDir + '/01.mp3'
await fileIO.open(path).then((fdNumber) => { let file = await fs.open(path);
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + file.fd;
console.info('open fd success fd is' + fdPath);
}, (err) => {
console.info('open fd failed err is' + err);
}).catch((err) => {
console.info('open fd failed err is' + err);
});
audioPlayer.src = fdPath; // 设置src属性,并触发'dataLoad'事件回调 audioPlayer.src = fdPath; // 设置src属性,并触发'dataLoad'事件回调
} }
} }
......
...@@ -111,7 +111,7 @@ AVPlayer主要工作是将Audio/Video媒体资源转码为可供渲染的图像 ...@@ -111,7 +111,7 @@ AVPlayer主要工作是将Audio/Video媒体资源转码为可供渲染的图像
```js ```js
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import audio from '@ohos.multimedia.audio'; import audio from '@ohos.multimedia.audio';
import fileIO from '@ohos.fileio' import fs from '@ohos.file.fs'
const TAG = 'AVPlayerDemo:' const TAG = 'AVPlayerDemo:'
export class AVPlayerDemo { export class AVPlayerDemo {
...@@ -230,14 +230,8 @@ export class AVPlayerDemo { ...@@ -230,14 +230,8 @@ export class AVPlayerDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。 let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。
// path路径的码流可通过"hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" 命令,将其推送到设备上 // path路径的码流可通过"hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" 命令,将其推送到设备上
let path = pathDir + '/H264_AAC.mp4' let path = pathDir + '/H264_AAC.mp4'
await fileIO.open(path).then((fdNumber) => { let file = await fs.open(path)
fdPath = fdPath + '' + fdNumber fdPath = fdPath + '' + file.fd
console.info('open fd success fd is' + fdPath)
}, (err) => {
console.info('open fd failed err is' + err)
}).catch((err) => {
console.info('open fd failed err is' + err)
});
this.avPlayer.url = fdPath this.avPlayer.url = fdPath
} }
} }
...@@ -247,7 +241,7 @@ export class AVPlayerDemo { ...@@ -247,7 +241,7 @@ export class AVPlayerDemo {
```js ```js
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import fs from '@ohos.file.fs'
const TAG = 'AVPlayerDemo:' const TAG = 'AVPlayerDemo:'
export class AVPlayerDemo { export class AVPlayerDemo {
...@@ -309,24 +303,18 @@ export class AVPlayerDemo { ...@@ -309,24 +303,18 @@ export class AVPlayerDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。 let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。
// path路径的码流可通过"hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" 命令,将其推送到设备上 // path路径的码流可通过"hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" 命令,将其推送到设备上
let path = pathDir + '/H264_AAC.mp4' let path = pathDir + '/H264_AAC.mp4'
await fileIO.open(path).then((fdNumber) => { let file = await fs.open(path)
fdPath = fdPath + '' + fdNumber fdPath = fdPath + '' + file.fd
console.info('open fd success fd is' + fdPath)
}, (err) => {
console.info('open fd failed err is' + err)
}).catch((err) => {
console.info('open fd failed err is' + err)
});
this.avPlayer.url = fdPath this.avPlayer.url = fdPath
} }
} }
``` ```
### 视频切换场景 ### 单曲循环场景
```js ```js
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import fs from '@ohos.file.fs'
const TAG = 'AVPlayerDemo:' const TAG = 'AVPlayerDemo:'
export class AVPlayerDemo { export class AVPlayerDemo {
...@@ -400,23 +388,17 @@ export class AVPlayerDemo { ...@@ -400,23 +388,17 @@ export class AVPlayerDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。 let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。
// path路径的码流可通过"hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" 命令,将其推送到设备上 // path路径的码流可通过"hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" 命令,将其推送到设备上
let path = pathDir + '/H264_AAC.mp4' let path = pathDir + '/H264_AAC.mp4'
await fileIO.open(path).then((fdNumber) => { let file = await fs.open(path)
fdPath = fdPath + '' + fdNumber fdPath = fdPath + '' + file.fd
console.info('open fd success fd is' + fdPath)
}, (err) => {
console.info('open fd failed err is' + err)
}).catch((err) => {
console.info('open fd failed err is' + err)
});
this.avPlayer.url = fdPath this.avPlayer.url = fdPath
} }
} }
``` ```
### 单曲循环场景 ### 视频切换场景
```js ```js
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import fs from '@ohos.file.fs'
const TAG = 'AVPlayerDemo:' const TAG = 'AVPlayerDemo:'
export class AVPlayerDemo { export class AVPlayerDemo {
...@@ -429,14 +411,8 @@ export class AVPlayerDemo { ...@@ -429,14 +411,8 @@ export class AVPlayerDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。 let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。
// path路径的码流可通过"hdc file send D:\xxx\H264_MP3.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" 命令,将其推送到设备上 // path路径的码流可通过"hdc file send D:\xxx\H264_MP3.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" 命令,将其推送到设备上
let path = pathDir + '/H264_MP3.mp4' let path = pathDir + '/H264_MP3.mp4'
await fileIO.open(path).then((fdNumber) => { let file = await fs.open(path)
fdPath = fdPath + '' + fdNumber fdPath = fdPath + '' + file.fd
console.info('open fd success fd is' + fdPath)
}, (err) => {
console.info('open fd failed err is' + err)
}).catch((err) => {
console.info('open fd failed err is' + err)
});
this.avPlayer.url = fdPath // 再次触发initialized状态机上报 this.avPlayer.url = fdPath // 再次触发initialized状态机上报
} }
...@@ -500,14 +476,8 @@ export class AVPlayerDemo { ...@@ -500,14 +476,8 @@ export class AVPlayerDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。 let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。
// path路径的码流可通过"hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" 命令,将其推送到设备上 // path路径的码流可通过"hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" 命令,将其推送到设备上
let path = pathDir + '/H264_AAC.mp4' let path = pathDir + '/H264_AAC.mp4'
await fileIO.open(path).then((fdNumber) => { let file = await fs.open(path)
fdPath = fdPath + '' + fdNumber fdPath = fdPath + '' + file.fd
console.info('open fd success fd is' + fdPath)
}, (err) => {
console.info('open fd failed err is' + err)
}).catch((err) => {
console.info('open fd failed err is' + err)
});
this.avPlayer.url = fdPath this.avPlayer.url = fdPath
} }
} }
......
...@@ -51,7 +51,7 @@ Xcomponent创建方法可参考:[Xcomponent创建方法](../reference/arkui-ts ...@@ -51,7 +51,7 @@ Xcomponent创建方法可参考:[Xcomponent创建方法](../reference/arkui-ts
```js ```js
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import fs from '@ohos.file.fs'
export class VideoPlayerDemo { export class VideoPlayerDemo {
// 函数调用发生错误时用于上报错误信息 // 函数调用发生错误时用于上报错误信息
failureCallback(error) { failureCallback(error) {
...@@ -82,14 +82,8 @@ export class VideoPlayerDemo { ...@@ -82,14 +82,8 @@ export class VideoPlayerDemo {
let fdPath = 'fd://' let fdPath = 'fd://'
// path路径的码流可通过"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" 命令,将其推送到设备上 // path路径的码流可通过"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" 命令,将其推送到设备上
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';
await fileIO.open(path).then((fdNumber) => { let file = await fs.open(path);
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + file.fd;
console.info('open fd success fd is' + fdPath);
}, (err) => {
console.info('open fd failed err is' + err);
}).catch((err) => {
console.info('open fd failed err is' + err);
});
// 调用createVideoPlayer接口返回videoPlayer实例对象 // 调用createVideoPlayer接口返回videoPlayer实例对象
await media.createVideoPlayer().then((video) => { await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') { if (typeof (video) != 'undefined') {
...@@ -180,7 +174,7 @@ export class VideoPlayerDemo { ...@@ -180,7 +174,7 @@ export class VideoPlayerDemo {
```js ```js
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import fs from '@ohos.file.fs'
export class VideoPlayerDemo { export class VideoPlayerDemo {
// 函数调用发生错误时用于上报错误信息 // 函数调用发生错误时用于上报错误信息
failureCallback(error) { failureCallback(error) {
...@@ -211,14 +205,8 @@ export class VideoPlayerDemo { ...@@ -211,14 +205,8 @@ export class VideoPlayerDemo {
let fdPath = 'fd://' let fdPath = 'fd://'
// path路径的码流可通过"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" 命令,将其推送到设备上 // path路径的码流可通过"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" 命令,将其推送到设备上
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';
await fileIO.open(path).then((fdNumber) => { let file = await fs.open(path);
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + file.fd;
console.info('open fd success fd is' + fdPath);
}, (err) => {
console.info('open fd failed err is' + err);
}).catch((err) => {
console.info('open fd failed err is' + err);
});
// 调用createVideoPlayer接口返回videoPlayer实例对象 // 调用createVideoPlayer接口返回videoPlayer实例对象
await media.createVideoPlayer().then((video) => { await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') { if (typeof (video) != 'undefined') {
...@@ -267,7 +255,7 @@ export class VideoPlayerDemo { ...@@ -267,7 +255,7 @@ export class VideoPlayerDemo {
```js ```js
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import fs from '@ohos.file.fs'
export class VideoPlayerDemo { export class VideoPlayerDemo {
// 函数调用发生错误时用于上报错误信息 // 函数调用发生错误时用于上报错误信息
failureCallback(error) { failureCallback(error) {
...@@ -299,14 +287,8 @@ export class VideoPlayerDemo { ...@@ -299,14 +287,8 @@ export class VideoPlayerDemo {
// path路径的码流可通过"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" 命令,将其推送到设备上 // path路径的码流可通过"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" 命令,将其推送到设备上
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';
let nextPath = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/MP4_AAC.mp4'; let nextPath = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/MP4_AAC.mp4';
await fileIO.open(path).then((fdNumber) => { let file = await fs.open(path);
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + file.fd;
console.info('open fd success fd is' + fdPath);
}, (err) => {
console.info('open fd failed err is' + err);
}).catch((err) => {
console.info('open fd failed err is' + err);
});
// 调用createVideoPlayer接口返回videoPlayer实例对象 // 调用createVideoPlayer接口返回videoPlayer实例对象
await media.createVideoPlayer().then((video) => { await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') { if (typeof (video) != 'undefined') {
...@@ -341,14 +323,8 @@ export class VideoPlayerDemo { ...@@ -341,14 +323,8 @@ export class VideoPlayerDemo {
// 获取下一个视频fd地址 // 获取下一个视频fd地址
fdPath = 'fd://' fdPath = 'fd://'
await fileIO.open(nextPath).then((fdNumber) => { let nextFile = await fs.open(nextPath);
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + nextFile.fd;
console.info('open fd success fd is' + fdPath);
}, (err) => {
console.info('open fd failed err is' + err);
}).catch((err) => {
console.info('open fd failed err is' + err);
});
// 设置第二个视频播放源 // 设置第二个视频播放源
videoPlayer.url = fdPath; videoPlayer.url = fdPath;
...@@ -378,7 +354,7 @@ export class VideoPlayerDemo { ...@@ -378,7 +354,7 @@ export class VideoPlayerDemo {
```js ```js
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import fs from '@ohos.file.fs'
export class VideoPlayerDemo { export class VideoPlayerDemo {
// 函数调用发生错误时用于上报错误信息 // 函数调用发生错误时用于上报错误信息
failureCallback(error) { failureCallback(error) {
...@@ -409,14 +385,8 @@ export class VideoPlayerDemo { ...@@ -409,14 +385,8 @@ export class VideoPlayerDemo {
let fdPath = 'fd://' let fdPath = 'fd://'
// path路径的码流可通过"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" 命令,将其推送到设备上 // path路径的码流可通过"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" 命令,将其推送到设备上
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';
await fileIO.open(path).then((fdNumber) => { let file = await fs.open(path);
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + file.fd;
console.info('open fd success fd is' + fdPath);
}, (err) => {
console.info('open fd failed err is' + err);
}).catch((err) => {
console.info('open fd failed err is' + err);
});
// 调用createVideoPlayer接口返回videoPlayer实例对象 // 调用createVideoPlayer接口返回videoPlayer实例对象
await media.createVideoPlayer().then((video) => { await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') { if (typeof (video) != 'undefined') {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册