1、本地视频
将mp4视频放到resource/rawfile目录下
参考代码:
@Entry
@Component
struct Test03 {
build() {
Column() {
Video({
src: $rawfile('v1.mp4')
})
.width('100%')
.aspectRatio(1.4)
}.height('100%').width('100%')
}
}
2、在线视频
Video({
src: ‘https://。。。。。’ 在线视频网址
})
.width(‘100%’)
.aspectRatio(1.4)
3、完整案例
@Entry
@Component
struct Test03{
@State
speed: number = 1
build() {
Row() {
Tabs() {
TabContent() {
Column({ space: 20 }) {
Video({
currentProgressRate: this.speed,
src: 'https://.。。。在线视频网址l'
})
.width('100%')
.aspectRatio(1.4)
Slider({
value: this.speed,
min: 0.75,
step: 0.25,
max: 2,
style: SliderStyle.InSet
})
.showSteps(true)
.onChange(value => {
this.speed = value
})
Text(this.speed+"倍速").fontSize(14).textAlign(TextAlign.Center).width('100%')
}
.width('100%')
}.tabBar("在线视频")
TabContent() {
Video({
src: $rawfile('v1.mp4')
})
.width('100%')
.aspectRatio(1.4)
}
.tabBar("本地视频")
}
.animationDuration(300)
}
.height('100%')
}
}