<template>
	<feed-vertical-reel
		ref="reel"
		:frame-w="width"
		:frame-h="height"
		:safe-bottom="safeBottom"
		:tab-active="tabActive"
		:auto-bootstrap="false"
		:loop-at-end="true"
		:entry-find-id="find_id"
		:entry-label-id="label_id"
		:entry-list-type="list_type"
		:entry-user-no="user_no"
		:entry-page="entryPageNum"
		:entry-comp-id="compID"
		:entry-order-type="order_type"
		:entry-is-hot-dian="is_hot_dian"
		:entry-search="search"
		@tabbar-change="$emit('tabbar-change', $event)"
	/>
</template>

<script>
import FeedVerticalReel from '@/components/feed-reel/vertical-reel.vue'

/**
 * 发现页竖滑播放器（对外接口同 88live components/find/play.vue）
 * nvue 页 video.nvue 引入本组件；内部复用 feed-vertical-reel 实现播放/点赞/评论。
 */
export default {
	name: 'FindPlay',
	components: { FeedVerticalReel },
	props: {
		label_id: {
			type: [String, Number],
			default: ''
		},
		find_id: {
			type: [String, Number],
			default: ''
		},
		/** 个人主页入口：works | likes | myfind */
		list_type: {
			type: [String, Number],
			default: ''
		},
		user_no: {
			type: [String, Number],
			default: ''
		},
		compID: {
			type: [String, Number],
			default: ''
		},
		order_type: {
			type: [String, Number],
			default: ''
		},
		is_hot_dian: {
			type: [String, Number],
			default: ''
		},
		/** 搜索入口：关键词，列表请求带 search */
		search: {
			type: [String, Number],
			default: ''
		},
		isComment: {
			type: [String, Boolean],
			default: 'Y'
		},
		height: {
			type: Number,
			default: 0
		},
		width: {
			type: Number,
			default: 0
		},
		bottom: { type: Number, default: 0 },
		safeBottom: {
			type: Number,
			default: 0
		},
		page: {
			type: [String, Number],
			default: 1
		},
		tabActive: {
			type: Boolean,
			default: true
		}
	},
	computed: {
		entryPageNum() {
			const n = Number(this.page)
			return Number.isFinite(n) && n > 0 ? n : 1
		}
	},
	methods: {
		handleVideoPlay() {
			const reel = this.$refs.reel
			if (reel && typeof reel.wakePlayback === 'function') {
				reel.wakePlayback()
			}
		},
		handleVideoPause() {
			const reel = this.$refs.reel
			if (reel && typeof reel.freezePlayback === 'function') {
				reel.freezePlayback()
			}
		},
		tryEntryBootstrap(force = false) {
			const reel = this.$refs.reel
			if (reel && typeof reel.tryEntryBootstrap === 'function') {
				reel.tryEntryBootstrap(force)
			}
		}
	}
}
</script>
