@saooti/octopus-sdk 34.0.4 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saooti/octopus-sdk",
3
- "version": "34.0.4",
3
+ "version": "34.0.5",
4
4
  "private": false,
5
5
  "description": "Javascript SDK for using octopus",
6
6
  "author": "Saooti",
@@ -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 { MediaRadio, 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.title + " - " + this.$store.state.player.radio.metadata.artist;
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)
@@ -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<MediaRadio>(14, 'player/playing/'+this.$store.state.player.radio.canalId);
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: {
@@ -84,18 +85,18 @@ export const playerLive = defineComponent({
84
85
  if (!Hls.isSupported()) {
85
86
  reject('Hls is not supported ! ');
86
87
  }
87
- const hls = new Hls();
88
- hls.on(Hls.Events.MANIFEST_PARSED, async () => {
88
+ this.hls = new Hls();
89
+ this.hls.on(Hls.Events.MANIFEST_PARSED, async () => {
89
90
  await this.initLiveDownloadId();
90
- hls.attachMedia((this.audioElement as HTMLAudioElement));
91
+ this.hls.attachMedia((this.audioElement as HTMLAudioElement));
91
92
  await (this.audioElement as HTMLAudioElement).play();
92
93
  this.onPlay();
93
94
  resolve();
94
95
  });
95
- hls.on(Hls.Events.ERROR, async() => {
96
+ this.hls.on(Hls.Events.ERROR, async() => {
96
97
  reject('There is an error while reading media content');
97
98
  });
98
- hls.loadSource(hlsStreamUrl);
99
+ this.hls.loadSource(hlsStreamUrl);
99
100
  });
100
101
  },
101
102
  setDownloadId(newValue: string|null): void {
@@ -114,5 +115,13 @@ export const playerLive = defineComponent({
114
115
  this.lastSend = 0;
115
116
  this.listenTime = 0;
116
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
+ }
117
126
  },
118
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.playRadio();
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,6 +1,7 @@
1
1
  <template>
2
2
  <div class="page-box">
3
3
  <button @click="playRadio">Radio</button>
4
+ <button @click="playRadioBis">RadioBis</button>
4
5
  <template v-if="0 === rubriquageFilter.length">
5
6
  <PodcastInlineList
6
7
  v-for="c in categories"
@@ -96,6 +97,14 @@ export default defineComponent({
96
97
  metadata : ""
97
98
  });
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
+
99
108
  }
100
109
  }
101
110
  })
@@ -40,7 +40,7 @@ const mutations = <MutationTree<Player>>{
40
40
  } else if (podcast.mediaId) {
41
41
  state.media = podcast;
42
42
  }else if(podcast.canalId){
43
- state.radio = podcast;
43
+ state.radio = {...podcast,...{isInit: false}};
44
44
  }
45
45
  },
46
46
 
@@ -5,6 +5,7 @@ export interface Radio{
5
5
  canalId: number;
6
6
  url: string;
7
7
  metadata: MediaRadio;
8
+ isInit: boolean,
8
9
  }
9
10
  export interface MediaRadio{
10
11
  artist:string;
@@ -18,6 +19,13 @@ export interface MediaRadio{
18
19
  uri:string;
19
20
  }
20
21
 
22
+ export interface MetadataRadio{
23
+ channelId:number;
24
+ currently:MediaRadio;
25
+ previously:Array<MediaRadio>;
26
+ }
27
+
28
+
21
29
 
22
30
  export interface Player{
23
31
  status: string; //STOPPED, LOADING, PLAYING, PAUSED