<template>
	<video id="myVideo" :src="videoSrc"
	@error="videoErrorCallback" :danmu-list="danmuList" :poster="posterSrc" controls></video>
</template>

<script>
	import { getGuildbookList } from '../api/index.js'
	const placeMap = {
		'hba': '黄避岙',
		'xqg': '蟹钳港'
	}
	export default({
		data() {
			return {
				place: '',
				posterSrc: '',
				videoSrc: ''
			}
		},
		methods: {
			getVideoInfo() {
				getGuildbookList().then(res => {
					if (res.code === 0) {
						let info = res.data.filter(item => {
							return item.remark === placeMap[this.place] && item.bookSrc.includes('mp4')
						})
						this.posterSrc = this.$staticUrl + info[0].coverSrc
						this.videoSrc = this.$staticUrl + info[0].bookSrc
					}
				})
			},
		},

		onLoad(opt) {
			this.place = opt.place
			this.getVideoInfo()
		}
	})
</script>

<style lang="scss" scoped>
	#myVideo{
		height: 100vh;
		width: 100%;
	}
</style>