| | |
| | | <template> |
| | | <div class="video-player"> |
| | | <canvas v-show="showArea" id="area-canvas" ref="areaCanvas" :width="canvasWidth" :height="canvasHeight"></canvas> |
| | | <canvas v-show="showArea" id="area-canvas" ref="areaCanvas" width="960" height="540"></canvas> |
| | | <video ref="videoPlayer" :poster="poster" preload="auto" muted></video> |
| | | <div class="controls"> |
| | | <!-- 全屏 --> |
| | |
| | | }, |
| | | showArea: { |
| | | type: Boolean, |
| | | default: true |
| | | default: false |
| | | } |
| | | }, |
| | | |
| | |
| | | //showProportionY: 3.58, |
| | | showProportion: 1.036, |
| | | showProportionY: 1.039, |
| | | // showProportion: 1.666, |
| | | // showProportionY: 1.666, |
| | | canvas: null, |
| | | ctx: null, |
| | | canvasWidth: 0, |
| | |
| | | setWidthHeight(){ |
| | | this.canvasWidth = this.$refs.videoPlayer.offsetWidth; |
| | | this.canvasHeight = this.$refs.videoPlayer.offsetHeight; |
| | | console.log(this.canvasWidth,this.canvasHeight) |
| | | }, |
| | | async initArea(){ |
| | | console.log('init') |
| | |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.clickStart(); |
| | | //获取video宽高并给区域canvas赋值 |
| | | this.setWidthHeight(); |
| | | //this.setWidthHeight(); |
| | | this.clickStart(); |
| | | |
| | | window.addEventListener('resize',()=>{ |
| | | //this.setWidthHeight(); |
| | | //this.initArea(); |