微信小程序中的视频播放问题

微信小程序中的视频播放问题,第1张

小程序中的 video 组件是原生组件, 默认宽雀饥度300px、高度225px,可通过wxss设置宽高。其中 src 属性默认支持MP4格式,但是实际上还可以支持其他格式。

属性主要有:

src :要播放视频的资源地址。

initial-time :指定视频初始州销播放位置。

danmu-list :d幕列表。

controls :是否显示默认播放控件(播放/暂停按钮、播放进度、时间)。

binderror :视频播放出错时触发。

安卓系统可以支持MP4格式的视频,苹果手机支持m3u8格式的视频。可以通过获取手机的系统,然后判断播放什么格式的视频。

参数主要顷迹返包括:

brand :手机品牌;

model :手机型号;

fontSizeSetting :用户字体大小设置。以“我-设置-通用-字体大小”中的设置为准,单位 px;

pixelRatio :设备像素比。

imeUpdate: function (e) {

      //实时播放进度 秒数

        var currentTime = parseInt(e.detail.currentTime)

        console.log("视频播放到第" + currentTime + "秒")//查看正在播放时间,以秒为单位

        if(currentTime>300){

          let videoContext = wx.createVideoContext('myVideo', this)

          console.log(videoContext)

          videoContext.pause

          念消videoContext.seek("1")

          videoContext.pause

          wx.showModal({

            title: '充值提示',

              content: "非会员只能看前五分钟的内容",//提示内容

              confirmColor: '#2EA7E0',//确定按钮的颜色

    胡高仔          showCancel: false,//不显示取消按钮

               success (res) {

              if (res.confirm) {

                 console.log('用户点击确定按钮')

               } else if (res.cancel) {

                 console.log('用户点击取消按钮')

               }

             }

            })

        }

   裤汪 },

<video  bindtimeupdate="timeUpdate"  id="myVideo" src="{{kino_mazmuni.info.resource_url}}"  initial-time="{{kino_mazmuni.duration_time}}" title="{{kino_mazmuni.info.video_name}}" object-fit="fill"  enable-auto-rotation="true" vslide-gesture="true"  enable-play-gesture="true" auto-pause-if-navigate="true"  show-screen-lock-button="true"  duration="15"   enable-auto-rotation="true" duration="true" show-fullscreen-btn  show-casting-button="true"   autoplay="true"  poster='https://apqak.alkuyi.com/alkuyi_video_poster.png' objectFit="cover" class="bofangqi">


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12308450.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存