Feat: switch url diff type
This commit is contained in:
parent
faa3bac79d
commit
eb57537cf7
|
@ -67,7 +67,7 @@ const Props = defineProps({
|
|||
|
||||
const Emits = defineEmits(["get-instance"]);
|
||||
|
||||
const playMpd = async (player: HTMLMediaElement, url: string, art: any) => {
|
||||
const playMpd = async (player: HTMLMediaElement, url: string, art: Artplayer) => {
|
||||
const dashjs = await import("dashjs");
|
||||
|
||||
if (!dashjs.supportsMediaSource()) {
|
||||
|
@ -75,13 +75,13 @@ const playMpd = async (player: HTMLMediaElement, url: string, art: any) => {
|
|||
return;
|
||||
}
|
||||
|
||||
if (art.dash) art.dash.destroy();
|
||||
if (art.mpd) art.mpd.destroy();
|
||||
|
||||
if (!art.plugins.artplayerPluginDashQuality) art.plugins.add(newDashQualityPlugin());
|
||||
|
||||
const d = dashjs.MediaPlayer().create();
|
||||
d.initialize(player, url, false);
|
||||
art.dash = d;
|
||||
art.mpd = d;
|
||||
art.on("destroy", d.destroy);
|
||||
};
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ enum pushType {
|
|||
interface movieTypeRecord {
|
||||
name: string;
|
||||
comment: string;
|
||||
advanced: boolean;
|
||||
showProxy: boolean;
|
||||
defaultType: string;
|
||||
allowedTypes: Array<{ name: string; value: string }>;
|
||||
|
@ -63,6 +64,7 @@ const movieTypeRecords: Map<pushType, movieTypeRecord> = new Map([
|
|||
{
|
||||
name: "视频直链",
|
||||
comment: "",
|
||||
advanced: true,
|
||||
showProxy: true,
|
||||
defaultType: "",
|
||||
allowedTypes: [
|
||||
|
@ -98,6 +100,7 @@ const movieTypeRecords: Map<pushType, movieTypeRecord> = new Map([
|
|||
{
|
||||
name: "直播流",
|
||||
comment: "",
|
||||
advanced: true,
|
||||
showProxy: false,
|
||||
defaultType: "",
|
||||
allowedTypes: [
|
||||
|
@ -121,6 +124,7 @@ const movieTypeRecords: Map<pushType, movieTypeRecord> = new Map([
|
|||
{
|
||||
name: "代理直播流",
|
||||
comment: "仅支持rtmp和flv代理",
|
||||
advanced: true,
|
||||
showProxy: false,
|
||||
defaultType: "",
|
||||
allowedTypes: []
|
||||
|
@ -131,18 +135,10 @@ const movieTypeRecords: Map<pushType, movieTypeRecord> = new Map([
|
|||
{
|
||||
name: "创建直播",
|
||||
comment: "用户可自行推流",
|
||||
advanced: false,
|
||||
showProxy: false,
|
||||
defaultType: "flv",
|
||||
allowedTypes: [
|
||||
{
|
||||
name: "flv",
|
||||
value: "flv"
|
||||
},
|
||||
{
|
||||
name: "m3u8",
|
||||
value: "m3u8"
|
||||
}
|
||||
]
|
||||
allowedTypes: []
|
||||
}
|
||||
],
|
||||
[
|
||||
|
@ -150,6 +146,7 @@ const movieTypeRecords: Map<pushType, movieTypeRecord> = new Map([
|
|||
{
|
||||
name: "哔哩哔哩",
|
||||
comment: "解析Bilibili视频",
|
||||
advanced: false,
|
||||
showProxy: false,
|
||||
defaultType: "",
|
||||
allowedTypes: []
|
||||
|
@ -160,6 +157,7 @@ const movieTypeRecords: Map<pushType, movieTypeRecord> = new Map([
|
|||
{
|
||||
name: "AList",
|
||||
comment: "解析 AList 视频",
|
||||
advanced: false,
|
||||
showProxy: false,
|
||||
defaultType: "",
|
||||
allowedTypes: []
|
||||
|
@ -170,6 +168,7 @@ const movieTypeRecords: Map<pushType, movieTypeRecord> = new Map([
|
|||
{
|
||||
name: "Emby",
|
||||
comment: "解析 Emby 视频",
|
||||
advanced: false,
|
||||
showProxy: false,
|
||||
defaultType: "",
|
||||
allowedTypes: []
|
||||
|
@ -179,7 +178,8 @@ const movieTypeRecords: Map<pushType, movieTypeRecord> = new Map([
|
|||
pushType.DIR,
|
||||
{
|
||||
name: "文件夹",
|
||||
comment: "新建普通文件夹",
|
||||
comment: "新建文件夹",
|
||||
advanced: false,
|
||||
showProxy: false,
|
||||
defaultType: "",
|
||||
allowedTypes: [],
|
||||
|
@ -235,6 +235,7 @@ const selectPushType = () => {
|
|||
rtmpSource: false,
|
||||
headers: {}
|
||||
};
|
||||
break;
|
||||
case pushType.BILIBILI:
|
||||
newMovieInfo.value = {
|
||||
url: newMovieInfo.value.url,
|
||||
|
@ -478,7 +479,7 @@ const getBiliBiliVendors = async () => {
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mx-5" v-if="!newMovieInfo.vendorInfo?.vendor && selectedMovieType != pushType.DIR">
|
||||
<div class="mx-5" v-if="movieTypeRecords.get(selectedMovieType)?.advanced">
|
||||
<el-collapse @change="" class="bg-transparent" style="background: #aaa0 !important">
|
||||
<el-collapse-item>
|
||||
<template #title><div class="text-base font-medium">高级选项</div></template>
|
||||
|
|
|
@ -91,7 +91,6 @@ export const useMovieApi = (roomToken: string) => {
|
|||
|
||||
if (!currentMovie.value) return;
|
||||
|
||||
room.currentMovie = currentMovie.value.movie;
|
||||
room.currentStatus = currentMovie.value.status;
|
||||
room.currentExpireId = currentMovie.value.expireId;
|
||||
|
||||
|
@ -99,10 +98,16 @@ export const useMovieApi = (roomToken: string) => {
|
|||
currentMovie.value.movie.base.url = `${window.location.origin}${currentMovie.value.movie.base.url}`;
|
||||
}
|
||||
|
||||
for (let key in currentMovie.value.movie.base.moreSource) {
|
||||
if (currentMovie.value.movie.base.moreSource[key].startsWith("/")) {
|
||||
currentMovie.value.movie.base.moreSource[key] =
|
||||
`${window.location.origin}${currentMovie.value.movie.base.moreSource[key]}`;
|
||||
// 遍历currentMovie.value.movie.base.moreSources,moreSources是数组,而不是对象
|
||||
if (
|
||||
currentMovie.value.movie.base.moreSources &&
|
||||
currentMovie.value.movie.base.moreSources.length > 0
|
||||
) {
|
||||
for (let i = 0; i < currentMovie.value.movie.base.moreSources.length; i++) {
|
||||
if (currentMovie.value.movie.base.moreSources[i].url.startsWith("/")) {
|
||||
currentMovie.value.movie.base.moreSources[i].url =
|
||||
`${window.location.origin}${currentMovie.value.movie.base.moreSources[i].url}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,7 +117,7 @@ export const useMovieApi = (roomToken: string) => {
|
|||
`${window.location.origin}${currentMovie.value.movie.base.subtitles[key].url}`;
|
||||
}
|
||||
}
|
||||
room.currentMovie.base.subtitles = currentMovie.value.movie.base.subtitles;
|
||||
room.currentMovie = currentMovie.value.movie;
|
||||
} catch (err: any) {
|
||||
console.log(err);
|
||||
ElNotification({
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import type Artplayer from "artplayer";
|
||||
|
||||
interface artplayPluginSource {
|
||||
url: string;
|
||||
html: string;
|
||||
url: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export function artplayPluginSource(option: artplayPluginSource[]) {
|
||||
|
@ -16,6 +17,7 @@ export function artplayPluginSource(option: artplayPluginSource[]) {
|
|||
art.once("video:canplay", () => {
|
||||
art.plugins["syncPlugin"].setAndNoPublishStatus(status);
|
||||
});
|
||||
art.option.type = item.type;
|
||||
art.url = item.url;
|
||||
return "源";
|
||||
}
|
||||
|
|
|
@ -21,11 +21,15 @@ export interface Subtitles {
|
|||
};
|
||||
}
|
||||
|
||||
export interface MoreSource {
|
||||
name: string;
|
||||
url: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface BaseMovieInfo {
|
||||
url: string;
|
||||
moreSource?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
moreSources?: MoreSource[];
|
||||
name: string;
|
||||
live: boolean;
|
||||
proxy: boolean;
|
||||
|
|
|
@ -145,17 +145,19 @@ const playerOption = computed<options>(() => {
|
|||
]
|
||||
};
|
||||
|
||||
if (room.currentMovie.base!.moreSource) {
|
||||
const obj = room.currentMovie.base!.moreSource;
|
||||
if (room.currentMovie.base!.moreSources) {
|
||||
const obj = room.currentMovie.base!.moreSources;
|
||||
option.plugins!.push(
|
||||
artplayPluginSource([
|
||||
{
|
||||
url: option.url,
|
||||
html: "默认"
|
||||
html: "默认",
|
||||
type: option.type || ""
|
||||
},
|
||||
...Object.keys(obj).map((key) => ({
|
||||
url: obj[key],
|
||||
html: key
|
||||
...obj.map((item) => ({
|
||||
url: item.url,
|
||||
html: item.name,
|
||||
type: item.type
|
||||
}))
|
||||
])
|
||||
);
|
||||
|
@ -226,10 +228,11 @@ const switchCurrentMovie = async () => {
|
|||
}
|
||||
|
||||
if (!player) return;
|
||||
player.url = currentMovie.value.movie.base.url;
|
||||
const currentExpireId = currentMovie.value.expireId;
|
||||
const currentStatus = currentMovie.value.status;
|
||||
room.currentExpireId = currentExpireId;
|
||||
player.option.type = currentMovie.value.movie.base.type;
|
||||
player.url = currentMovie.value.movie.base.url;
|
||||
player.once("video:canplay", () => {
|
||||
if (room.currentExpireId != currentExpireId) return;
|
||||
setPlayerStatus(currentStatus);
|
||||
|
|
Loading…
Reference in New Issue