小程序开发之组件cover-view、 cover-image(覆盖在原生组件的组件)

cover-view

覆盖在原生组件之上的文本视图,可覆盖的原生组件包括map、video、canvas、camera、live-player、live-pusher,只支持嵌套cover-view、cover-image,可在cover-view中使用button。
小程序开发之组件cover-view、 cover-image(覆盖在原生组件的组件)_第1张图片

cover-image

覆盖在原生组件之上的图片视图,可覆盖的原生组件同cover-view,支持嵌套在cover-view里。

小程序开发之组件cover-view、 cover-image(覆盖在原生组件的组件)_第2张图片
例:在Viedo上加播放暂停按钮和自定义显示时间的文本信息
效果展示:


在这里插入图片描述

(1)先找两张播放暂停的图片拖入工程
如:
icon_play

icon_pause

小程序开发之组件cover-view、 cover-image(覆盖在原生组件的组件)_第3张图片

(2)再找一个可以解析的视频连接
如:http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400

注:记得开启不校验合法域名、web-view(业务域名)、TLS 版本以及 HTTPS 证书,否则不支持http无备案域名

(3)代码
index.wxml



index.wxss
.videoView{
  width: 100%
}
.controls {
  position: relative;
  top: 50%;
  height: 50px;
  margin-top: -25px;
  display: flex;
}
.play,
.pause,
.time {
  flex: 1;
  height: 100%;
}
.time {
  text-align: center;
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  line-height: 50px;
}
.img {
  width: 40px;
  height: 40px;
  margin: 5px auto;
}

index.js

Page({
  onReady() {
    this.videoCtx = wx.createVideoContext('myVideo')
  },
  play() {
    this.videoCtx.play()
  },
  pause() {
    this.videoCtx.pause()
  }
})





你可能感兴趣的:(ONE,PIECE--小程序,ONE,PIECE--小程序)