|
|
@@ -32,6 +32,10 @@ const props = defineProps({
|
|
|
height: {
|
|
|
type: String,
|
|
|
default: '630px'
|
|
|
+ },
|
|
|
+ uid: {
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
}
|
|
|
})
|
|
|
const playing = ref(false)
|
|
|
@@ -70,7 +74,7 @@ const playCreate = async () => {
|
|
|
const container = easyPlayerRef.value
|
|
|
if (!container) return
|
|
|
|
|
|
- const uid = route.params._uid || Date.now() // 使用时间戳作为唯一标识
|
|
|
+ const uid = props.uid || route.params._uid || Date.now() // 使用时间戳作为唯一标识
|
|
|
|
|
|
easyplayer[uid] = new EasyPlayerPro(container, {
|
|
|
isLive: config.isLive,
|
|
|
@@ -124,7 +128,7 @@ const playCreate = async () => {
|
|
|
// 播放视频
|
|
|
async function play(url) {
|
|
|
await loadEasyPlayer()
|
|
|
- const uid = route.params._uid || Date.now()
|
|
|
+ const uid = props.uid || route.params._uid || Date.now() // 使用时间戳作为唯一标识
|
|
|
|
|
|
// 确保容器已准备就绪
|
|
|
if (!easyPlayerRef.value) {
|
|
|
@@ -158,7 +162,7 @@ async function play(url) {
|
|
|
}
|
|
|
|
|
|
const pause = () => {
|
|
|
- const uid = route.params._uid || Date.now()
|
|
|
+ const uid = props.uid || route.params._uid || Date.now() // 使用时间戳作为唯一标识
|
|
|
|
|
|
if (easyplayer[uid]) {
|
|
|
easyplayer[uid].pause()
|
|
|
@@ -168,7 +172,7 @@ const pause = () => {
|
|
|
|
|
|
// 截图
|
|
|
const screenshot = () => {
|
|
|
- const uid = route.params._uid || Date.now()
|
|
|
+ const uid = props.uid || route.params._uid || Date.now() // 使用时间戳作为唯一标识
|
|
|
|
|
|
if (easyplayer[uid]) {
|
|
|
easyplayer[uid].screenshot()
|
|
|
@@ -177,7 +181,7 @@ const screenshot = () => {
|
|
|
}
|
|
|
|
|
|
const destroy = async () => {
|
|
|
- const uid = route.params._uid || Date.now()
|
|
|
+ const uid = props.uid || route.params._uid || Date.now() // 使用时间戳作为唯一标识
|
|
|
|
|
|
if (easyplayer[uid]) {
|
|
|
await easyplayer[uid].destroy().then(() => {
|
|
|
@@ -200,7 +204,7 @@ const onMute = () => {
|
|
|
// playInfo.value.setMute(true)
|
|
|
// }
|
|
|
|
|
|
- const uid = route.params._uid || Date.now()
|
|
|
+ const uid = props.uid || route.params._uid || Date.now() // 使用时间戳作为唯一标识
|
|
|
|
|
|
if (easyplayer[uid]) {
|
|
|
easyplayer[uid].setMute(true)
|
|
|
@@ -302,8 +306,8 @@ onMounted(() => {
|
|
|
})
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
- if (easyplayer[route.params._uid]) {
|
|
|
- easyplayer[route.params._uid].destroy()
|
|
|
+ if (easyplayer[props.uid || route.params._uid || Date.now()]) {
|
|
|
+ easyplayer[props.uid || route.params._uid || Date.now()].destroy()
|
|
|
}
|
|
|
playing.value = false
|
|
|
})
|