@saooti/octopus-sdk 37.0.29 → 37.0.31
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/display/sharing/SharePlayer.vue +2 -2
- package/src/components/misc/player/PlayerCompact.vue +1 -3
- package/src/components/misc/player/PlayerComponent.vue +0 -2
- package/src/components/misc/player/PlayerLarge.vue +1 -3
- package/src/components/misc/player/PlayerProgressBar.vue +4 -4
- package/src/components/misc/player/PlayerVideoDigiteka.vue +9 -7
- package/src/components/misc/player/PlayerVideoHls.vue +35 -26
- package/src/components/mixins/player/playerLive.ts +5 -51
- package/src/components/mixins/player/playerLogic.ts +1 -44
- package/src/components/mixins/player/playerLogicProgress.ts +134 -0
- package/src/stores/ParamSdkStore.ts +1 -1
package/package.json
CHANGED
|
@@ -219,8 +219,8 @@ export default defineComponent({
|
|
|
219
219
|
iFrameSrc(): string {
|
|
220
220
|
if ("video" === this.iFrameModel) {
|
|
221
221
|
return (
|
|
222
|
-
"
|
|
223
|
-
this.podcast?.video?.videoId
|
|
222
|
+
"https://www.ultimedia.com/deliver/generic/iframe/mdtk/01009833/zone/1/showtitle/1/src/" +
|
|
223
|
+
this.podcast?.video?.videoId + "/sound/true"
|
|
224
224
|
);
|
|
225
225
|
}
|
|
226
226
|
let url = [""];
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
:duration-live-position="durationLivePosition"
|
|
44
44
|
:player-error="playerError"
|
|
45
45
|
:listen-time="listenTime"
|
|
46
|
-
@update-not-listen-time="$emit('update:notListenTime', $event)"
|
|
47
46
|
/>
|
|
48
47
|
<RadioProgressBar v-else />
|
|
49
48
|
</div>
|
|
@@ -90,7 +89,6 @@ export default defineComponent({
|
|
|
90
89
|
|
|
91
90
|
props: {
|
|
92
91
|
playerError: { default: false, type: Boolean },
|
|
93
|
-
notListenTime: { default: 0, type: Number },
|
|
94
92
|
comments: { default: () => [], type: Array as () => Array<CommentPodcast> },
|
|
95
93
|
displayAlertBar: { default: false, type: Boolean },
|
|
96
94
|
percentLiveProgress: { default: 0, type: Number },
|
|
@@ -99,7 +97,7 @@ export default defineComponent({
|
|
|
99
97
|
hlsReady: { default: false, type: Boolean },
|
|
100
98
|
},
|
|
101
99
|
|
|
102
|
-
emits: ["stopPlayer", "
|
|
100
|
+
emits: ["stopPlayer", "changePlayerLargeVersion"],
|
|
103
101
|
data() {
|
|
104
102
|
return {
|
|
105
103
|
showTimeline: false as boolean,
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
/>
|
|
23
23
|
<PlayerCompact
|
|
24
24
|
v-if="!playerLargeVersion"
|
|
25
|
-
v-model:notListenTime="notListenTime"
|
|
26
25
|
:player-error="playerError"
|
|
27
26
|
:comments="comments"
|
|
28
27
|
:display-alert-bar="displayAlertBar"
|
|
@@ -35,7 +34,6 @@
|
|
|
35
34
|
/>
|
|
36
35
|
<PlayerLarge
|
|
37
36
|
v-else
|
|
38
|
-
v-model:notListenTime="notListenTime"
|
|
39
37
|
:player-error="playerError"
|
|
40
38
|
:comments="comments"
|
|
41
39
|
:display-alert-bar="displayAlertBar"
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
:duration-live-position="durationLivePosition"
|
|
37
37
|
:player-error="playerError"
|
|
38
38
|
:listen-time="listenTime"
|
|
39
|
-
@update-not-listen-time="$emit('update:notListenTime', $event)"
|
|
40
39
|
/>
|
|
41
40
|
<RadioProgressBar v-else />
|
|
42
41
|
<div class="d-flex justify-content-between">
|
|
@@ -112,7 +111,6 @@ export default defineComponent({
|
|
|
112
111
|
|
|
113
112
|
props: {
|
|
114
113
|
playerError: { default: false, type: Boolean },
|
|
115
|
-
notListenTime: { default: 0, type: Number },
|
|
116
114
|
comments: { default: () => [], type: Array as () => Array<CommentPodcast> },
|
|
117
115
|
displayAlertBar: { default: false, type: Boolean },
|
|
118
116
|
percentLiveProgress: { default: 0, type: Number },
|
|
@@ -121,7 +119,7 @@ export default defineComponent({
|
|
|
121
119
|
hlsReady: { default: false, type: Boolean },
|
|
122
120
|
},
|
|
123
121
|
|
|
124
|
-
emits: ["stopPlayer", "
|
|
122
|
+
emits: ["stopPlayer", "changePlayerLargeVersion"],
|
|
125
123
|
data() {
|
|
126
124
|
return {
|
|
127
125
|
showTimeline: false as boolean,
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
17
|
<script lang="ts">
|
|
18
|
+
import { usePlayerStore } from "@/stores/PlayerStore";
|
|
19
|
+
import { mapState, mapActions } from "pinia";
|
|
18
20
|
import ProgressBar from "../ProgressBar.vue";
|
|
19
21
|
import { CommentPodcast } from "@/stores/class/general/comment";
|
|
20
|
-
import { usePlayerStore } from "@/stores/PlayerStore";
|
|
21
|
-
import { mapState } from "pinia";
|
|
22
22
|
import { defineComponent, defineAsyncComponent } from "vue";
|
|
23
23
|
const CommentPlayer = defineAsyncComponent(
|
|
24
24
|
() => import("../../display/comments/CommentPlayer.vue"),
|
|
@@ -40,7 +40,6 @@ export default defineComponent({
|
|
|
40
40
|
playerError: { default: false, type: Boolean },
|
|
41
41
|
listenTime: { default: 0, type: Number },
|
|
42
42
|
},
|
|
43
|
-
emits: ["updateNotListenTime"],
|
|
44
43
|
|
|
45
44
|
computed: {
|
|
46
45
|
...mapState(usePlayerStore, [
|
|
@@ -58,6 +57,7 @@ export default defineComponent({
|
|
|
58
57
|
},
|
|
59
58
|
|
|
60
59
|
methods: {
|
|
60
|
+
...mapActions(usePlayerStore, ["playerUpdateSeekTime"]),
|
|
61
61
|
seekTo(event: MouseEvent): void {
|
|
62
62
|
const audioPlayer: HTMLAudioElement | null =
|
|
63
63
|
document.querySelector("#audio-player");
|
|
@@ -74,7 +74,7 @@ export default defineComponent({
|
|
|
74
74
|
},
|
|
75
75
|
isSeekTo(audioPlayer: HTMLAudioElement, seekTime: number): void {
|
|
76
76
|
if (this.playerPodcast || this.playerLive) {
|
|
77
|
-
this
|
|
77
|
+
this.playerUpdateSeekTime(seekTime);
|
|
78
78
|
}
|
|
79
79
|
audioPlayer.currentTime = seekTime;
|
|
80
80
|
},
|
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
width="500"
|
|
7
7
|
height="281"
|
|
8
8
|
style="z-index: 1"
|
|
9
|
+
ebkitallowfullscreen="true"
|
|
10
|
+
mozallowfullscreen="true"
|
|
9
11
|
allowfullscreen="true"
|
|
10
|
-
allow="autoplay"
|
|
12
|
+
allow="fullscreen, autoplay"
|
|
11
13
|
referrerpolicy="no-referrer-when-downgrade"
|
|
12
14
|
></iframe>
|
|
13
15
|
</template>
|
|
@@ -27,22 +29,22 @@ export default defineComponent({
|
|
|
27
29
|
return (
|
|
28
30
|
"//www.ultimedia.com/deliver/generic/iframe/mdtk/01009833/zone/1/showtitle/1/src/" +
|
|
29
31
|
this.playerPodcast?.video?.videoId +
|
|
30
|
-
"/autoplay/1"
|
|
32
|
+
"/sound/true/autoplay/1"
|
|
31
33
|
);
|
|
32
34
|
}
|
|
33
35
|
return "";
|
|
34
36
|
},
|
|
35
37
|
},
|
|
36
38
|
watch: {
|
|
37
|
-
srcVideo() {
|
|
39
|
+
/* srcVideo() {
|
|
38
40
|
this.goFullScreen();
|
|
39
|
-
},
|
|
41
|
+
}, */
|
|
40
42
|
},
|
|
41
43
|
mounted() {
|
|
42
|
-
this.goFullScreen();
|
|
44
|
+
/* this.goFullScreen(); */
|
|
43
45
|
},
|
|
44
46
|
methods: {
|
|
45
|
-
goFullScreen() {
|
|
47
|
+
/* goFullScreen() {
|
|
46
48
|
if ("" === this.srcVideo) {
|
|
47
49
|
return;
|
|
48
50
|
}
|
|
@@ -58,7 +60,7 @@ export default defineComponent({
|
|
|
58
60
|
default:
|
|
59
61
|
console.log("The orientation API isn't supported in this browser :(");
|
|
60
62
|
}
|
|
61
|
-
},
|
|
63
|
+
}, */
|
|
62
64
|
},
|
|
63
65
|
});
|
|
64
66
|
</script>
|
|
@@ -10,10 +10,9 @@
|
|
|
10
10
|
</div>
|
|
11
11
|
</template>
|
|
12
12
|
<script lang="ts">
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
import { playerLive } from "../../mixins/player/playerLive";
|
|
13
|
+
import { usePlayerStore } from "@/stores/PlayerStore";
|
|
14
|
+
import { mapActions } from "pinia";
|
|
15
|
+
import { playerLogicProgress } from "../../mixins/player/playerLogicProgress";
|
|
17
16
|
import videojs, { VideoJsPlayer } from "video.js";
|
|
18
17
|
import qualitySelector from "videojs-hls-quality-selector";
|
|
19
18
|
import qualityLevels from "videojs-contrib-quality-levels";
|
|
@@ -30,7 +29,7 @@ export default defineComponent({
|
|
|
30
29
|
props: {
|
|
31
30
|
hlsUrl: { default: "", type: String },
|
|
32
31
|
},
|
|
33
|
-
mixins: [
|
|
32
|
+
mixins: [playerLogicProgress],
|
|
34
33
|
emits: ["changeValid"],
|
|
35
34
|
data() {
|
|
36
35
|
return {
|
|
@@ -38,6 +37,7 @@ export default defineComponent({
|
|
|
38
37
|
useVideoSrc: false as boolean,
|
|
39
38
|
player: undefined as VideoJsPlayer | undefined,
|
|
40
39
|
playing: false as boolean,
|
|
40
|
+
isPaused: false as boolean,
|
|
41
41
|
stalledTimout: undefined as ReturnType<typeof setTimeout> | undefined,
|
|
42
42
|
//playerLive mixins
|
|
43
43
|
downloadId: null as string | null,
|
|
@@ -47,7 +47,6 @@ export default defineComponent({
|
|
|
47
47
|
};
|
|
48
48
|
},
|
|
49
49
|
computed: {
|
|
50
|
-
/* ...mapState(usePlayerStore, ["playerLive"]), */
|
|
51
50
|
videoElement(): HTMLVideoElement {
|
|
52
51
|
return this.$refs.videoelement as HTMLVideoElement;
|
|
53
52
|
},
|
|
@@ -91,8 +90,13 @@ export default defineComponent({
|
|
|
91
90
|
},
|
|
92
91
|
|
|
93
92
|
methods: {
|
|
93
|
+
...mapActions(usePlayerStore, ["playerUpdateSeekTime"]),
|
|
94
94
|
definedStalledTimeout() {
|
|
95
|
+
this.isPaused = false;
|
|
95
96
|
this.stalledTimout = setTimeout(() => {
|
|
97
|
+
if(this.isPaused){
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
96
100
|
this.videoClean();
|
|
97
101
|
this.playLive();
|
|
98
102
|
}, 5000);
|
|
@@ -113,11 +117,6 @@ export default defineComponent({
|
|
|
113
117
|
this.playing = true;
|
|
114
118
|
},
|
|
115
119
|
);
|
|
116
|
-
this.player.on("timeupdate", () => {
|
|
117
|
-
clearTimeout(this.stalledTimout);
|
|
118
|
-
this.definedStalledTimeout();
|
|
119
|
-
this.onTimeUpdate();
|
|
120
|
-
});
|
|
121
120
|
this.player.on("error", (error) => {
|
|
122
121
|
this.stopLive();
|
|
123
122
|
if (error.description && error.description.includes("403")) {
|
|
@@ -126,6 +125,20 @@ export default defineComponent({
|
|
|
126
125
|
this.errorPlay = this.$t("Podcast play error");
|
|
127
126
|
}
|
|
128
127
|
});
|
|
128
|
+
this.player.on('seeking', () => {
|
|
129
|
+
this.playerUpdateSeekTime(this.player?.currentTime()??0);
|
|
130
|
+
});
|
|
131
|
+
this.player.on('pause', () => {
|
|
132
|
+
this.isPaused=true;
|
|
133
|
+
});
|
|
134
|
+
this.player.on("timeupdate", () => {
|
|
135
|
+
clearTimeout(this.stalledTimout);
|
|
136
|
+
this.definedStalledTimeout();
|
|
137
|
+
this.onTimeUpdateVideo();
|
|
138
|
+
});
|
|
139
|
+
this.player.on('seeking', () => {
|
|
140
|
+
this.playerUpdateSeekTime(this.player?.currentTime()??0);
|
|
141
|
+
});
|
|
129
142
|
},
|
|
130
143
|
async playLiveIos(): Promise<void> {
|
|
131
144
|
this.videoElement.onloadedmetadata = () => {
|
|
@@ -148,7 +161,13 @@ export default defineComponent({
|
|
|
148
161
|
this.videoElement.ontimeupdate = async () => {
|
|
149
162
|
clearTimeout(this.stalledTimout);
|
|
150
163
|
this.definedStalledTimeout();
|
|
151
|
-
this.
|
|
164
|
+
this.onTimeUpdateVideo();
|
|
165
|
+
};
|
|
166
|
+
this.videoElement.onpause = async () => {
|
|
167
|
+
this.isPaused=true;
|
|
168
|
+
};
|
|
169
|
+
this.videoElement.onseeking = async () => {
|
|
170
|
+
this.playerUpdateSeekTime(this.videoElement.currentTime);
|
|
152
171
|
};
|
|
153
172
|
this.videoElement.src = this.hlsUrl;
|
|
154
173
|
},
|
|
@@ -178,22 +197,12 @@ export default defineComponent({
|
|
|
178
197
|
this.errorPlay = "";
|
|
179
198
|
this.videoClean();
|
|
180
199
|
this.playing = false;
|
|
200
|
+
this.endListeningProgress();
|
|
181
201
|
},
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
onTimeUpdate(): void {
|
|
202
|
+
onTimeUpdateVideo(): void {
|
|
185
203
|
if (!this.downloadId) { return;}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
this.playerLive &&
|
|
189
|
-
0 === this.listenTime &&
|
|
190
|
-
0 !==currentTime
|
|
191
|
-
) {
|
|
192
|
-
this.notListenTime = currentTime;
|
|
193
|
-
this.listenTime = 1;
|
|
194
|
-
} else {
|
|
195
|
-
this.listenTime = currentTime - this.notListenTime;
|
|
196
|
-
}
|
|
204
|
+
const currentTime = this.player?.currentTime() ?? this.videoElement.currentTime;
|
|
205
|
+
this.onTimeUpdateProgress(currentTime);
|
|
197
206
|
},
|
|
198
207
|
},
|
|
199
208
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { state } from "../../../stores/ParamSdkStore";
|
|
2
|
-
import
|
|
2
|
+
import { playerLogicProgress} from "./playerLogicProgress";
|
|
3
3
|
import { usePlayerStore } from "@/stores/PlayerStore";
|
|
4
4
|
import { useAuthStore } from "@/stores/AuthStore";
|
|
5
5
|
import { mapState, mapActions } from "pinia";
|
|
@@ -8,6 +8,7 @@ let Hls:any = null;
|
|
|
8
8
|
/* eslint-enable */
|
|
9
9
|
import { defineComponent } from "vue";
|
|
10
10
|
export const playerLive = defineComponent({
|
|
11
|
+
mixins: [playerLogicProgress],
|
|
11
12
|
data() {
|
|
12
13
|
return {
|
|
13
14
|
listenTime: 0 as number,
|
|
@@ -20,7 +21,7 @@ export const playerLive = defineComponent({
|
|
|
20
21
|
};
|
|
21
22
|
},
|
|
22
23
|
computed: {
|
|
23
|
-
...mapState(usePlayerStore, ["playerLive", "playerRadio"]),
|
|
24
|
+
...mapState(usePlayerStore, ["playerLive", "playerRadio", "playerVideo"]),
|
|
24
25
|
...mapState(useAuthStore, ["authOrgaId"]),
|
|
25
26
|
},
|
|
26
27
|
methods: {
|
|
@@ -56,6 +57,7 @@ export const playerLive = defineComponent({
|
|
|
56
57
|
) {
|
|
57
58
|
this.audioElement.src = hlsStreamUrl;
|
|
58
59
|
await this.initLiveDownloadId();
|
|
60
|
+
this.hlsReady = true;
|
|
59
61
|
await this.audioElement.play();
|
|
60
62
|
this.onPlay();
|
|
61
63
|
} else {
|
|
@@ -67,32 +69,6 @@ export const playerLive = defineComponent({
|
|
|
67
69
|
}, 1000);
|
|
68
70
|
}
|
|
69
71
|
},
|
|
70
|
-
async initLiveDownloadId() {
|
|
71
|
-
if (!this.playerLive || this.downloadId) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
const downloadId = await octopusApi.putDataPublic<string | null>(
|
|
76
|
-
0,
|
|
77
|
-
"podcast/prepare/live/" + this.playerLive.podcastId,
|
|
78
|
-
undefined,
|
|
79
|
-
);
|
|
80
|
-
await octopusApi.fetchDataPublicWithParams<string | null>(
|
|
81
|
-
0,
|
|
82
|
-
"podcast/download/live/" + this.playerLive.podcastId + ".m3u8",
|
|
83
|
-
{
|
|
84
|
-
downloadId: null !== downloadId ? downloadId : undefined,
|
|
85
|
-
origin: "octopus",
|
|
86
|
-
distributorId: this.authOrgaId,
|
|
87
|
-
},
|
|
88
|
-
);
|
|
89
|
-
this.setDownloadId(downloadId);
|
|
90
|
-
} catch (error) {
|
|
91
|
-
this.downloadId = null;
|
|
92
|
-
console.log("ERROR downloadId");
|
|
93
|
-
}
|
|
94
|
-
this.hlsReady = true;
|
|
95
|
-
},
|
|
96
72
|
async initHls(hlsStreamUrl: string): Promise<void> {
|
|
97
73
|
return new Promise<void>(async (resolve, reject) => {
|
|
98
74
|
if (null === Hls) {
|
|
@@ -106,6 +82,7 @@ export const playerLive = defineComponent({
|
|
|
106
82
|
this.hls = new Hls();
|
|
107
83
|
this.hls.on(Hls.Events.MANIFEST_PARSED, async () => {
|
|
108
84
|
await this.initLiveDownloadId();
|
|
85
|
+
this.hlsReady = true;
|
|
109
86
|
this.hls.attachMedia(this.audioElement as HTMLAudioElement);
|
|
110
87
|
await (this.audioElement as HTMLAudioElement).play();
|
|
111
88
|
this.onPlay();
|
|
@@ -117,29 +94,6 @@ export const playerLive = defineComponent({
|
|
|
117
94
|
this.hls.loadSource(hlsStreamUrl);
|
|
118
95
|
});
|
|
119
96
|
},
|
|
120
|
-
setDownloadId(newValue: string | null): void {
|
|
121
|
-
this.endListeningProgress();
|
|
122
|
-
this.downloadId = newValue;
|
|
123
|
-
},
|
|
124
|
-
async endListeningProgress(): Promise<void> {
|
|
125
|
-
if (!this.downloadId) return;
|
|
126
|
-
try {
|
|
127
|
-
await octopusApi.putDataPublic(
|
|
128
|
-
0,
|
|
129
|
-
"podcast/listen/" +
|
|
130
|
-
this.downloadId +
|
|
131
|
-
"?seconds=" +
|
|
132
|
-
Math.round(this.listenTime),
|
|
133
|
-
undefined,
|
|
134
|
-
);
|
|
135
|
-
} catch {
|
|
136
|
-
//Do nothing
|
|
137
|
-
}
|
|
138
|
-
this.downloadId = null;
|
|
139
|
-
this.notListenTime = 0;
|
|
140
|
-
this.lastSend = 0;
|
|
141
|
-
this.listenTime = 0;
|
|
142
|
-
},
|
|
143
97
|
endingLive(): void {
|
|
144
98
|
const audio: HTMLElement | null = document.getElementById("audio-player");
|
|
145
99
|
if (audio && this.hls) {
|
|
@@ -100,33 +100,6 @@ export const playerLogic = defineComponent({
|
|
|
100
100
|
this.playRadio();
|
|
101
101
|
});
|
|
102
102
|
},
|
|
103
|
-
async listenTime(newVal): Promise<void> {
|
|
104
|
-
if (
|
|
105
|
-
(this.playerRadio && !this.playerPodcast && !this.playerLive) ||
|
|
106
|
-
!this.downloadId ||
|
|
107
|
-
newVal - this.lastSend < 10
|
|
108
|
-
) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
this.lastSend = newVal;
|
|
112
|
-
await octopusApi.putDataPublic(
|
|
113
|
-
0,
|
|
114
|
-
"podcast/listen/" + this.downloadId + "?seconds=" + Math.round(newVal),
|
|
115
|
-
undefined,
|
|
116
|
-
);
|
|
117
|
-
},
|
|
118
|
-
playerSeekTime() {
|
|
119
|
-
if (!this.playerSeekTime) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (this.playerPodcast || this.playerLive) {
|
|
123
|
-
this.notListenTime = this.playerSeekTime - this.listenTime;
|
|
124
|
-
}
|
|
125
|
-
const audioPlayer: HTMLAudioElement | null =
|
|
126
|
-
document.querySelector("#audio-player");
|
|
127
|
-
if (!audioPlayer) return;
|
|
128
|
-
audioPlayer.currentTime = this.playerSeekTime;
|
|
129
|
-
},
|
|
130
103
|
playerStatus() {
|
|
131
104
|
const audioPlayer: HTMLAudioElement | null =
|
|
132
105
|
document.querySelector("#audio-player");
|
|
@@ -155,10 +128,6 @@ export const playerLogic = defineComponent({
|
|
|
155
128
|
},
|
|
156
129
|
},
|
|
157
130
|
|
|
158
|
-
mounted() {
|
|
159
|
-
window.addEventListener("beforeunload", this.endListeningProgress);
|
|
160
|
-
},
|
|
161
|
-
|
|
162
131
|
methods: {
|
|
163
132
|
...mapActions(usePlayerStore, ["playerPlay", "playerUpdateElapsed"]),
|
|
164
133
|
getDomain(): string {
|
|
@@ -271,19 +240,7 @@ export const playerLogic = defineComponent({
|
|
|
271
240
|
}
|
|
272
241
|
const mediaTarget = event.currentTarget as HTMLMediaElement;
|
|
273
242
|
if (this.playerPodcast || this.playerLive) {
|
|
274
|
-
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
if (
|
|
278
|
-
this.playerLive &&
|
|
279
|
-
0 === this.listenTime &&
|
|
280
|
-
0 !== mediaTarget.currentTime
|
|
281
|
-
) {
|
|
282
|
-
this.notListenTime = mediaTarget.currentTime;
|
|
283
|
-
this.listenTime = 1;
|
|
284
|
-
} else {
|
|
285
|
-
this.listenTime = mediaTarget.currentTime - this.notListenTime;
|
|
286
|
-
}
|
|
243
|
+
this.onTimeUpdateProgress(mediaTarget.currentTime);
|
|
287
244
|
}
|
|
288
245
|
const streamDuration = this.streamDurationForSafari(mediaTarget);
|
|
289
246
|
if (!streamDuration) return;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import octopusApi from "@saooti/octopus-api";
|
|
2
|
+
import { defineComponent } from "vue";
|
|
3
|
+
import { useAuthStore } from "@/stores/AuthStore";
|
|
4
|
+
import { usePlayerStore } from "@/stores/PlayerStore";
|
|
5
|
+
import { mapState } from "pinia";
|
|
6
|
+
export const playerLogicProgress = defineComponent({
|
|
7
|
+
mixins: [],
|
|
8
|
+
data() {
|
|
9
|
+
return {
|
|
10
|
+
listenTime: 0 as number,
|
|
11
|
+
notListenTime: 0 as number,
|
|
12
|
+
lastSend: 0 as number,
|
|
13
|
+
downloadId: null as string | null,
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
computed: {
|
|
17
|
+
...mapState(useAuthStore, ["authOrgaId"]),
|
|
18
|
+
...mapState(usePlayerStore, [
|
|
19
|
+
"playerPodcast",
|
|
20
|
+
"playerLive",
|
|
21
|
+
"playerRadio",
|
|
22
|
+
"playerSeekTime",
|
|
23
|
+
"playerVideo"
|
|
24
|
+
]),
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
watch: {
|
|
28
|
+
async listenTime(newVal): Promise<void> {
|
|
29
|
+
if (
|
|
30
|
+
(this.playerRadio && !this.playerPodcast && !this.playerLive) ||
|
|
31
|
+
!this.downloadId ||
|
|
32
|
+
newVal - this.lastSend < 10
|
|
33
|
+
) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this.lastSend = newVal;
|
|
37
|
+
await octopusApi.putDataPublic(
|
|
38
|
+
0,
|
|
39
|
+
"podcast/listen/" + this.downloadId + "?seconds=" + Math.round(newVal),
|
|
40
|
+
undefined,
|
|
41
|
+
);
|
|
42
|
+
},
|
|
43
|
+
playerSeekTime() {
|
|
44
|
+
if (!this.playerSeekTime) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (this.playerPodcast || this.playerLive) {
|
|
48
|
+
this.notListenTime = this.playerSeekTime - this.listenTime;
|
|
49
|
+
}
|
|
50
|
+
if(this.playerVideo){
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const audioPlayer: HTMLAudioElement | null = document.querySelector("#audio-player");
|
|
54
|
+
if (!audioPlayer) return;
|
|
55
|
+
audioPlayer.currentTime = this.playerSeekTime;
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
mounted() {
|
|
60
|
+
window.addEventListener("beforeunload", this.endListeningProgress);
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
methods: {
|
|
64
|
+
async initLiveDownloadId() {
|
|
65
|
+
if (!this.playerLive || this.downloadId) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const mediaType = this.playerVideo ? "VIDEO":"AUDIO";
|
|
70
|
+
const downloadId = await octopusApi.putDataPublic<string | null>(
|
|
71
|
+
0,
|
|
72
|
+
"podcast/prepare/live/" + this.playerLive.podcastId+"?mediaType="+mediaType,
|
|
73
|
+
undefined,
|
|
74
|
+
);
|
|
75
|
+
await octopusApi.fetchDataPublicWithParams<string | null>(
|
|
76
|
+
0,
|
|
77
|
+
"podcast/download/live/" + this.playerLive.podcastId + ".m3u8",
|
|
78
|
+
{
|
|
79
|
+
downloadId: null !== downloadId ? downloadId : undefined,
|
|
80
|
+
origin: "octopus",
|
|
81
|
+
distributorId: this.authOrgaId,
|
|
82
|
+
},
|
|
83
|
+
);
|
|
84
|
+
this.setDownloadId(downloadId);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
this.downloadId = null;
|
|
87
|
+
console.log("ERROR downloadId");
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
onTimeUpdateProgress(currentTime: number): void {
|
|
91
|
+
if (!this.downloadId) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (
|
|
95
|
+
this.playerLive &&
|
|
96
|
+
0 === this.listenTime &&
|
|
97
|
+
0 !== currentTime
|
|
98
|
+
) {
|
|
99
|
+
this.notListenTime = currentTime;
|
|
100
|
+
this.listenTime = 1;
|
|
101
|
+
} else {
|
|
102
|
+
const newListenTime = currentTime - this.notListenTime;
|
|
103
|
+
const diffTime = newListenTime - this.listenTime;
|
|
104
|
+
if(diffTime > 0 && diffTime<1){
|
|
105
|
+
this.listenTime = newListenTime;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
setDownloadId(newValue: string | null): void {
|
|
110
|
+
this.endListeningProgress();
|
|
111
|
+
this.downloadId = newValue;
|
|
112
|
+
},
|
|
113
|
+
async endListeningProgress(): Promise<void> {
|
|
114
|
+
if (!this.downloadId) return;
|
|
115
|
+
try {
|
|
116
|
+
await octopusApi.putDataPublic(
|
|
117
|
+
0,
|
|
118
|
+
"podcast/listen/" +
|
|
119
|
+
this.downloadId +
|
|
120
|
+
"?seconds=" +
|
|
121
|
+
Math.round(this.listenTime),
|
|
122
|
+
undefined,
|
|
123
|
+
);
|
|
124
|
+
} catch {
|
|
125
|
+
//Do nothing
|
|
126
|
+
}
|
|
127
|
+
this.downloadId = null;
|
|
128
|
+
this.notListenTime = 0;
|
|
129
|
+
this.lastSend = 0;
|
|
130
|
+
this.listenTime = 0;
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
},
|
|
134
|
+
});
|
|
@@ -3,7 +3,7 @@ import { Category } from "./class/general/category";
|
|
|
3
3
|
|
|
4
4
|
const state: ParamStore = {
|
|
5
5
|
generalParameters: {
|
|
6
|
-
organisationId: "ecbd98d9-79bd-4312-ad5e-fc7c1c4a191c",
|
|
6
|
+
organisationId: /* "7e67406d-c1f5-4f98-91ca-dd45583aa1a6" */"ecbd98d9-79bd-4312-ad5e-fc7c1c4a191c",
|
|
7
7
|
authenticated: true,
|
|
8
8
|
isAdmin: true,
|
|
9
9
|
isRoleLive: true,
|