小程序video的各种事件 如何让小程序视频只播放前五秒

小程序video的各种事件 如何让小程序视频只播放前五秒,第1张

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">

您好!很高兴能为您解答,  

在微信浏览器里面使用video标签,会自动变成全屏,改成下面就好了,起码可以在video标签之上加入其他元素。

<video id="videoID"webkit-playsinline="true" x-webkit-airplay="true" playsinline="true"x5-video-player-type="h5"x5-video-player-fullscreen="true"width="100%" height="100%"preload="auto" poster=""没裤 src="">谈察谨

</video>

还有个问题,在android的微信里面,就算加上了上面的属性,还会出现上下有黑边,不能全屏的问题。

解决办法:给含基video加上object-fit: fill的style属性。

h5作为webview嵌渣毕套,小程序或客户端如果涉及全屏,会较为麻烦。

ios播放视频时,一般会默认全屏,阻止全屏反而会麻烦一野宽些。

而安卓单靠h5是如脊芹没法完成,视频全屏的。

需要客户端支持。

实现video是没法直接点击的,一般用div定位覆盖上去。

图片则是poster的属性可以不用img。

x5为微信h5的一种内核,类似webkit且不要写 playsinline 类似的任何属性。

那个是阻止全屏的 !!!

安卓webview客户端处理参考:

https://blog.csdn.net/weixin_28909745/article/details/117497145


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

原文地址: https://outofmemory.cn/yw/12329983.html

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

发表评论

登录后才能评论

评论列表(0条)

保存