HarmonyOS Swiper组件是否支持子组件为Video组件,并且可以自动播放

HarmonyOS Swiper组件是否支持子组件为Video组件,并且可以自动播放

HarmonyOS
2024-08-03 14:11:51
1095浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
elucky

Swiper组件支持子组件为Video组件以及自动播放。

可以参考这个demo:

@Entry 
@Component 
struct VideoCreateComponent { 
  @State videoSrc: Resource = $rawfile('video1.mp4') 
  @State previewUri: Resource = $rawfile('video2.mp4') 
  @State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X 
  @State isAutoPlay: boolean = true 
  @State showControls: boolean = true 
  controller: VideoController = new VideoController() 
  private swiperController: SwiperController = new SwiperController() 
 
  build() { 
    Column() { 
      Swiper(this.swiperController){ 
        Video({ 
          src: this.videoSrc, 
          previewUri: this.previewUri, 
          currentProgressRate: this.curRate, 
          controller: this.controller 
        }) 
          .width('100%') 
          .height(300) 
          .autoPlay(this.isAutoPlay) 
          .controls(this.showControls) 
          .loop(true) 
        Video({ 
          src: this.previewUri, 
          previewUri: this.videoSrc, 
          currentProgressRate: this.curRate, 
          controller: this.controller 
        }) 
          .width('100%') 
          .height(300) 
          .autoPlay(this.isAutoPlay) 
          .controls(this.showControls) 
          .loop(true) 
      } 
    } 
  } 
} 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.

Video文档:

https://developer.huawei.com/consumer/cn/doc/harmonyos-references/ts-media-components-video-0000001815927640

swiper文档:

https://developer.huawei.com/consumer/cn/doc/harmonyos-references/ts-container-swiper-0000001862607461

分享
微博
QQ
微信
回复
2024-08-04 14:05:44


相关问题
Swiper是否支持组件复用
1540浏览 • 1回复 待解决
HarmonyOS Video组件如何播放沙盒视频
779浏览 • 1回复 待解决
组件的事件可以传到父组件
1464浏览 • 1回复 待解决
关于视频播放Video组件的问题
281浏览 • 0回复 待解决