<template>
	<view>

		<video v-if="url != ''" style="width: 100%; height: 100vh;" :src="url" autoplay codec="software" :play-strategy="1" :show-fullscreen-btn="true"  @play="play" @pause="pause"></video>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				link:"",
				url: "",

				play_time_1: 0,
				play_time_2: 0
			};
		},
		onLoad() {
			// #ifndef APP-NVUE
			const eventChannel = this.getOpenerEventChannel();
			// #endif
			// 监听acceptDataFromOpenerPage事件，获取上一页面通过eventChannel传送到当前页面的数据
			eventChannel.on('acceptDataFromOpenerPage', (data) => {
				console.log(data)
				
				uni.setNavigationBarTitle({
					title: data.title
				})
				
				
				this.link = data.url
				this.url = data.url
				
			})
		},
		methods: {
			play() {
				console.log('play:'+this.play_time_1,this.play_time_2)
				let time = this.play_time_1 - this.play_time_2
				
				setTimeout(() => {
					this.play_time_1 += 10
					console.log(this.play_time_1)
				}, 5000)
				
				if (time > 5) {
					this.url = ""
					this.play_time_2 = this.play_time_1
				
					setTimeout(()=>{
						this.url = this.link
					},10)
					
					return
				}


			},
			pause(){
				console.log('pause:暂停')
			}

		}
	}
</script>

<style lang="scss">

</style>
