@saooti/octopus-sdk 34.0.3 → 34.0.5
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 +3 -3
- package/src/components/mixins/player/playerDisplay.ts +5 -5
- package/src/components/mixins/player/playerLive.ts +16 -10
- package/src/components/mixins/player/playerLogic.ts +8 -7
- package/src/components/pages/Home.vue +18 -0
- package/src/store/PlayerStore.ts +1 -1
- package/src/store/class/general/classicSelectType.ts +5 -0
- package/src/store/class/general/listReturn.ts +16 -0
- package/src/store/class/general/player.ts +20 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saooti/octopus-sdk",
|
|
3
|
-
"version": "34.0.
|
|
3
|
+
"version": "34.0.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Javascript SDK for using octopus",
|
|
6
6
|
"author": "Saooti",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"sonarqube-scanner": "^2.9.1",
|
|
33
33
|
"swiper": "^8.4.5",
|
|
34
34
|
"v-calendar": "^3.0.0-alpha.8",
|
|
35
|
-
"vite": "^
|
|
35
|
+
"vite": "^3.2.5",
|
|
36
36
|
"vue": "^3.2.45",
|
|
37
37
|
"vue-i18n": "^9.2.2",
|
|
38
38
|
"vue-multiselect": "^3.0.0-alpha.2",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@types/jquery": "^3.5.14",
|
|
47
47
|
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
|
48
48
|
"@typescript-eslint/parser": "^5.46.1",
|
|
49
|
-
"@vitejs/plugin-vue": "^
|
|
49
|
+
"@vitejs/plugin-vue": "^3.2.0",
|
|
50
50
|
"@vue/compiler-sfc": "^3.2.45",
|
|
51
51
|
"@vue/eslint-config-typescript": "^11.0.2",
|
|
52
52
|
"eslint": "^8.29.0",
|
|
@@ -3,7 +3,7 @@ import DurationHelper from '../../../helper/duration';
|
|
|
3
3
|
import { state } from '../../../store/paramStore';
|
|
4
4
|
import { defineComponent } from 'vue';
|
|
5
5
|
import { RouteLocationRaw } from 'vue-router';
|
|
6
|
-
import { Radio } from '@/store/class/general/player';
|
|
6
|
+
import { MediaRadio, MetadataRadio, Radio } from '@/store/class/general/player';
|
|
7
7
|
import octopusApi from '@saooti/octopus-api';
|
|
8
8
|
export const playerDisplay = defineComponent({
|
|
9
9
|
props: {
|
|
@@ -59,7 +59,7 @@ export const playerDisplay = defineComponent({
|
|
|
59
59
|
},
|
|
60
60
|
podcastTitle(): string {
|
|
61
61
|
if(this.$store.state.player.radio){
|
|
62
|
-
return this.$store.state.player.radio.metadata;
|
|
62
|
+
return this.$store.state.player.radio.metadata.title + " " + this.$store.state.player.radio.metadata.artist;
|
|
63
63
|
}
|
|
64
64
|
if (this.$store.state.player.podcast) {
|
|
65
65
|
if (this.isEmissionName)
|
|
@@ -82,7 +82,7 @@ export const playerDisplay = defineComponent({
|
|
|
82
82
|
return this.$store.state.player.transcript?.actualText ?? "";
|
|
83
83
|
},
|
|
84
84
|
radio(): Radio{
|
|
85
|
-
return this.$store.state.player.radio;
|
|
85
|
+
return this.$store.state.player.radio?.url;
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
watch:{
|
|
@@ -109,8 +109,8 @@ export const playerDisplay = defineComponent({
|
|
|
109
109
|
},
|
|
110
110
|
methods: {
|
|
111
111
|
async fetchRadioMetadata(): Promise<void>{
|
|
112
|
-
const metadata = await octopusApi.fetchData<
|
|
113
|
-
this.$store.commit('player/radioMetadata', metadata);
|
|
112
|
+
const metadata = await octopusApi.fetchData<MetadataRadio>(14, 'player/playing/'+this.$store.state.player.radio.canalId);
|
|
113
|
+
this.$store.commit('player/radioMetadata', metadata.currently);
|
|
114
114
|
},
|
|
115
115
|
addKeyboardControl(event: KeyboardEvent): void{
|
|
116
116
|
if(!event || null ===event){return;}
|
|
@@ -14,7 +14,8 @@ export const playerLive = defineComponent({
|
|
|
14
14
|
lastSend: 0 as number,
|
|
15
15
|
hlsReady: false as boolean,
|
|
16
16
|
downloadId: null as string|null,
|
|
17
|
-
audioElement: null as HTMLAudioElement|null
|
|
17
|
+
audioElement: null as HTMLAudioElement|null,
|
|
18
|
+
hls: null as any,
|
|
18
19
|
};
|
|
19
20
|
},
|
|
20
21
|
computed: {
|
|
@@ -77,28 +78,25 @@ export const playerLive = defineComponent({
|
|
|
77
78
|
async initHls(hlsStreamUrl: string): Promise<void> {
|
|
78
79
|
return new Promise<void>(async(resolve, reject) => {
|
|
79
80
|
if(null === Hls){
|
|
80
|
-
await import('hls.js
|
|
81
|
-
Hls = hlsLibrary.default;
|
|
82
|
-
})
|
|
83
|
-
await import('hls.js').then((hlsLibrary) => {
|
|
81
|
+
await import('hls.js').then((hlsLibrary) => {
|
|
84
82
|
Hls = hlsLibrary.default;
|
|
85
83
|
})
|
|
86
84
|
}
|
|
87
85
|
if (!Hls.isSupported()) {
|
|
88
86
|
reject('Hls is not supported ! ');
|
|
89
87
|
}
|
|
90
|
-
|
|
91
|
-
hls.on(Hls.Events.MANIFEST_PARSED, async () => {
|
|
88
|
+
this.hls = new Hls();
|
|
89
|
+
this.hls.on(Hls.Events.MANIFEST_PARSED, async () => {
|
|
92
90
|
await this.initLiveDownloadId();
|
|
93
|
-
hls.attachMedia((this.audioElement as HTMLAudioElement));
|
|
91
|
+
this.hls.attachMedia((this.audioElement as HTMLAudioElement));
|
|
94
92
|
await (this.audioElement as HTMLAudioElement).play();
|
|
95
93
|
this.onPlay();
|
|
96
94
|
resolve();
|
|
97
95
|
});
|
|
98
|
-
hls.on(Hls.Events.ERROR, async() => {
|
|
96
|
+
this.hls.on(Hls.Events.ERROR, async() => {
|
|
99
97
|
reject('There is an error while reading media content');
|
|
100
98
|
});
|
|
101
|
-
hls.loadSource(hlsStreamUrl);
|
|
99
|
+
this.hls.loadSource(hlsStreamUrl);
|
|
102
100
|
});
|
|
103
101
|
},
|
|
104
102
|
setDownloadId(newValue: string|null): void {
|
|
@@ -117,5 +115,13 @@ export const playerLive = defineComponent({
|
|
|
117
115
|
this.lastSend = 0;
|
|
118
116
|
this.listenTime = 0;
|
|
119
117
|
},
|
|
118
|
+
endingLive():void{
|
|
119
|
+
const audio: HTMLElement|null = document.getElementById('audio-player');
|
|
120
|
+
if(audio && this.hls){
|
|
121
|
+
this.hls.destroy();
|
|
122
|
+
(audio as HTMLAudioElement).src = '';
|
|
123
|
+
this.hls = null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
120
126
|
},
|
|
121
127
|
})
|
|
@@ -113,7 +113,11 @@ export const playerLogic = defineComponent({
|
|
|
113
113
|
}else if('PAUSED' === this.status){
|
|
114
114
|
audioPlayer.pause();
|
|
115
115
|
}else if ('PLAYING' === this.status && this.radio){
|
|
116
|
-
this.
|
|
116
|
+
if(this.radio.isInit){
|
|
117
|
+
this.playRadio();
|
|
118
|
+
}else{
|
|
119
|
+
this.radio.isInit = true;
|
|
120
|
+
}
|
|
117
121
|
}else if('PLAYING' === this.status){
|
|
118
122
|
audioPlayer.play();
|
|
119
123
|
}
|
|
@@ -163,6 +167,9 @@ export const playerLogic = defineComponent({
|
|
|
163
167
|
this.setDownloadId(null);
|
|
164
168
|
this.listenError = false;
|
|
165
169
|
this.initComments();
|
|
170
|
+
if (this.live || this.radio) {
|
|
171
|
+
this.endingLive();
|
|
172
|
+
}
|
|
166
173
|
},
|
|
167
174
|
stopPlayer(): void {
|
|
168
175
|
this.$store.commit('player/playPodcast');
|
|
@@ -260,11 +267,5 @@ export const playerLogic = defineComponent({
|
|
|
260
267
|
}
|
|
261
268
|
this.forceHide = true;
|
|
262
269
|
},
|
|
263
|
-
endingLive():void{
|
|
264
|
-
const audio: HTMLElement|null = document.getElementById('audio-player');
|
|
265
|
-
if(audio){
|
|
266
|
-
(audio as HTMLAudioElement).src = '';
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
270
|
},
|
|
270
271
|
})
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="page-box">
|
|
3
|
+
<button @click="playRadio">Radio</button>
|
|
4
|
+
<button @click="playRadioBis">RadioBis</button>
|
|
3
5
|
<template v-if="0 === rubriquageFilter.length">
|
|
4
6
|
<PodcastInlineList
|
|
5
7
|
v-for="c in categories"
|
|
@@ -88,6 +90,22 @@ export default defineComponent({
|
|
|
88
90
|
}
|
|
89
91
|
this.rubriqueId = rubriqueId;
|
|
90
92
|
},
|
|
93
|
+
playRadio(){
|
|
94
|
+
this.$store.commit('player/playPodcast', {
|
|
95
|
+
canalId: 3,
|
|
96
|
+
url: "https://c6884219-e191-45ec-a931-6f34683c6ac7.stream.dev2.saooti.org/live.m3u8",
|
|
97
|
+
metadata : ""
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
},
|
|
101
|
+
playRadioBis(){
|
|
102
|
+
this.$store.commit('player/playPodcast', {
|
|
103
|
+
canalId: 1,
|
|
104
|
+
url: "https://79a52b6b-8475-42f9-9c48-7f7460202649.stream.dev2.saooti.org/live.m3u8",
|
|
105
|
+
metadata : ""
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
}
|
|
91
109
|
}
|
|
92
110
|
})
|
|
93
111
|
</script>
|
package/src/store/PlayerStore.ts
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Pageable } from "./pageable";
|
|
2
|
+
import { SortPageable } from "./sortPageable";
|
|
3
|
+
|
|
4
|
+
export interface ListReturn<T> {
|
|
5
|
+
content: T;
|
|
6
|
+
empty: boolean;
|
|
7
|
+
first: boolean;
|
|
8
|
+
last: boolean;
|
|
9
|
+
number: number;
|
|
10
|
+
numberOfElements: number;
|
|
11
|
+
pageable: Pageable;
|
|
12
|
+
size: number;
|
|
13
|
+
sort: SortPageable;
|
|
14
|
+
totalElements: number;
|
|
15
|
+
totalPages: number;
|
|
16
|
+
}
|
|
@@ -4,8 +4,27 @@ import { Podcast } from "./podcast";
|
|
|
4
4
|
export interface Radio{
|
|
5
5
|
canalId: number;
|
|
6
6
|
url: string;
|
|
7
|
-
metadata:
|
|
7
|
+
metadata: MediaRadio;
|
|
8
|
+
isInit: boolean,
|
|
8
9
|
}
|
|
10
|
+
export interface MediaRadio{
|
|
11
|
+
artist:string;
|
|
12
|
+
duration:number;
|
|
13
|
+
kind:string;
|
|
14
|
+
mediaId:number;
|
|
15
|
+
mediaType:string|null;
|
|
16
|
+
playlistId:number;
|
|
17
|
+
startDate:string;
|
|
18
|
+
title:string;
|
|
19
|
+
uri:string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface MetadataRadio{
|
|
23
|
+
channelId:number;
|
|
24
|
+
currently:MediaRadio;
|
|
25
|
+
previously:Array<MediaRadio>;
|
|
26
|
+
}
|
|
27
|
+
|
|
9
28
|
|
|
10
29
|
|
|
11
30
|
export interface Player{
|