@saooti/octopus-sdk 38.1.2 → 38.1.3
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
CHANGED
|
@@ -2,12 +2,33 @@ import octopusApi from "@saooti/octopus-api";
|
|
|
2
2
|
import { defineComponent } from "vue";
|
|
3
3
|
import { usePlayerStore } from "@/stores/PlayerStore";
|
|
4
4
|
import { mapState, mapActions } from "pinia";
|
|
5
|
+
import { AdserverOtherEmission } from "@/stores/class/adserver/adserverOtherEmission";
|
|
5
6
|
export const playerTranscript = defineComponent({
|
|
6
7
|
computed: {
|
|
7
|
-
...mapState(usePlayerStore, ["playerTranscript", "playerPodcast"]),
|
|
8
|
+
...mapState(usePlayerStore, ["playerTranscript", "playerPodcast", 'playerDelayStitching']),
|
|
8
9
|
},
|
|
9
10
|
methods: {
|
|
10
|
-
...mapActions(usePlayerStore, ["playerUpdateTranscript"]),
|
|
11
|
+
...mapActions(usePlayerStore, ["playerUpdateTranscript", "playerUpdateDelayStitching"]),
|
|
12
|
+
async checkDelaytWithStitching(){
|
|
13
|
+
this.playerUpdateDelayStitching(0);
|
|
14
|
+
const audioPlayer = document.querySelector("#audio-player") as HTMLAudioElement;
|
|
15
|
+
if (!this.playerTranscript || !audioPlayer || !this.playerPodcast ||
|
|
16
|
+
audioPlayer.duration <= this.playerPodcast.duration / 1000 + 5)
|
|
17
|
+
{
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
let adserverConfig = await octopusApi.fetchDataPublic<AdserverOtherEmission>(0,`ad/test/podcast/${this.playerPodcast.podcastId}`);
|
|
21
|
+
const doubletsLength = adserverConfig.config.doublets.length;
|
|
22
|
+
if(1=== doubletsLength && "pre" === adserverConfig.config.doublets[0].timing.insertion){
|
|
23
|
+
this.playerUpdateDelayStitching( audioPlayer.duration - (this.playerPodcast.duration / 1000));
|
|
24
|
+
}else if(0===doubletsLength || 1=== doubletsLength && "post" === adserverConfig.config.doublets[0].timing.insertion){
|
|
25
|
+
return;
|
|
26
|
+
}else{
|
|
27
|
+
// todo remove chaptering
|
|
28
|
+
this.playerUpdateChaptering();
|
|
29
|
+
this.playerUpdateTranscript();
|
|
30
|
+
}
|
|
31
|
+
},
|
|
11
32
|
async getTranscription(): Promise<void> {
|
|
12
33
|
if (!this.playerPodcast) {
|
|
13
34
|
this.playerUpdateTranscript();
|
|
@@ -20,10 +41,13 @@ export const playerTranscript = defineComponent({
|
|
|
20
41
|
const arrayTranscript = this.parseSrt(result);
|
|
21
42
|
const actualText =
|
|
22
43
|
arrayTranscript?.[0]?.startTime === 0 ? arrayTranscript[0].text : "";
|
|
44
|
+
if(!arrayTranscript){
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
23
47
|
this.playerUpdateTranscript({
|
|
24
48
|
actual: 0,
|
|
25
49
|
actualText: actualText,
|
|
26
|
-
value: arrayTranscript
|
|
50
|
+
value: arrayTranscript
|
|
27
51
|
});
|
|
28
52
|
},
|
|
29
53
|
parseSrt(transcript: string) {
|
|
@@ -52,23 +76,30 @@ export const playerTranscript = defineComponent({
|
|
|
52
76
|
return +a[0] * 60 * 60 + +a[1] * 60 + +parseFloat(a[2]);
|
|
53
77
|
},
|
|
54
78
|
onTimeUpdateTranscript(currentTime: number) {
|
|
79
|
+
if(!this.playerTranscript || !this.playerTranscript.value.length){
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const startTime = (this.playerTranscript.value[this.playerTranscript.actual]?.startTime ?? 0) + this.playerDelayStitching;
|
|
83
|
+
if (startTime <= currentTime) {
|
|
84
|
+
this.playerTranscript.actualText = this.playerTranscript.value[this.playerTranscript?.actual]?.text ??"";
|
|
85
|
+
}
|
|
55
86
|
if (
|
|
56
|
-
this.playerTranscript
|
|
57
|
-
|
|
58
|
-
Infinity) < currentTime
|
|
87
|
+
(this.playerTranscript.value[this.playerTranscript.actual]?.endTime ??
|
|
88
|
+
Infinity) + this.playerDelayStitching < currentTime
|
|
59
89
|
) {
|
|
60
90
|
this.playerTranscript.actual += 1;
|
|
61
91
|
this.playerTranscript.actualText =
|
|
62
|
-
this.playerTranscript?.value[this.playerTranscript
|
|
92
|
+
this.playerTranscript?.value[this.playerTranscript.actual]?.text ??
|
|
63
93
|
"";
|
|
64
94
|
}
|
|
65
95
|
},
|
|
96
|
+
|
|
66
97
|
onSeekedTranscript(currentTime: number) {
|
|
67
98
|
if (this.playerTranscript) {
|
|
68
99
|
let newActual = 0;
|
|
69
100
|
while (
|
|
70
101
|
currentTime >
|
|
71
|
-
(this.playerTranscript.value[newActual]?.endTime ?? Infinity)
|
|
102
|
+
(this.playerTranscript.value[newActual]?.endTime ?? Infinity) + this.playerDelayStitching
|
|
72
103
|
) {
|
|
73
104
|
newActual += 1;
|
|
74
105
|
}
|
|
@@ -25,6 +25,7 @@ interface PlayerState {
|
|
|
25
25
|
playerLargeVersion: boolean;
|
|
26
26
|
playerVideo: boolean;
|
|
27
27
|
playerChaptering?: Chaptering;
|
|
28
|
+
playerDelayStitching: number;
|
|
28
29
|
}
|
|
29
30
|
export const usePlayerStore = defineStore("PlayerStore", {
|
|
30
31
|
state: (): PlayerState => ({
|
|
@@ -40,6 +41,7 @@ export const usePlayerStore = defineStore("PlayerStore", {
|
|
|
40
41
|
playerLargeVersion: false,
|
|
41
42
|
playerVideo: false,
|
|
42
43
|
playerChaptering: undefined,
|
|
44
|
+
playerDelayStitching:0,
|
|
43
45
|
}),
|
|
44
46
|
getters: {
|
|
45
47
|
playerChapteringPercent(): ChapteringPercent|undefined{
|
|
@@ -48,10 +50,11 @@ export const usePlayerStore = defineStore("PlayerStore", {
|
|
|
48
50
|
}
|
|
49
51
|
let chapteringPercent: ChapteringPercent = [];
|
|
50
52
|
for (let i = 0, len = this.playerChaptering.chapters.length; i < len; i++) {
|
|
53
|
+
const startTimeWithDelay = this.playerChaptering.chapters[i].startTime + Math.floor(this.playerDelayStitching);
|
|
51
54
|
chapteringPercent.push({
|
|
52
|
-
startTime :
|
|
53
|
-
startDisplay: DurationHelper.formatDuration(
|
|
54
|
-
startPercent: (
|
|
55
|
+
startTime : startTimeWithDelay,
|
|
56
|
+
startDisplay: DurationHelper.formatDuration(startTimeWithDelay, ':', false),
|
|
57
|
+
startPercent: (startTimeWithDelay * 100 ) / (Math.round(this.playerTotal)),
|
|
55
58
|
endPercent:100,
|
|
56
59
|
title: this.playerChaptering.chapters[i].title
|
|
57
60
|
});
|
|
@@ -202,8 +205,14 @@ export const usePlayerStore = defineStore("PlayerStore", {
|
|
|
202
205
|
playerUpdateTranscript(transcript?: Transcript) {
|
|
203
206
|
this.playerTranscript = transcript;
|
|
204
207
|
},
|
|
208
|
+
playerUpdateDelayStitching(delay: number){
|
|
209
|
+
this.playerDelayStitching = delay;
|
|
210
|
+
},
|
|
205
211
|
playerUpdateLargeVersion(largeVersion: boolean) {
|
|
206
212
|
this.playerLargeVersion = largeVersion;
|
|
207
213
|
},
|
|
214
|
+
playerUpdateChaptering(chaptering?: Chaptering){
|
|
215
|
+
this.playerChaptering = chaptering;
|
|
216
|
+
}
|
|
208
217
|
},
|
|
209
218
|
});
|