<template>
	<view class="enlargevideo">
		<video id="myVideo" :src="file"
			@error="videoErrorCallback" autoplay controls :show-fullscreen-btn='false' 
				@fullscreenchange='videoControl'
			></video>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				file:'',
			}
		},
		onLoad(options) {
			if(options && options.file){
				this.file =  options.file
			}
			this.videoContext = uni.createVideoContext('myVideo');
			this.videoContext.requestFullScreen({
				direction:0
			})
		},
		methods: {
			videoErrorCallback(){//视频出错返回
				wx.showToast({
					title: '播放失败!',
					icon:'none',
					duration: 1000
				})
				uni.navigateBack({})
			},
			videoControl(e){
				console.log(e.detail)
				if(e.detail.fullScreen==false){
					uni.navigateBack({})
				}
			}
		},
		
	}
</script>

<style>
	.enlargevideo{
		width: 100%;
		height: 100vh;
		display: flex;
		align-items: center;
		justify-content: center;
		background: #000000;
	}
	#myVideo{
		width: 100%;
	}
</style>
