@saooti/octopus-sdk 40.2.12 → 40.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/composable/player/usePlayerLive.ts +15 -2
- package/src/components/composable/player/usePlayerLogicProgress.ts +15 -12
- package/src/components/misc/player/video/PlayerVideo.vue +4 -1
- package/src/components/misc/player/video/PlayerVideoHls.vue +18 -3
- package/src/components/pages/VideoPage.vue +4 -0
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import { Ref, ref } from "vue";
|
|
|
4
4
|
import { usePlayerStore } from "../../../stores/PlayerStore";
|
|
5
5
|
import { useApiStore } from "../../../stores/ApiStore";
|
|
6
6
|
import dayjs from "dayjs";
|
|
7
|
+
import { useAuthStore } from "../../../stores/AuthStore";
|
|
7
8
|
/* eslint-disable*/
|
|
8
9
|
let Hls:any = null;
|
|
9
10
|
/* eslint-enable*/
|
|
@@ -21,6 +22,8 @@ export const usePlayerLive = (hlsReady: Ref<boolean>)=>{
|
|
|
21
22
|
|
|
22
23
|
const playerStore = usePlayerStore();
|
|
23
24
|
const apiStore = useApiStore();
|
|
25
|
+
const authStore = useAuthStore();
|
|
26
|
+
|
|
24
27
|
|
|
25
28
|
function onPlay(): void {
|
|
26
29
|
playerStore.playerChangeStatus("PAUSED"===playerStore.playerStatus);
|
|
@@ -65,7 +68,11 @@ export const usePlayerLive = (hlsReady: Ref<boolean>)=>{
|
|
|
65
68
|
audioElement.value.canPlayType("application/vnd.apple.mpegurl") &&
|
|
66
69
|
!isAndroid
|
|
67
70
|
) {
|
|
68
|
-
|
|
71
|
+
if ("SECURED" === playerStore.playerLive?.organisation?.privacy && authStore.authParam.accessToken) {
|
|
72
|
+
audioElement.value.src = hlsStreamUrl+"?access_token="+authStore.authParam.accessToken;
|
|
73
|
+
}else{
|
|
74
|
+
audioElement.value.src = hlsStreamUrl;
|
|
75
|
+
}
|
|
69
76
|
await initLiveDownloadId();
|
|
70
77
|
hlsReady.value = true;
|
|
71
78
|
await audioElement.value.play();
|
|
@@ -97,7 +104,13 @@ export const usePlayerLive = (hlsReady: Ref<boolean>)=>{
|
|
|
97
104
|
if (!Hls.isSupported()) {
|
|
98
105
|
throw new Error("Hls is not supported ! ");
|
|
99
106
|
}
|
|
100
|
-
hls.value = new Hls(
|
|
107
|
+
hls.value = new Hls({
|
|
108
|
+
xhrSetup: (xhr: XMLHttpRequest) => {
|
|
109
|
+
if ("SECURED" === playerStore.playerLive?.organisation?.privacy && authStore.authParam.accessToken) {
|
|
110
|
+
xhr.setRequestHeader("Authorization", "Bearer " +authStore.authParam.accessToken);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
101
114
|
hls.value.on(Hls.Events.MANIFEST_PARSED, async () => {
|
|
102
115
|
await initLiveDownloadId();
|
|
103
116
|
hlsReady.value = true;
|
|
@@ -68,18 +68,20 @@ export const usePlayerLogicProgress = ()=>{
|
|
|
68
68
|
const downloadId = await classicApi.putData<string | null>({
|
|
69
69
|
api: 0,
|
|
70
70
|
path:"podcast/prepare/live/" + playerStore.playerLive.podcastId+"?mediaType="+mediaType,
|
|
71
|
-
isNotAuth:true
|
|
72
|
-
});
|
|
73
|
-
await classicApi.fetchData<string | null>({
|
|
74
|
-
api:0,
|
|
75
|
-
path: "podcast/download/live/" + playerStore.playerLive.podcastId + ".m3u8",
|
|
76
|
-
parameters:{
|
|
77
|
-
downloadId: downloadId ?? undefined,
|
|
78
|
-
origin: "octopus",
|
|
79
|
-
distributorId: authStore.authOrgaId,
|
|
80
|
-
},
|
|
81
|
-
isNotAuth:true
|
|
82
71
|
});
|
|
72
|
+
try {
|
|
73
|
+
await classicApi.fetchData<string | null>({
|
|
74
|
+
api:0,
|
|
75
|
+
path: "podcast/download/live/" + playerStore.playerLive.podcastId + ".m3u8",
|
|
76
|
+
parameters:{
|
|
77
|
+
downloadId: downloadId ?? undefined,
|
|
78
|
+
origin: "octopus",
|
|
79
|
+
distributorId: authStore.authOrgaId,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
} catch {
|
|
83
|
+
// Remove try/catch when back will no longer redirect with a 403 in a secured context #13594
|
|
84
|
+
}
|
|
83
85
|
setDownloadId(downloadId);
|
|
84
86
|
} catch {
|
|
85
87
|
downloadId.value = null;
|
|
@@ -138,6 +140,7 @@ export const usePlayerLogicProgress = ()=>{
|
|
|
138
140
|
downloadId,
|
|
139
141
|
initLiveDownloadId,
|
|
140
142
|
setDownloadId,
|
|
141
|
-
onTimeUpdateProgress
|
|
143
|
+
onTimeUpdateProgress,
|
|
144
|
+
endListeningProgress
|
|
142
145
|
}
|
|
143
146
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<div class="video-wrapper">
|
|
8
8
|
<PlayerYoutubeEmbed v-if="youtubeId" :youtube-id="youtubeId" />
|
|
9
9
|
<PlayerVideoDigiteka v-else-if="!playerLive" :video-id="playerPodcast?.video?.videoId" />
|
|
10
|
-
<PlayerVideoHls v-else :hls-url="hlsVideoUrl" />
|
|
10
|
+
<PlayerVideoHls v-else :hls-url="hlsVideoUrl" :is-secured="isSecured"/>
|
|
11
11
|
</div>
|
|
12
12
|
</template>
|
|
13
13
|
</teleport>
|
|
@@ -45,6 +45,9 @@ export default defineComponent({
|
|
|
45
45
|
computed: {
|
|
46
46
|
...mapState(useApiStore, ["hlsUrl"]),
|
|
47
47
|
...mapState(usePlayerStore, ["playerVideo", "playerLive", "playerPodcast"]),
|
|
48
|
+
isSecured(): boolean{
|
|
49
|
+
return "SECURED" === this.playerLive?.organisation?.privacy;
|
|
50
|
+
},
|
|
48
51
|
hlsVideoUrl(): string {
|
|
49
52
|
if (!this.playerLive) {
|
|
50
53
|
return "";
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
</template>
|
|
16
16
|
<script lang="ts">
|
|
17
17
|
import { usePlayerStore } from "../../../../stores/PlayerStore";
|
|
18
|
-
import { mapActions } from "pinia";
|
|
18
|
+
import { mapActions, mapState } from "pinia";
|
|
19
19
|
import {usePlayerLogicProgress} from "../../../composable/player/usePlayerLogicProgress";
|
|
20
20
|
import videojs, { VideoJsPlayer } from "video.js";
|
|
21
21
|
import qualitySelectorHls from "videojs-quality-selector-hls";
|
|
@@ -23,18 +23,20 @@ if (undefined === videojs.getPlugin("qualitySelectorHls")) {
|
|
|
23
23
|
videojs.registerPlugin("qualitySelectorHls", qualitySelectorHls);
|
|
24
24
|
}
|
|
25
25
|
import { defineComponent } from "vue";
|
|
26
|
+
import { useAuthStore } from "../../../../stores/AuthStore";
|
|
26
27
|
export default defineComponent({
|
|
27
28
|
name: "PlayerVideoHls",
|
|
28
29
|
|
|
29
30
|
props: {
|
|
30
31
|
hlsUrl: { default: "", type: String },
|
|
31
32
|
responsive: { default: false, type: Boolean },
|
|
33
|
+
isSecured: { default: true, type: Boolean }, //TODO
|
|
32
34
|
},
|
|
33
35
|
emits: ["changeValid"],
|
|
34
36
|
|
|
35
37
|
setup(){
|
|
36
|
-
const { downloadId, initLiveDownloadId, onTimeUpdateProgress} = usePlayerLogicProgress();
|
|
37
|
-
return { downloadId, initLiveDownloadId, onTimeUpdateProgress }
|
|
38
|
+
const { downloadId, initLiveDownloadId, onTimeUpdateProgress, endListeningProgress} = usePlayerLogicProgress();
|
|
39
|
+
return { downloadId, initLiveDownloadId, onTimeUpdateProgress, endListeningProgress }
|
|
38
40
|
},
|
|
39
41
|
data() {
|
|
40
42
|
return {
|
|
@@ -47,6 +49,7 @@ export default defineComponent({
|
|
|
47
49
|
};
|
|
48
50
|
},
|
|
49
51
|
computed: {
|
|
52
|
+
...mapState(useAuthStore, ["authParam"]),
|
|
50
53
|
videoElement(): HTMLVideoElement {
|
|
51
54
|
return this.$refs.videoelement as HTMLVideoElement;
|
|
52
55
|
},
|
|
@@ -104,6 +107,15 @@ export default defineComponent({
|
|
|
104
107
|
this.playLiveIos();
|
|
105
108
|
return;
|
|
106
109
|
}
|
|
110
|
+
if (this.isSecured && this.authParam.accessToken) {
|
|
111
|
+
const globalXhrRequestHook = (options: any) => {
|
|
112
|
+
options.beforeSend = (xhr: XMLHttpRequest) => {
|
|
113
|
+
xhr.setRequestHeader("Authorization", "Bearer "+this.authParam.accessToken);
|
|
114
|
+
};
|
|
115
|
+
return options;
|
|
116
|
+
};
|
|
117
|
+
videojs.Vhs.xhr.onRequest(globalXhrRequestHook);
|
|
118
|
+
}
|
|
107
119
|
this.player = videojs(
|
|
108
120
|
document.getElementById("video-element-hls") as Element,
|
|
109
121
|
this.videoOptions,
|
|
@@ -165,6 +177,9 @@ export default defineComponent({
|
|
|
165
177
|
this.videoElement.onseeking = async () => {
|
|
166
178
|
this.playerUpdateSeekTime(this.videoElement.currentTime);
|
|
167
179
|
};
|
|
180
|
+
/* if ("SECURED" === playerStore.playerLive?.organisation?.privacy && authStore.authParam.accessToken) {
|
|
181
|
+
} */
|
|
182
|
+
//TODO
|
|
168
183
|
this.videoElement.src = this.hlsUrl;
|
|
169
184
|
},
|
|
170
185
|
videoClean(): void {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
<PlayerVideoHls
|
|
21
21
|
v-if="recordingLive"
|
|
22
22
|
:hls-url="hlsVideoUrl"
|
|
23
|
+
:is-secured="isSecured"
|
|
23
24
|
:responsive="true"
|
|
24
25
|
/>
|
|
25
26
|
<div
|
|
@@ -190,6 +191,9 @@ const hlsVideoUrl = computed(() => {
|
|
|
190
191
|
}
|
|
191
192
|
return `${apiStore.hlsUrl}live/video_dev.${podcastConference.value.conferenceId}/index.m3u8`;
|
|
192
193
|
});
|
|
194
|
+
const isSecured = computed(() => {
|
|
195
|
+
return "SECURED" === podcast.value?.organisation?.privacy;
|
|
196
|
+
});
|
|
193
197
|
const overrideText = computed(() => {
|
|
194
198
|
if ("PUBLISHING" !== podcastConference.value?.status) {
|
|
195
199
|
return;
|