...
|
...
|
@@ -42,17 +42,17 @@ |
42
|
42
|
|
43
|
43
|
const handleGetVideoPlayUrl = async () => {
|
44
|
44
|
try {
|
45
|
|
- const instance = unref(basicVideoPlayEl)?.getInstance();
|
46
|
45
|
const { config } = props;
|
47
|
46
|
const { option } = config;
|
48
|
47
|
const { videoConfig, uuid } = option || {};
|
49
|
48
|
if (!uuid) return;
|
50
|
49
|
const { url, id, accessMode } = videoConfig || {};
|
51
|
|
- const type = getVideoTypeByUrl(url!);
|
|
50
|
+ let type = getVideoTypeByUrl(url!);
|
52
|
51
|
let playUrl = url;
|
53
|
52
|
if (accessMode === AccessMode.Streaming && id) {
|
54
|
53
|
const { data: { url } = { url: '' } } = await getStreamingPlayUrl(id!);
|
55
|
54
|
playUrl = url;
|
|
55
|
+ playUrl && (type = getVideoTypeByUrl(playUrl!));
|
56
|
56
|
}
|
57
|
57
|
|
58
|
58
|
if (isRtspProtocol(url!)) {
|
...
|
...
|
@@ -60,10 +60,6 @@ |
60
|
60
|
const { visitorId } = result;
|
61
|
61
|
playUrl = getFlvPlayUrl(playUrl!, visitorId);
|
62
|
62
|
withToken.value = true;
|
63
|
|
-
|
64
|
|
- (instance!.options_ as any).flvjs.config.headers = {
|
65
|
|
- 'X-Authorization': `Bearer ${isShareMode() ? getShareJwtToken() : getJwtToken()}`,
|
66
|
|
- };
|
67
|
63
|
}
|
68
|
64
|
|
69
|
65
|
playSource.value = {
|
...
|
...
|
@@ -71,7 +67,17 @@ |
71
|
67
|
type,
|
72
|
68
|
};
|
73
|
69
|
|
74
|
|
- instance?.src(toRaw(unref(playSource)));
|
|
70
|
+ const instance = unref(basicVideoPlayEl)?.customInit((options) => {
|
|
71
|
+ withToken.value = true;
|
|
72
|
+
|
|
73
|
+ if (unref(withToken)) {
|
|
74
|
+ (options as any).flvjs.config.headers = {
|
|
75
|
+ 'X-Authorization': `Bearer ${isShareMode() ? getShareJwtToken() : getJwtToken()}`,
|
|
76
|
+ };
|
|
77
|
+ }
|
|
78
|
+ return { ...options, sources: [toRaw(unref(playSource))] } as VideoJsPlayerOptions;
|
|
79
|
+ });
|
|
80
|
+
|
75
|
81
|
instance?.play();
|
76
|
82
|
} finally {
|
77
|
83
|
loading.value = false;
|
...
|
...
|
@@ -80,8 +86,19 @@ |
80
|
86
|
|
81
|
87
|
const handleSelectPreview = () => {
|
82
|
88
|
loading.value = false;
|
83
|
|
- const instance = unref(basicVideoPlayEl)?.getInstance();
|
84
|
|
- instance?.src({ type: getVideoTypeByUrl(exampleVideoPlay), src: exampleVideoPlay });
|
|
89
|
+ const instance = unref(basicVideoPlayEl)?.customInit((options) => {
|
|
90
|
+ withToken.value = true;
|
|
91
|
+
|
|
92
|
+ if (unref(withToken)) {
|
|
93
|
+ (options as any).flvjs.config.headers = {
|
|
94
|
+ 'X-Authorization': `Bearer ${isShareMode() ? getShareJwtToken() : getJwtToken()}`,
|
|
95
|
+ };
|
|
96
|
+ }
|
|
97
|
+ return {
|
|
98
|
+ ...options,
|
|
99
|
+ sources: [{ type: getVideoTypeByUrl(exampleVideoPlay), src: exampleVideoPlay }],
|
|
100
|
+ } as VideoJsPlayerOptions;
|
|
101
|
+ });
|
85
|
102
|
instance?.play();
|
86
|
103
|
};
|
87
|
104
|
|
...
|
...
|
@@ -103,7 +120,12 @@ |
103
|
120
|
<template>
|
104
|
121
|
<main class="w-full h-full flex flex-col justify-center items-center p-2">
|
105
|
122
|
<Spin :spinning="loading" wrapper-class-name="video-spin">
|
106
|
|
- <BasicVideoPlay ref="basicVideoPlayEl" :options="getOptions" :with-token="withToken" />
|
|
123
|
+ <BasicVideoPlay
|
|
124
|
+ ref="basicVideoPlayEl"
|
|
125
|
+ :options="getOptions"
|
|
126
|
+ :with-token="withToken"
|
|
127
|
+ :immediateInitOnMounted="false"
|
|
128
|
+ />
|
107
|
129
|
</Spin>
|
108
|
130
|
</main>
|
109
|
131
|
</template>
|
...
|
...
|
|