@saooti/octopus-sdk 32.0.30 → 32.0.31

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 CHANGED
@@ -643,6 +643,12 @@ See [Configuration Reference](https://cli.vuejs.org/config/).
643
643
  * 31.0.50 Améliorations responsive
644
644
  * 31.0.51 Newest
645
645
  * 31.0.52 Locale
646
+ * 31.0.53 Correction playerLogic
647
+ * 31.0.54 Test live ios
648
+ * 31.0.55 Test live ios
649
+ * 31.0.56 Test live ios
650
+ * 31.0.57 Test live ios
651
+
646
652
 
647
653
  * 32.0.0 Passage en 32
648
654
  * 32.0.1 Navigation clavier
@@ -674,4 +680,5 @@ See [Configuration Reference](https://cli.vuejs.org/config/).
674
680
  * 32.0.27 Image Proxy -> webp
675
681
  * 32.0.28 Image Proxy
676
682
  * 32.0.29 SpeechToText
677
- * 32.0.30 SpeechToText
683
+ * 32.0.30 SpeechToText
684
+ * 32.0.31 Merge live IOS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saooti/octopus-sdk",
3
- "version": "32.0.30",
3
+ "version": "32.0.31",
4
4
  "private": false,
5
5
  "description": "Javascript SDK for using octopus",
6
6
  "author": "Saooti",
@@ -16,8 +16,8 @@ enum ModuleApi {
16
16
  }
17
17
  /* eslint-disable */
18
18
  export default {
19
- async fetchData<Type>(state: StoreState,moduleName: ModuleApi,wsPath:string): Promise<Type>{
20
- console.log(state,moduleName,wsPath);
19
+ async fetchData<Type>(state: StoreState,moduleName: ModuleApi,wsPath:string, forceRefresh?:boolean): Promise<Type>{
20
+ console.log(state,moduleName,wsPath,forceRefresh);
21
21
  const response = await axios.get('/mock');
22
22
  return response.data;
23
23
  },
@@ -14,6 +14,7 @@ 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
18
  };
18
19
  },
19
20
  computed: {
@@ -33,14 +34,43 @@ export const playerLive = defineComponent({
33
34
  this.live.conferenceId +
34
35
  '/index.m3u8';
35
36
  try {
36
- await this.initHls(hlsStreamUrl);
37
+ this.audioElement = (document.getElementById('audio-player') as HTMLAudioElement);
38
+ if(null===this.audioElement){
39
+ setTimeout(() => {
40
+ this.playLive();
41
+ }, 1000);
42
+ return;
43
+ }
44
+ if (this.audioElement.canPlayType('application/vnd.apple.mpegurl')) {
45
+ this.audioElement.src = hlsStreamUrl;
46
+ await this.initLiveDownloadId();
47
+ await (this.audioElement as HTMLAudioElement).play();
48
+ this.onPlay();
49
+ }else{
50
+ await this.initHls(hlsStreamUrl);
51
+ }
37
52
  } catch (error) {
38
- console.log(error);
39
53
  setTimeout(() => {
40
54
  this.playLive();
41
55
  }, 1000);
42
56
  }
43
57
  },
58
+ async initLiveDownloadId(){
59
+ if(!this.live){ return;}
60
+ let downloadId = null;
61
+ try {
62
+ downloadId = await octopusApi.putDataPublic<string | null>(0, 'podcast/prepare/live/'+this.live.livePodcastId, undefined);
63
+ await octopusApi.fetchDataPublicWithParams<string | null>(0,'podcast/download/live/' + this.live.livePodcastId+".m3u8",{
64
+ 'downloadId': null!==downloadId ? downloadId : undefined,
65
+ 'origin':'octopus',
66
+ 'distributorId':this.$store.state.authentication.organisationId
67
+ });
68
+ this.setDownloadId(downloadId);
69
+ } catch (error) {
70
+ console.log('ERROR downloadId');
71
+ }
72
+ this.hlsReady = true;
73
+ },
44
74
  async initHls(hlsStreamUrl: string): Promise<void> {
45
75
  return new Promise<void>(async(resolve, reject) => {
46
76
  if(null === Hls){
@@ -65,23 +95,9 @@ export const playerLive = defineComponent({
65
95
  );
66
96
  } */
67
97
  hls.on(Hls.Events.MANIFEST_PARSED, async () => {
68
- if(!this.live){ return; }
69
- let downloadId = null;
70
- try {
71
- downloadId = await octopusApi.putDataPublic<string | null>(0, 'podcast/prepare/live/'+this.live.livePodcastId, undefined);
72
- await octopusApi.fetchDataPublicWithParams<string | null>(0,'podcast/download/live/' + this.live.livePodcastId+".m3u8",{
73
- 'downloadId': null!==downloadId ? downloadId : undefined,
74
- 'origin':'octopus',
75
- 'distributorId':this.$store.state.authentication.organisationId
76
- });
77
- this.setDownloadId(downloadId);
78
- } catch (error) {
79
- console.log('ERROR downloadId');
80
- }
81
- this.hlsReady = true;
82
- const audio: HTMLElement|null = document.getElementById('audio-player');
83
- hls.attachMedia((audio as HTMLAudioElement));
84
- await (audio as HTMLAudioElement).play();
98
+ await this.initLiveDownloadId();
99
+ hls.attachMedia((this.audioElement as HTMLAudioElement));
100
+ await (this.audioElement as HTMLAudioElement).play();
85
101
  this.onPlay();
86
102
  resolve();
87
103
  });
@@ -63,10 +63,12 @@ export const playerLogic = defineComponent({
63
63
  },
64
64
  live: {
65
65
  deep: true,
66
- async handler(){
67
- this.hlsReady = false;
68
- this.reInitPlayer();
69
- await this.playLive();
66
+ handler(){
67
+ this.$nextTick(async () => {
68
+ this.hlsReady = false;
69
+ this.reInitPlayer();
70
+ await this.playLive();
71
+ });
70
72
  }
71
73
  },
72
74
  async listenTime(newVal): Promise<void> {
@@ -188,7 +190,15 @@ export const playerLogic = defineComponent({
188
190
  mediaTarget.currentTime - this.notListenTime;
189
191
  }
190
192
  }
191
- const streamDuration = mediaTarget.duration;
193
+ let streamDuration = mediaTarget.duration;
194
+ if(Infinity===streamDuration){
195
+ const seekable = mediaTarget.seekable;
196
+ if(seekable){
197
+ streamDuration = seekable.end(seekable.length - 1);
198
+ }else{
199
+ streamDuration = mediaTarget.currentTime;
200
+ }
201
+ }
192
202
  if (!streamDuration) return;
193
203
  if (!mediaTarget.currentTime) return;
194
204
  if (!this.live) {