@saooti/octopus-sdk 31.0.19 → 31.0.22
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/README.md +3 -0
- package/index.ts +1 -1
- package/package.json +2 -2
- package/src/assets/general.scss +1 -1
- package/src/components/misc/Footer.vue +2 -5
- package/src/components/misc/player/Player.vue +146 -0
- package/src/components/misc/player/PlayerCompact.vue +149 -0
- package/src/components/misc/player/PlayerLarge.vue +161 -0
- package/src/components/misc/player/PlayerProgressBar.vue +112 -0
- package/src/components/misc/{PlayerClockAndTimeline.vue → player/PlayerTimeline.vue} +3 -24
- package/src/components/mixins/player/playerComment.ts +97 -0
- package/src/components/mixins/player/playerDisplay.ts +113 -0
- package/src/components/mixins/player/playerLive.ts +117 -0
- package/src/components/mixins/player/playerLogic.ts +228 -0
- package/src/locale/de.ts +2 -0
- package/src/locale/en.ts +2 -0
- package/src/locale/es.ts +2 -0
- package/src/locale/fr.ts +2 -0
- package/src/locale/it.ts +2 -0
- package/src/locale/sl.ts +2 -0
- package/src/store/paramStore.ts +1 -5
- package/src/components/misc/Player.vue +0 -525
- package/src/components/misc/PlayerButtons.vue +0 -143
- package/src/components/misc/PlayerProgressBar.vue +0 -176
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
|
|
2
|
+
import { mapState } from 'vuex';
|
|
3
|
+
import { state } from '../../../store/paramStore';
|
|
4
|
+
import octopusApi from '@saooti/octopus-api';
|
|
5
|
+
import { CommentPodcast } from '@/store/class/general/comment';
|
|
6
|
+
import { StoreState } from '@/store/typeAppStore';
|
|
7
|
+
import { defineComponent } from 'vue';
|
|
8
|
+
import { FetchParam } from '@/store/class/general/fetchParam';
|
|
9
|
+
export const playerComment = defineComponent({
|
|
10
|
+
data() {
|
|
11
|
+
return {
|
|
12
|
+
comments: [] as Array<CommentPodcast>,
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
computed: {
|
|
16
|
+
...mapState({
|
|
17
|
+
commentsLoaded(state: StoreState){ return state.comments.loadedComments},
|
|
18
|
+
live(state: StoreState) { return state.player.live},
|
|
19
|
+
podcast(state: StoreState) { return state.player.podcast}
|
|
20
|
+
}),
|
|
21
|
+
organisationId(): string|undefined {
|
|
22
|
+
return state.generalParameters.organisationId;
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
watch: {
|
|
27
|
+
commentsLoaded(): void {
|
|
28
|
+
this.initComments(true);
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
methods: {
|
|
32
|
+
editRight(organisation: string): boolean {
|
|
33
|
+
if (
|
|
34
|
+
(state.generalParameters.isCommments &&
|
|
35
|
+
this.organisationId === organisation) ||
|
|
36
|
+
state.generalParameters.isAdmin
|
|
37
|
+
)
|
|
38
|
+
return true;
|
|
39
|
+
return false;
|
|
40
|
+
},
|
|
41
|
+
async initComments(refresh = false): Promise<void> {
|
|
42
|
+
let podcastId, organisation;
|
|
43
|
+
if (this.podcast) {
|
|
44
|
+
podcastId = this.podcast.podcastId;
|
|
45
|
+
organisation = this.podcast.organisation.id;
|
|
46
|
+
} else if (this.live) {
|
|
47
|
+
podcastId = this.live.livePodcastId;
|
|
48
|
+
organisation = this.live.organisation.id;
|
|
49
|
+
}
|
|
50
|
+
if (
|
|
51
|
+
refresh &&
|
|
52
|
+
podcastId &&
|
|
53
|
+
this.$store.state.comments.actualPodcastId !== podcastId
|
|
54
|
+
) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
let first = 0;
|
|
58
|
+
let count = 0;
|
|
59
|
+
const size = 50;
|
|
60
|
+
if (
|
|
61
|
+
podcastId &&
|
|
62
|
+
this.$store.state.comments.actualPodcastId === podcastId
|
|
63
|
+
) {
|
|
64
|
+
this.comments = this.commentsLoaded;
|
|
65
|
+
if (
|
|
66
|
+
this.commentsLoaded &&
|
|
67
|
+
this.commentsLoaded.length < this.$store.state.comments.totalCount
|
|
68
|
+
) {
|
|
69
|
+
first = this.commentsLoaded.length;
|
|
70
|
+
count = this.$store.state.comments.totalCount;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (
|
|
74
|
+
(!podcastId ||
|
|
75
|
+
this.$store.state.comments.actualPodcastId === podcastId) &&
|
|
76
|
+
0 === first
|
|
77
|
+
)
|
|
78
|
+
return;
|
|
79
|
+
while (0 === first || this.comments.length < count) {
|
|
80
|
+
const param: FetchParam = {
|
|
81
|
+
first: first,
|
|
82
|
+
size: size,
|
|
83
|
+
podcastId: podcastId,
|
|
84
|
+
};
|
|
85
|
+
if (!this.editRight(organisation? organisation : '')) {
|
|
86
|
+
param.status = ['Valid'];
|
|
87
|
+
}
|
|
88
|
+
const data = await octopusApi.fetchRootComments(param);
|
|
89
|
+
first += size;
|
|
90
|
+
count = data.totalElements;
|
|
91
|
+
this.comments = this.comments.concat(data.content).filter((c: CommentPodcast) => {
|
|
92
|
+
return null !== c;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
})
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Podcast } from '@/store/class/general/podcast';
|
|
2
|
+
import DurationHelper from '../../../helper/duration';
|
|
3
|
+
import { state } from '../../../store/paramStore';
|
|
4
|
+
import { defineComponent } from 'vue';
|
|
5
|
+
import { RouteLocationRaw } from 'vue-router';
|
|
6
|
+
export const playerDisplay = defineComponent({
|
|
7
|
+
props: {
|
|
8
|
+
hlsReady: { default: false , type: Boolean},
|
|
9
|
+
},
|
|
10
|
+
computed:{
|
|
11
|
+
playedTime(): string{
|
|
12
|
+
if (this.$store.state.player.elapsed && this.$store.state.player.elapsed > 0 && this.$store.state.player.total && this.$store.state.player.total > 0) {
|
|
13
|
+
return DurationHelper.formatDuration(
|
|
14
|
+
Math.round(this.$store.state.player.elapsed * this.$store.state.player.total)
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
return '--:--';
|
|
18
|
+
},
|
|
19
|
+
totalTime(): string {
|
|
20
|
+
if (this.$store.state.player.elapsed && this.$store.state.player.elapsed > 0 && this.$store.state.player.total && this.$store.state.player.total > 0)
|
|
21
|
+
return DurationHelper.formatDuration(Math.round(this.$store.state.player.total));
|
|
22
|
+
return '--:--';
|
|
23
|
+
},
|
|
24
|
+
isPlaying(): boolean {
|
|
25
|
+
return 'PLAYING' === this.$store.state.player.status;
|
|
26
|
+
},
|
|
27
|
+
isPaused(): boolean {
|
|
28
|
+
return 'PAUSED' === this.$store.state.player.status;
|
|
29
|
+
},
|
|
30
|
+
podcast(): undefined|Podcast{
|
|
31
|
+
return this.$store.state.player.podcast;
|
|
32
|
+
},
|
|
33
|
+
isImage(): boolean {
|
|
34
|
+
return (state.player.image as boolean);
|
|
35
|
+
},
|
|
36
|
+
podcastImage(): string{
|
|
37
|
+
if (this.$store.state.player.podcast) return this.$store.state.player.podcast.imageUrl;
|
|
38
|
+
return '';
|
|
39
|
+
},
|
|
40
|
+
podcastShareUrl(): RouteLocationRaw|string {
|
|
41
|
+
if (this.podcast) {
|
|
42
|
+
return {
|
|
43
|
+
name: 'podcast',
|
|
44
|
+
params: { podcastId: this.podcast.podcastId.toString() },
|
|
45
|
+
query: { productor: this.$store.state.filter.organisationId },
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return '';
|
|
49
|
+
},
|
|
50
|
+
isEmissionName(): boolean {
|
|
51
|
+
return (state.player.emissionName as boolean);
|
|
52
|
+
},
|
|
53
|
+
podcastTitle(): string {
|
|
54
|
+
if (this.$store.state.player.podcast) {
|
|
55
|
+
if (this.isEmissionName)
|
|
56
|
+
return this.emissionName + ' - ' + this.$store.state.player.podcast.title;
|
|
57
|
+
return this.$store.state.player.podcast.title;
|
|
58
|
+
}
|
|
59
|
+
if (this.$store.state.player.media) return this.$store.state.player.media.title;
|
|
60
|
+
if (this.$store.state.player.live) {
|
|
61
|
+
if (!this.hlsReady)
|
|
62
|
+
return this.$store.state.player.live.title + ' (' + this.$t('Start in a while') + ')';
|
|
63
|
+
return this.$store.state.player.live.title;
|
|
64
|
+
}
|
|
65
|
+
return '';
|
|
66
|
+
},
|
|
67
|
+
emissionName(): string {
|
|
68
|
+
if (this.$store.state.player.podcast) return this.$store.state.player.podcast.emission.name;
|
|
69
|
+
return '';
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
created(){
|
|
73
|
+
window.addEventListener('keydown', this.addKeyboardControl);
|
|
74
|
+
},
|
|
75
|
+
beforeUnmount() {
|
|
76
|
+
window.removeEventListener('keydown', this.addKeyboardControl);
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
methods: {
|
|
80
|
+
addKeyboardControl(event: KeyboardEvent): void{
|
|
81
|
+
if(!event || null ===event){return;}
|
|
82
|
+
const element = event.target as HTMLElement;
|
|
83
|
+
if (!element || 'INPUT' == element.tagName.toUpperCase() || 'TEXTAREA' == element.tagName.toUpperCase()){return;}
|
|
84
|
+
if (' ' === event.key || 'Spacebar' === event.key) {
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
this.switchPausePlay();
|
|
87
|
+
}else if ('ArrowRight' === event.key && event.ctrlKey) {
|
|
88
|
+
const audioPlayer: HTMLAudioElement|null = document.querySelector('#audio-player');
|
|
89
|
+
if(!audioPlayer){return;}
|
|
90
|
+
audioPlayer.currentTime += 15;
|
|
91
|
+
}else if ('ArrowLeft' === event.key && event.ctrlKey) {
|
|
92
|
+
const audioPlayer: HTMLAudioElement|null = document.querySelector('#audio-player');
|
|
93
|
+
if(!audioPlayer){return;}
|
|
94
|
+
audioPlayer.currentTime -=15;
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
switchPausePlay(): void {
|
|
98
|
+
const audioPlayer: HTMLAudioElement|null = document.querySelector('#audio-player');
|
|
99
|
+
if(!audioPlayer){return;}
|
|
100
|
+
if (audioPlayer.paused) {
|
|
101
|
+
this.onPlay();
|
|
102
|
+
} else {
|
|
103
|
+
this.onPause();
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
onPlay(): void {
|
|
107
|
+
this.$store.commit('playerPause', false);
|
|
108
|
+
},
|
|
109
|
+
onPause(): void {
|
|
110
|
+
this.$store.commit('playerPause', true);
|
|
111
|
+
},
|
|
112
|
+
}
|
|
113
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { mapState } from 'vuex';
|
|
2
|
+
import { state } from '../../../store/paramStore';
|
|
3
|
+
import octopusApi from '@saooti/octopus-api';
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
let Hls:any = null;
|
|
6
|
+
/* eslint-enable */
|
|
7
|
+
import { StoreState } from '@/store/typeAppStore';
|
|
8
|
+
import { defineComponent } from 'vue';
|
|
9
|
+
export const playerLive = defineComponent({
|
|
10
|
+
data() {
|
|
11
|
+
return {
|
|
12
|
+
listenTime: 0 as number,
|
|
13
|
+
notListenTime: 0 as number,
|
|
14
|
+
lastSend: 0 as number,
|
|
15
|
+
hlsReady: false as boolean,
|
|
16
|
+
downloadId: null as string|null,
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
computed: {
|
|
20
|
+
...mapState({
|
|
21
|
+
live(state: StoreState) { return state.player.live}
|
|
22
|
+
}),
|
|
23
|
+
},
|
|
24
|
+
methods: {
|
|
25
|
+
onPlay(): void {
|
|
26
|
+
this.$store.commit('playerPause', false);
|
|
27
|
+
},
|
|
28
|
+
async playLive(): Promise<void> {
|
|
29
|
+
if (!this.live) return;
|
|
30
|
+
const hlsStreamUrl =
|
|
31
|
+
state.podcastPage.hlsUri +
|
|
32
|
+
'stream/dev.' +
|
|
33
|
+
this.live.conferenceId +
|
|
34
|
+
'/index.m3u8';
|
|
35
|
+
try {
|
|
36
|
+
await this.initHls(hlsStreamUrl);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.log(error);
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
this.playLive();
|
|
41
|
+
}, 1000);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
async initHls(hlsStreamUrl: string): Promise<void> {
|
|
45
|
+
return new Promise<void>(async(resolve, reject) => {
|
|
46
|
+
if(null === Hls){
|
|
47
|
+
//TODO -> Version light min quand ce sera possible
|
|
48
|
+
await import('hls.js/dist/hls.js').then((hlsLibrary) => {
|
|
49
|
+
Hls = hlsLibrary.default;
|
|
50
|
+
})
|
|
51
|
+
await import('hls.js').then((hlsLibrary) => {
|
|
52
|
+
Hls = hlsLibrary.default;
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
if (!Hls.isSupported()) {
|
|
56
|
+
reject('Hls is not supported ! ');
|
|
57
|
+
}
|
|
58
|
+
let hls = new Hls();
|
|
59
|
+
if(this.$store.state.authentication.isAuthenticated && this.$store.state.oAuthParam.accessToken){
|
|
60
|
+
hls = new Hls({xhrSetup:
|
|
61
|
+
(xhr: any) => {
|
|
62
|
+
xhr.setRequestHeader("Authorization", "Bearer " + this.$store.state.oAuthParam.accessToken);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
hls.on(Hls.Events.MANIFEST_PARSED, async () => {
|
|
68
|
+
if(!this.live){ return; }
|
|
69
|
+
let downloadId = null;
|
|
70
|
+
try {
|
|
71
|
+
downloadId = await octopusApi.requestLiveDownloadId(
|
|
72
|
+
this.live.livePodcastId
|
|
73
|
+
);
|
|
74
|
+
await octopusApi.markPlayingLive(
|
|
75
|
+
this.live.livePodcastId,
|
|
76
|
+
downloadId,
|
|
77
|
+
'octopus',
|
|
78
|
+
this.$store.state.authentication.organisationId
|
|
79
|
+
);
|
|
80
|
+
this.setDownloadId(downloadId);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.log('ERROR downloadId');
|
|
83
|
+
}
|
|
84
|
+
this.hlsReady = true;
|
|
85
|
+
const audio: HTMLElement|null = document.getElementById('audio-player');
|
|
86
|
+
hls.attachMedia((audio as HTMLAudioElement));
|
|
87
|
+
await (audio as HTMLAudioElement).play();
|
|
88
|
+
this.onPlay();
|
|
89
|
+
resolve();
|
|
90
|
+
});
|
|
91
|
+
hls.on(Hls.Events.ERROR, async() => {
|
|
92
|
+
reject('There is an error while reading media content');
|
|
93
|
+
});
|
|
94
|
+
hls.loadSource(hlsStreamUrl);
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
setDownloadId(newValue: string|null): void {
|
|
98
|
+
this.endListeningProgress();
|
|
99
|
+
this.downloadId = newValue;
|
|
100
|
+
},
|
|
101
|
+
async endListeningProgress(): Promise<void> {
|
|
102
|
+
if (!this.downloadId) return;
|
|
103
|
+
try {
|
|
104
|
+
await octopusApi.updatePlayerTime(
|
|
105
|
+
this.downloadId,
|
|
106
|
+
Math.round(this.listenTime)
|
|
107
|
+
);
|
|
108
|
+
} catch{
|
|
109
|
+
//Do nothing
|
|
110
|
+
}
|
|
111
|
+
this.downloadId = null;
|
|
112
|
+
this.notListenTime = 0;
|
|
113
|
+
this.lastSend = 0;
|
|
114
|
+
this.listenTime = 0;
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
})
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { mapState } from 'vuex';
|
|
2
|
+
import octopusApi from '@saooti/octopus-api';
|
|
3
|
+
import { CommentPodcast } from '@/store/class/general/comment';
|
|
4
|
+
import { cookies } from '../functions';
|
|
5
|
+
import { playerLive } from './playerLive';
|
|
6
|
+
import { playerComment } from './playerComment';
|
|
7
|
+
import { StoreState } from '@/store/typeAppStore';
|
|
8
|
+
import { defineComponent } from 'vue';
|
|
9
|
+
export const playerLogic = defineComponent({
|
|
10
|
+
mixins:[cookies,playerLive,playerComment],
|
|
11
|
+
data() {
|
|
12
|
+
return {
|
|
13
|
+
forceHide: false as boolean,
|
|
14
|
+
listenTime: 0 as number,
|
|
15
|
+
notListenTime: 0 as number,
|
|
16
|
+
lastSend: 0 as number,
|
|
17
|
+
downloadId: null as string|null,
|
|
18
|
+
playerError: false as boolean,
|
|
19
|
+
listenError: false as boolean,
|
|
20
|
+
percentLiveProgress: 0 as number,
|
|
21
|
+
durationLivePosition: 0 as number,
|
|
22
|
+
displayAlertBar: false as boolean,
|
|
23
|
+
hlsReady: false as boolean,
|
|
24
|
+
comments: [] as Array<CommentPodcast>,
|
|
25
|
+
showTimeline: false as boolean,
|
|
26
|
+
audioUrlToPlay: "" as string
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
computed: {
|
|
30
|
+
...mapState({
|
|
31
|
+
podcast (state: StoreState){ return state.player.podcast},
|
|
32
|
+
media: (state: StoreState) => state.player.media,
|
|
33
|
+
live: (state: StoreState) => state.player.live,
|
|
34
|
+
volume: (state: StoreState) => state.player.volume,
|
|
35
|
+
commentsLoaded: (state: StoreState) => state.comments.loadedComments,
|
|
36
|
+
percentProgress: (state: StoreState) => {
|
|
37
|
+
if(!state.player.elapsed){return 0;}
|
|
38
|
+
return state.player.elapsed * 100;
|
|
39
|
+
},
|
|
40
|
+
playerSeekTime: (state: StoreState) => state.player.seekTime,
|
|
41
|
+
}),
|
|
42
|
+
audioUrl(): string {
|
|
43
|
+
return this.getAudioUrl();
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
watch: {
|
|
48
|
+
async audioUrl(): Promise<void>{
|
|
49
|
+
this.playerError = false;
|
|
50
|
+
if(this.media || !this.podcast || !this.podcast.availability.visibility ||this.listenError){
|
|
51
|
+
this.audioUrlToPlay = this.audioUrl;
|
|
52
|
+
}
|
|
53
|
+
if(!this.podcast){return;}
|
|
54
|
+
const response = await octopusApi.fetchPodcastDownloadUrl("podcast/download/register/"+this.podcast.podcastId+".mp3"+ this.audioUrl);
|
|
55
|
+
this.setDownloadId(response.downloadId.toString());
|
|
56
|
+
this.audioUrlToPlay = response.location;
|
|
57
|
+
},
|
|
58
|
+
podcast: {
|
|
59
|
+
deep: true,
|
|
60
|
+
handler(){
|
|
61
|
+
this.reInitPlayer();
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
live: {
|
|
65
|
+
deep: true,
|
|
66
|
+
async handler(){
|
|
67
|
+
this.hlsReady = false;
|
|
68
|
+
this.reInitPlayer();
|
|
69
|
+
await this.playLive();
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
async listenTime(newVal): Promise<void> {
|
|
73
|
+
if ((!this.podcast && !this.live)||(!this.downloadId)||(newVal - this.lastSend < 10)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
this.lastSend = newVal;
|
|
77
|
+
await octopusApi.updatePlayerTime(
|
|
78
|
+
this.downloadId,
|
|
79
|
+
Math.round(newVal)
|
|
80
|
+
);
|
|
81
|
+
},
|
|
82
|
+
playerSeekTime(){
|
|
83
|
+
if(!this.playerSeekTime){return;}
|
|
84
|
+
if (this.$store.state.player.podcast || this.$store.state.player.live) {
|
|
85
|
+
this.notListenTime = this.playerSeekTime - this.listenTime;
|
|
86
|
+
}
|
|
87
|
+
const audioPlayer: HTMLAudioElement | null = document.querySelector('#audio-player');
|
|
88
|
+
if (!audioPlayer) return;
|
|
89
|
+
audioPlayer.currentTime = this.playerSeekTime;
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
mounted() {
|
|
94
|
+
window.addEventListener('beforeunload', this.endListeningProgress);
|
|
95
|
+
this.watchPlayerStatus();
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
methods: {
|
|
99
|
+
getDomain(): string{
|
|
100
|
+
let domain = "";
|
|
101
|
+
const domainArray: RegExpExecArray | null = /\.(.+)/.exec(window.location.host);
|
|
102
|
+
if(domainArray && null !== domainArray){
|
|
103
|
+
domain = domainArray[1];
|
|
104
|
+
}
|
|
105
|
+
return domain;
|
|
106
|
+
},
|
|
107
|
+
getAudioUrl(): string{
|
|
108
|
+
if (this.media) return this.media.audioUrl? this.media.audioUrl:"";
|
|
109
|
+
if (!this.podcast) return '';
|
|
110
|
+
if (!this.podcast.availability.visibility)
|
|
111
|
+
return this.podcast.audioStorageUrl;
|
|
112
|
+
if (this.listenError) return this.podcast.audioStorageUrl;
|
|
113
|
+
const parameters = [];
|
|
114
|
+
parameters.push('origin=octopus');
|
|
115
|
+
parameters.push('listenerId='+this.getListenerId());
|
|
116
|
+
if (
|
|
117
|
+
this.$store.state.authentication &&
|
|
118
|
+
this.$store.state.authentication.organisationId
|
|
119
|
+
) {
|
|
120
|
+
parameters.push(
|
|
121
|
+
'distributorId=' + this.$store.state.authentication.organisationId
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
if("SECURED" === this.podcast.organisation.privacy && this.$store.state.authentication.isAuthenticated && this.$store.state.oAuthParam.accessToken){
|
|
125
|
+
parameters.push('access_token='+this.$store.state.oAuthParam.accessToken);
|
|
126
|
+
}
|
|
127
|
+
return this.podcast.podcastId + '.mp3?' + parameters.join('&');
|
|
128
|
+
},
|
|
129
|
+
reInitPlayer():void{
|
|
130
|
+
this.setDownloadId(null);
|
|
131
|
+
this.listenError = false;
|
|
132
|
+
this.initComments();
|
|
133
|
+
},
|
|
134
|
+
stopPlayer(): void {
|
|
135
|
+
this.$store.commit('playerPlayPodcast');
|
|
136
|
+
},
|
|
137
|
+
getListenerId(): string{
|
|
138
|
+
let listenerId = this.getCookie("octopus_listenerId");
|
|
139
|
+
if(!listenerId){
|
|
140
|
+
listenerId = new Date().valueOf().toString() + Math.random();
|
|
141
|
+
this.setCookie("octopus_listenerId", listenerId, ';domain='+this.getDomain());
|
|
142
|
+
}
|
|
143
|
+
return listenerId;
|
|
144
|
+
},
|
|
145
|
+
watchPlayerStatus(): void {
|
|
146
|
+
this.$store.watch(
|
|
147
|
+
(state: StoreState) => state.player.status,
|
|
148
|
+
(newValue: string) => {
|
|
149
|
+
const audioPlayer: HTMLAudioElement | null = document.querySelector('#audio-player');
|
|
150
|
+
if (!audioPlayer) return;
|
|
151
|
+
if (this.live && !this.hlsReady) {
|
|
152
|
+
audioPlayer.pause();
|
|
153
|
+
this.percentLiveProgress = 0;
|
|
154
|
+
this.durationLivePosition = 0;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if ('PAUSED' === newValue) {
|
|
158
|
+
audioPlayer.pause();
|
|
159
|
+
}else if ('PLAYING' === newValue){
|
|
160
|
+
audioPlayer.play();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
},
|
|
165
|
+
onError(): void {
|
|
166
|
+
if (this.podcast && ""!==this.audioUrlToPlay && !this.listenError) {
|
|
167
|
+
this.listenError = true;
|
|
168
|
+
} else if ((this.podcast && ""!==this.audioUrlToPlay ) || this.media) {
|
|
169
|
+
this.playerError = true;
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
onTimeUpdate(event: Event): void {
|
|
173
|
+
const mediaTarget = (event.currentTarget as HTMLMediaElement);
|
|
174
|
+
if (this.podcast || this.live) {
|
|
175
|
+
if (!this.downloadId) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (
|
|
179
|
+
this.live &&
|
|
180
|
+
0 === this.listenTime &&
|
|
181
|
+
0 !== mediaTarget.currentTime
|
|
182
|
+
) {
|
|
183
|
+
this.notListenTime = mediaTarget.currentTime;
|
|
184
|
+
this.listenTime = 1;
|
|
185
|
+
} else {
|
|
186
|
+
this.listenTime =
|
|
187
|
+
mediaTarget.currentTime - this.notListenTime;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const streamDuration = mediaTarget.duration;
|
|
191
|
+
if (!streamDuration) return;
|
|
192
|
+
if (!mediaTarget.currentTime) return;
|
|
193
|
+
if (!this.live) {
|
|
194
|
+
this.displayAlertBar = false;
|
|
195
|
+
this.percentLiveProgress = 100;
|
|
196
|
+
this.$store.commit('playerTotalTime', streamDuration);
|
|
197
|
+
this.$store.commit('playerElapsed', mediaTarget.currentTime / streamDuration);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const scheduledDuration = this.live.duration / 1000;
|
|
201
|
+
if (scheduledDuration > streamDuration) {
|
|
202
|
+
this.displayAlertBar = false;
|
|
203
|
+
this.percentLiveProgress = (streamDuration / scheduledDuration) * 100;
|
|
204
|
+
this.$store.commit('playerTotalTime', scheduledDuration);
|
|
205
|
+
this.$store.commit(
|
|
206
|
+
'playerElapsed',
|
|
207
|
+
mediaTarget.currentTime / scheduledDuration
|
|
208
|
+
);
|
|
209
|
+
} else {
|
|
210
|
+
this.percentLiveProgress = 100;
|
|
211
|
+
this.displayAlertBar = true;
|
|
212
|
+
this.durationLivePosition = (scheduledDuration / streamDuration) * 100;
|
|
213
|
+
this.$store.commit('playerTotalTime', streamDuration);
|
|
214
|
+
this.$store.commit('playerElapsed', mediaTarget.currentTime / streamDuration);
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
onFinished(): void {
|
|
218
|
+
this.setDownloadId(null);
|
|
219
|
+
if (this.live) {
|
|
220
|
+
const audio: HTMLElement|null = document.getElementById('audio-player');
|
|
221
|
+
if(audio){
|
|
222
|
+
(audio as HTMLAudioElement).src = '';
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
this.forceHide = true;
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
})
|
package/src/locale/de.ts
CHANGED
package/src/locale/en.ts
CHANGED
package/src/locale/es.ts
CHANGED
package/src/locale/fr.ts
CHANGED
package/src/locale/it.ts
CHANGED
package/src/locale/sl.ts
CHANGED
package/src/store/paramStore.ts
CHANGED
|
@@ -73,8 +73,6 @@ const state:paramStore = {
|
|
|
73
73
|
player: {
|
|
74
74
|
image: true,
|
|
75
75
|
emissionName: false,
|
|
76
|
-
clock: false,
|
|
77
|
-
barTop: false,
|
|
78
76
|
},
|
|
79
77
|
footer: {
|
|
80
78
|
contactLink: undefined,
|
|
@@ -164,9 +162,7 @@ export interface SearchPage{
|
|
|
164
162
|
}
|
|
165
163
|
export interface Player{
|
|
166
164
|
image?: boolean
|
|
167
|
-
|
|
168
|
-
clock?: boolean
|
|
169
|
-
barTop?: boolean
|
|
165
|
+
emissionName?: boolean
|
|
170
166
|
}
|
|
171
167
|
export interface Footer{
|
|
172
168
|
contactLink?: string|undefined
|