@saooti/octopus-sdk 37.0.28 → 37.0.30
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/misc/modal/ClassicModal.vue +33 -15
- 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/PlayerVideoHls.vue +45 -7
- package/src/components/mixins/player/playerLive.ts +5 -51
- package/src/components/mixins/player/playerLogic.ts +5 -44
- package/src/components/mixins/player/playerLogicProgress.ts +134 -0
- package/src/stores/ParamSdkStore.ts +1 -1
package/package.json
CHANGED
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div :id="idModal" class="octopus-modal">
|
|
3
|
-
<div class="octopus-modal-backdrop"
|
|
4
|
-
<div class="octopus-modal-dialog">
|
|
2
|
+
<div :id="idModal" class="octopus-modal" :class="onlyHeader? 'octopus-only-header-modal':''">
|
|
3
|
+
<div class="octopus-modal-backdrop"/>
|
|
4
|
+
<div class="octopus-modal-dialog" >
|
|
5
5
|
<div class="octopus-modal-content">
|
|
6
6
|
<div class="octopus-modal-header">
|
|
7
7
|
<h5 cclass="octopus-modal-title">
|
|
8
8
|
{{ titleModal }}
|
|
9
9
|
</h5>
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
<div class="d-flex align-items-center">
|
|
11
|
+
<button
|
|
12
|
+
v-if="canBeReduced"
|
|
13
|
+
class="btn-transparent text-light"
|
|
14
|
+
:class="onlyHeader? 'saooti-down':'saooti-up'"
|
|
15
|
+
:title="onlyHeader? $t('Enlarge'):$t('Reduce')"
|
|
16
|
+
@click="onlyHeader = !onlyHeader"
|
|
17
|
+
/>
|
|
18
|
+
<button
|
|
19
|
+
v-if="closable"
|
|
20
|
+
:ref="closable ? 'focusElement' : ''"
|
|
21
|
+
type="button"
|
|
22
|
+
class="btn-transparent text-light saooti-remove"
|
|
23
|
+
:title="$t('Close')"
|
|
24
|
+
@click="$emit('close')"
|
|
25
|
+
/>
|
|
26
|
+
</div>
|
|
18
27
|
</div>
|
|
19
|
-
<div class="octopus-modal-body">
|
|
28
|
+
<div v-show="!onlyHeader" class="octopus-modal-body">
|
|
20
29
|
<slot name="body" />
|
|
21
30
|
</div>
|
|
22
|
-
<div class="octopus-modal-footer">
|
|
31
|
+
<div v-show="!onlyHeader" class="octopus-modal-footer">
|
|
23
32
|
<slot name="footer" />
|
|
24
33
|
</div>
|
|
25
34
|
</div>
|
|
@@ -35,8 +44,14 @@ export default defineComponent({
|
|
|
35
44
|
idModal: { default: undefined, type: String },
|
|
36
45
|
titleModal: { default: undefined, type: String },
|
|
37
46
|
closable: { default: true, type: Boolean },
|
|
47
|
+
canBeReduced: { default: false, type: Boolean },
|
|
38
48
|
},
|
|
39
49
|
emits: ["close"],
|
|
50
|
+
data() {
|
|
51
|
+
return {
|
|
52
|
+
onlyHeader: false as boolean,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
40
55
|
mounted() {
|
|
41
56
|
(this.$refs.focusElement as HTMLElement)?.focus();
|
|
42
57
|
},
|
|
@@ -67,6 +82,9 @@ export default defineComponent({
|
|
|
67
82
|
height: 100vh;
|
|
68
83
|
background-color: black;
|
|
69
84
|
}
|
|
85
|
+
.octopus-modal.octopus-only-header-modal .octopus-modal-backdrop {
|
|
86
|
+
opacity: 0.1;
|
|
87
|
+
}
|
|
70
88
|
|
|
71
89
|
.octopus-modal-dialog {
|
|
72
90
|
position: relative;
|
|
@@ -103,8 +121,8 @@ export default defineComponent({
|
|
|
103
121
|
padding: 1rem;
|
|
104
122
|
}
|
|
105
123
|
|
|
106
|
-
.octopus-modal-dialog,
|
|
107
|
-
.octopus-modal-content {
|
|
124
|
+
.octopus-modal:not(.octopus-only-header-modal) .octopus-modal-dialog,
|
|
125
|
+
.octopus-modal:not(.octopus-only-header-modal) .octopus-modal-content {
|
|
108
126
|
min-height: 300px;
|
|
109
127
|
}
|
|
110
128
|
.octopus-modal-content {
|
|
@@ -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
|
},
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
</div>
|
|
11
11
|
</template>
|
|
12
12
|
<script lang="ts">
|
|
13
|
+
import { usePlayerStore } from "@/stores/PlayerStore";
|
|
14
|
+
import { mapActions } from "pinia";
|
|
15
|
+
import { playerLogicProgress } from "../../mixins/player/playerLogicProgress";
|
|
13
16
|
import videojs, { VideoJsPlayer } from "video.js";
|
|
14
17
|
import qualitySelector from "videojs-hls-quality-selector";
|
|
15
18
|
import qualityLevels from "videojs-contrib-quality-levels";
|
|
@@ -26,7 +29,7 @@ export default defineComponent({
|
|
|
26
29
|
props: {
|
|
27
30
|
hlsUrl: { default: "", type: String },
|
|
28
31
|
},
|
|
29
|
-
|
|
32
|
+
mixins: [playerLogicProgress],
|
|
30
33
|
emits: ["changeValid"],
|
|
31
34
|
data() {
|
|
32
35
|
return {
|
|
@@ -34,7 +37,13 @@ export default defineComponent({
|
|
|
34
37
|
useVideoSrc: false as boolean,
|
|
35
38
|
player: undefined as VideoJsPlayer | undefined,
|
|
36
39
|
playing: false as boolean,
|
|
40
|
+
isPaused: false as boolean,
|
|
37
41
|
stalledTimout: undefined as ReturnType<typeof setTimeout> | undefined,
|
|
42
|
+
//playerLive mixins
|
|
43
|
+
downloadId: null as string | null,
|
|
44
|
+
listenTime: 0 as number,
|
|
45
|
+
notListenTime: 0 as number,
|
|
46
|
+
lastSend: 0 as number,
|
|
38
47
|
};
|
|
39
48
|
},
|
|
40
49
|
computed: {
|
|
@@ -68,10 +77,10 @@ export default defineComponent({
|
|
|
68
77
|
},
|
|
69
78
|
},
|
|
70
79
|
mounted() {
|
|
71
|
-
this.playLive();
|
|
72
80
|
this.useVideoSrc =
|
|
73
81
|
"" !== this.videoElement.canPlayType("application/vnd.apple.mpegurl") &&
|
|
74
82
|
!navigator.userAgent.includes("Android");
|
|
83
|
+
this.playLive();
|
|
75
84
|
},
|
|
76
85
|
|
|
77
86
|
beforeUnmount() {
|
|
@@ -81,8 +90,13 @@ export default defineComponent({
|
|
|
81
90
|
},
|
|
82
91
|
|
|
83
92
|
methods: {
|
|
93
|
+
...mapActions(usePlayerStore, ["playerUpdateSeekTime"]),
|
|
84
94
|
definedStalledTimeout() {
|
|
95
|
+
this.isPaused = false;
|
|
85
96
|
this.stalledTimout = setTimeout(() => {
|
|
97
|
+
if(this.isPaused){
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
86
100
|
this.videoClean();
|
|
87
101
|
this.playLive();
|
|
88
102
|
}, 5000);
|
|
@@ -90,6 +104,7 @@ export default defineComponent({
|
|
|
90
104
|
async playLive(): Promise<void> {
|
|
91
105
|
clearTimeout(this.stalledTimout);
|
|
92
106
|
this.definedStalledTimeout();
|
|
107
|
+
await this.initLiveDownloadId();
|
|
93
108
|
if (this.useVideoSrc) {
|
|
94
109
|
this.playLiveIos();
|
|
95
110
|
return;
|
|
@@ -102,10 +117,6 @@ export default defineComponent({
|
|
|
102
117
|
this.playing = true;
|
|
103
118
|
},
|
|
104
119
|
);
|
|
105
|
-
this.player.on("timeupdate", () => {
|
|
106
|
-
clearTimeout(this.stalledTimout);
|
|
107
|
-
this.definedStalledTimeout();
|
|
108
|
-
});
|
|
109
120
|
this.player.on("error", (error) => {
|
|
110
121
|
this.stopLive();
|
|
111
122
|
if (error.description && error.description.includes("403")) {
|
|
@@ -114,6 +125,20 @@ export default defineComponent({
|
|
|
114
125
|
this.errorPlay = this.$t("Podcast play error");
|
|
115
126
|
}
|
|
116
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
|
+
});
|
|
117
142
|
},
|
|
118
143
|
async playLiveIos(): Promise<void> {
|
|
119
144
|
this.videoElement.onloadedmetadata = () => {
|
|
@@ -136,6 +161,13 @@ export default defineComponent({
|
|
|
136
161
|
this.videoElement.ontimeupdate = async () => {
|
|
137
162
|
clearTimeout(this.stalledTimout);
|
|
138
163
|
this.definedStalledTimeout();
|
|
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);
|
|
139
171
|
};
|
|
140
172
|
this.videoElement.src = this.hlsUrl;
|
|
141
173
|
},
|
|
@@ -165,8 +197,14 @@ export default defineComponent({
|
|
|
165
197
|
this.errorPlay = "";
|
|
166
198
|
this.videoClean();
|
|
167
199
|
this.playing = false;
|
|
200
|
+
this.endListeningProgress();
|
|
201
|
+
},
|
|
202
|
+
onTimeUpdateVideo(): void {
|
|
203
|
+
if (!this.downloadId) { return;}
|
|
204
|
+
const currentTime = this.player?.currentTime() ?? this.videoElement.currentTime;
|
|
205
|
+
this.onTimeUpdateProgress(currentTime);
|
|
206
|
+
},
|
|
168
207
|
},
|
|
169
|
-
},
|
|
170
208
|
});
|
|
171
209
|
</script>
|
|
172
210
|
|
|
@@ -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) {
|
|
@@ -40,6 +40,7 @@ export const playerLogic = defineComponent({
|
|
|
40
40
|
"playerVolume",
|
|
41
41
|
"playerStatus",
|
|
42
42
|
"playerSeekTime",
|
|
43
|
+
"playerVideo"
|
|
43
44
|
]),
|
|
44
45
|
|
|
45
46
|
audioUrl(): string {
|
|
@@ -82,6 +83,9 @@ export const playerLogic = defineComponent({
|
|
|
82
83
|
playerLive: {
|
|
83
84
|
deep: true,
|
|
84
85
|
handler() {
|
|
86
|
+
if(this.playerVideo){
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
85
89
|
this.$nextTick(async () => {
|
|
86
90
|
this.hlsReady = false;
|
|
87
91
|
this.reInitPlayer();
|
|
@@ -96,33 +100,6 @@ export const playerLogic = defineComponent({
|
|
|
96
100
|
this.playRadio();
|
|
97
101
|
});
|
|
98
102
|
},
|
|
99
|
-
async listenTime(newVal): Promise<void> {
|
|
100
|
-
if (
|
|
101
|
-
(this.playerRadio && !this.playerPodcast && !this.playerLive) ||
|
|
102
|
-
!this.downloadId ||
|
|
103
|
-
newVal - this.lastSend < 10
|
|
104
|
-
) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
this.lastSend = newVal;
|
|
108
|
-
await octopusApi.putDataPublic(
|
|
109
|
-
0,
|
|
110
|
-
"podcast/listen/" + this.downloadId + "?seconds=" + Math.round(newVal),
|
|
111
|
-
undefined,
|
|
112
|
-
);
|
|
113
|
-
},
|
|
114
|
-
playerSeekTime() {
|
|
115
|
-
if (!this.playerSeekTime) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (this.playerPodcast || this.playerLive) {
|
|
119
|
-
this.notListenTime = this.playerSeekTime - this.listenTime;
|
|
120
|
-
}
|
|
121
|
-
const audioPlayer: HTMLAudioElement | null =
|
|
122
|
-
document.querySelector("#audio-player");
|
|
123
|
-
if (!audioPlayer) return;
|
|
124
|
-
audioPlayer.currentTime = this.playerSeekTime;
|
|
125
|
-
},
|
|
126
103
|
playerStatus() {
|
|
127
104
|
const audioPlayer: HTMLAudioElement | null =
|
|
128
105
|
document.querySelector("#audio-player");
|
|
@@ -151,10 +128,6 @@ export const playerLogic = defineComponent({
|
|
|
151
128
|
},
|
|
152
129
|
},
|
|
153
130
|
|
|
154
|
-
mounted() {
|
|
155
|
-
window.addEventListener("beforeunload", this.endListeningProgress);
|
|
156
|
-
},
|
|
157
|
-
|
|
158
131
|
methods: {
|
|
159
132
|
...mapActions(usePlayerStore, ["playerPlay", "playerUpdateElapsed"]),
|
|
160
133
|
getDomain(): string {
|
|
@@ -267,19 +240,7 @@ export const playerLogic = defineComponent({
|
|
|
267
240
|
}
|
|
268
241
|
const mediaTarget = event.currentTarget as HTMLMediaElement;
|
|
269
242
|
if (this.playerPodcast || this.playerLive) {
|
|
270
|
-
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
if (
|
|
274
|
-
this.playerLive &&
|
|
275
|
-
0 === this.listenTime &&
|
|
276
|
-
0 !== mediaTarget.currentTime
|
|
277
|
-
) {
|
|
278
|
-
this.notListenTime = mediaTarget.currentTime;
|
|
279
|
-
this.listenTime = 1;
|
|
280
|
-
} else {
|
|
281
|
-
this.listenTime = mediaTarget.currentTime - this.notListenTime;
|
|
282
|
-
}
|
|
243
|
+
this.onTimeUpdateProgress(mediaTarget.currentTime);
|
|
283
244
|
}
|
|
284
245
|
const streamDuration = this.streamDurationForSafari(mediaTarget);
|
|
285
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,
|