代码片段https://developers.weixin.qq.com/s/oWAma9mZ7Db2
iOS video标签 object-fit属性动态设置无效?机型:iphone xs 微信版本:7.0.5 问题描述:iOS video标签 object-fit属性动态设置无效。现在调用视频全屏方法后,设置objectFit为 contain无效 期望:视频在页面内播放的时候objectFit 是 cover。当调用视频全屏方法后,设置objectFit为 contain。 html代码: [代码][代码]<video custom-cache="{{false}}" id="myVideo" src="{{src}}" objectFit="{{ objectFit }}" direction="{{ 0 }}" bindfullscreenchange="screenChange"></video> <view> <button catchtap="playVideo">播放</button> <button catchtap="fullScreen">全屏</button> </view> [代码][代码]js处理逻辑: [代码]// 系统全屏变化事件[代码][代码]screenChange(e) {[代码][代码] [代码][代码]// 如果退出全屏,则设置 cover[代码][代码] [代码][代码]if[代码] [代码](!e.detail.fullScreen) {[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]objectFit: [代码][代码]'cover'[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码]},[代码][代码]// 按钮点击 播放视频[代码][代码]playVideo() {[代码][代码] [代码][代码]console.log([代码][代码]this[代码][代码].data.objectFit)[代码][代码] [代码][代码]this[代码][代码].videoContext.play()[代码][代码]},[代码][代码]// 按钮点击 全屏[代码][代码]fullScreen() {[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]objectFit: [代码][代码]'contain'[代码][代码] [代码][代码]})[代码][代码] [代码][代码]this[代码][代码].videoContext.requestFullScreen()[代码][代码]}[代码]
2019-09-05