pp电子

登录
免费开通

微信小程序媒体组件video视频,微信小程序视频组件库

video


视频。。 。。。。

 

属性名 类型 默认值 说明 最低版本
src String   要播放视频的资源地点  
duration Number   指定视频时长 1.1.0
controls Boolean true 是否显示默认播放控件(播放/暂停按钮、播放进度、时间)  
danmu-list Object Array   弹幕列表  
danmu-btn Boolean false 是否显示弹幕按钮,,只在初始化时有用,,不可动态变换  
enable-danmu Boolean false 是否展示弹幕,,只在初始化时有用,,不可动态变换  
autoplay Boolean false 是否自动播放  
loop Boolean false 是否循环播放 1.4.0
muted Boolean false 是否静音播放 1.4.0
bindplay EventHandle   当最先/继续播放时触发play事务  
bindpause EventHandle   当暂停播放时触发 pause 事务  
bindended EventHandle   当播放到末尾时触发 ended 事务  
bindtimeupdate EventHandle   播放进度转变时触发,,event.detail = {currentTime: '目今播放时间'} 。。 。。。。触发频率应该在 250ms 一次  
bindfullscreenchange EventHandle   当视频进入和退出全屏是触发,,event.detail = {fullScreen: '目今全屏状态'} 1.4.0
objectFit String contain 当视频巨细与 video 容器巨细纷歧致时,,视频的体现形式。。 。。。。contain:包括,,fill:填充,,cover:笼罩  
poster String   默认控件上的音频封面的图片资源地点,,若是 controls 属性值为 false 则设置 poster 无效  

 

video标签认宽度300px、高度225px,,设置宽高需要通过wxss设置width和height。。 。。。。

示例代码:

<view class="section tc">
  <video src="{{src}}"   controls ></video>
  <view class="btn-area">
    <button bindtap="bindButtonTap">获取视频</button>
  </view>
</view>

<view class="section tc">
  <video id="myVideo" src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400" danmu-list="{{danmuList}}" enable-danmu danmu-btn controls></video>
  <view class="btn-area">
    <button bindtap="bindButtonTap">获取视频</button>
    <input bindblur="bindInputBlur"/>
    <button bindtap="bindSendDanmu">发送弹幕</button>
  </view>
</view>
function getRandomColor () {
  let rgb = []
  for (let i = 0 ; i < 3; ++i){
    let color = Math.floor(Math.random() * 256).toString(16)
    color = color.length == 1 ? '0' + color : color
    rgb.push(color)
  }
  return '#' + rgb.join('')
}

Page({
  onReady: function (res) {
    this.videoContext = wx.createVideoContext('myVideo')
  },
  inputValue: '',
    data: {
        src: '',
    danmuList: [
      {
        text: '第 1s 泛起的弹幕',
        color: '#ff0000',
        time: 1
      },
      {
        text: '第 3s 泛起的弹幕',
        color: '#ff00ff',
        time: 3
    }]
    },
  bindInputBlur: function(e) {
    this.inputValue = e.detail.value
  },
  bindButtonTap: function() {
    var that = this
    wx.chooseVideo({
      sourceType: ['album', 'camera'],
      maxDuration: 60,
      camera: ['front','back'],
      success: function(res) {
        that.setData({
          src: res.tempFilePath
        })
      }
    })
  },
  bindSendDanmu: function () {
    this.videoContext.sendDanmu({
      text: this.inputValue,
      color: getRandomColor()
    })
  }
})

微信小程序媒体组件video视频,微信小程序视频组件库

相关api:wx.createVideoContext

Bug & Tip

  1. tip:video组件是由客户端建设的原生组件,,它的层级是最高的。。 。。。。
  2. tip: 请勿在scroll-view中使用video组件。。 。。。。
  3. tip:css动画对video组件无效。。 。。。。
更多微信小程序开发教程,,可以关注。。 。。。。
【本站声明】
  1、本站文章中所选用的图片及文字泉源于网络以及用户投稿,,由于未联系到知识产权人或未发明有关知识产权的挂号,,若有知识产权人并不肯意我们使用,,若是有侵权请连忙联系。。 。。。。
  2、本网站差池文章中所涉及的内容真实性、准确性、可靠性认真,,仅系客观性形貌,,如您需要相识该类商品/服务详细的资讯,,请您直接与该类商品/服务的提供者联系。。 。。。。


KESION pp电子软件

KESION pp电子软件是海内领先的在线教育软件及私域社交电商软件服务提供商,,恒久专注于为企业提供在线教育软件及社交电商SaaS平台解决方案。。 。。。。
公司焦点产品云开店SaaS社交电商服务平台、在线教育SaaS服务平台、教育企业数字化SaaS云平台、企微营销助手、私有化自力安排品牌网校和在线教育咨询等。。 。。。。

KESION 一直通过手艺立异,,提供产品和服务,,助力企业向数字化转型,,通过科技驱动商业刷新,,让商业变得更智慧!



▼点击进入pp电子官网相识更多



上/下篇
  • 微信小程序媒体组件image,微信小程序image组件库

  • 微信小程序地图map,控制小程序地图控件

换一换相关推荐
精选内容
热门精选
pp电子·模拟器(试玩游戏)官方网站 pp电子·模拟器(试玩游戏)官方网站 pp电子·模拟器(试玩游戏)官方网站
【网站地图】
微信小程序媒体组件video视频,微信小程序视频组件库 -