目的:在live-player 之上显示一个canvas层用于绘制一些信息。
微信版本: Android7.0.6,小程序基础库:2.8.1 ,使用的到的控件:live-player, canvas
当live-player处于“非全屏”模式下时:canvas可覆盖在live-player之上,示例图如下:
当live-palyer处于“全屏”模式下时:canvas不能覆盖在live-player之上,示例图如下:
具体代码如下:
index.wxml
< live-player id = "livePlayer" class = "player-container-view" style = "width:390px;height:220px;z-index:100;" autoplay = "{{true}}" mode = "live" src = "rtmp://58.200.131.2:1935/livetv/hunantv" orientation = "vertical" >
</ live-player > < button class = "btn" type = "primary" bindtap = "onTap" > 进入全屏 </ button > |
index.js
Page({ onTap: function (){ this .playerCtx.requestFullScreen({ direction: 90, success: res => { console.log( 'requestFullScreen success: ' , res) }, fail: res => { console.log( 'requestFullScreen fail: ' , res) } }) }, canvasError: function (e) { console.log( "canvas error " , e) }, onLoad: function (){ wx.setNavigationBarTitle({ title: 'live-player&canvas' }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { this .playerCtx = wx.createLivePlayerContext( "livePlayer" ) this .canvasCtx = wx.createCanvasContext( 'container' ); this .canvasCtx.clearRect(0, 0, 390, 220); this .canvasCtx.setStrokeStyle( "#ff0000" ) this .canvasCtx.setLineWidth(5) this .canvasCtx.strokeRect(10, 10, 370, 200) this .canvasCtx.draw() } }) |
还请知道的高手指点指点,怎么解决live-player全屏时,canvas不能覆盖在其上方的问题。
同样的问题,一模一样
同问, 我这里也发现android, 在live-player 中 使用canvas ,全屏的时候,动画无法显示。
同问,我们用cover-image 做了一个返回按钮。iOS能显示出来,安卓显示不出来
https://developers.weixin.qq.com/community/develop/article/doc/000c4e433707c072c1793e56f5c813
同问,帮顶+1
同问,帮顶