Change url episode query param and update artplayer urls
This commit is contained in:
@ -6,7 +6,7 @@ import { EpisodeChangeType } from "./ChangeEpisodeButton.vue";
|
||||
import { UiPlayerChangeEpisodeButton } from "#components";
|
||||
|
||||
interface Props {
|
||||
urls: any;
|
||||
urls: any[];
|
||||
id: string;
|
||||
episodeButton: boolean;
|
||||
}
|
||||
@ -17,36 +17,12 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
const emit = defineEmits(['get-instance'])
|
||||
|
||||
const options = computed(() => {
|
||||
const controls = []
|
||||
if (props.episodeButton) {
|
||||
controls.push(
|
||||
createVueControlSmart(UiPlayerChangeEpisodeButton, {
|
||||
name: "next-episode",
|
||||
index: 50,
|
||||
tooltip: "Next episode",
|
||||
type: EpisodeChangeType.NEXT
|
||||
}, {
|
||||
click: () => console.log("NEXT")
|
||||
})
|
||||
)
|
||||
controls.push(
|
||||
createVueControlSmart(UiPlayerChangeEpisodeButton, {
|
||||
name: "previous-episode",
|
||||
index: 50,
|
||||
tooltip: "Previous episode",
|
||||
type: EpisodeChangeType.PREVIOUS
|
||||
}, {
|
||||
click: () => console.log("Previous")
|
||||
})
|
||||
)
|
||||
}
|
||||
return {
|
||||
url: props.urls[0].url || '',
|
||||
type: 'm3u8',
|
||||
customType: {
|
||||
m3u8: playM3u8,
|
||||
},
|
||||
quality: props.urls,
|
||||
autoSize: true,
|
||||
autoMini: true,
|
||||
playbackRate: true,
|
||||
@ -57,7 +33,6 @@ const options = computed(() => {
|
||||
autoOrientation: true,
|
||||
autoPlayback: true,
|
||||
id: props.id,
|
||||
controls: controls,
|
||||
}
|
||||
})
|
||||
const artplayerRef = ref();
|
||||
@ -83,6 +58,24 @@ onMounted(() => {
|
||||
container: artplayerRef.value,
|
||||
...options.value,
|
||||
})
|
||||
if (props.episodeButton) {
|
||||
instance.value.controls.add(
|
||||
createVueControlSmart(UiPlayerChangeEpisodeButton, {
|
||||
name: "next-episode",
|
||||
index: 50,
|
||||
tooltip: "Next episode",
|
||||
type: EpisodeChangeType.NEXT,
|
||||
})
|
||||
)
|
||||
instance.value.controls.add(
|
||||
createVueControlSmart(UiPlayerChangeEpisodeButton, {
|
||||
name: "previous-episode",
|
||||
index: 50,
|
||||
tooltip: "Previous episode",
|
||||
type: EpisodeChangeType.PREVIOUS,
|
||||
})
|
||||
)
|
||||
}
|
||||
nextTick(() => {
|
||||
emit('get-instance')
|
||||
})
|
||||
@ -93,6 +86,13 @@ onBeforeUnmount(() => {
|
||||
instance.value.destroy(false)
|
||||
}
|
||||
})
|
||||
|
||||
watch([instance, () => props.urls], async ([artplayer, urls]) => {
|
||||
if (!artplayer) return;
|
||||
artplayer.quality = urls;
|
||||
artplayer.switch = urls[0].url;
|
||||
instance.value = artplayer;
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
Reference in New Issue
Block a user