小程序基础微信小程序微信小程序开发

小程序:cover-view

2018-06-13  本文已影响58人  Mccc_

代码Github地址

一. cover-view 能做什么?

二. 代码展示

<video class="video" id='myVideo' src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400">

  <cover-view class="controls">

    <cover-view class="play" bindtap="play">
      <cover-image class="img" src="/images/play.png"></cover-image>
    </cover-view>

    <cover-view class="pause" bindtap="pause">
      <cover-image class="img" src="/images/pause.png"></cover-image>
    </cover-view>

  </cover-view>

</video>
.video {
  width: 100%;
  height: 200px;
}

.controls {
  position: relative;
  top: 100%;
  height: 50px;
  margin-top: -50px;
  display: flex;
  background-color: red;
  justify-content: space-around;
  align-items: center;
}

.img {
  width: 40px;
  height: 40px;
}
Page({
  onReady: function (options) {
    this.videoCtx = wx.createVideoContext('myVideo')
  },
  play: function (event) {
    this.videoCtx.play()

    wx.showToast({
      title: '开始播放',
      icon: "none",
      duration: 1500
    })
  },
  pause: function (event) {
    this.videoCtx.pause()
    wx.showToast({
      title: '暂停播放',
      icon: "none",
      duration: 1500
    })
  }
})
上一篇 下一篇

猜你喜欢

热点阅读