@saooti/octopus-sdk 31.0.21 → 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 CHANGED
@@ -597,3 +597,4 @@ See [Configuration Reference](https://cli.vuejs.org/config/).
597
597
  * 31.0.19 Add access_token player
598
598
  * 31.0.20 Player mobile
599
599
  * 31.0.21 Player mobile
600
+ * 31.0.22 Merge 30
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saooti/octopus-sdk",
3
- "version": "31.0.21",
3
+ "version": "31.0.22",
4
4
  "private": false,
5
5
  "description": "Javascript SDK for using octopus",
6
6
  "author": "Saooti",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "main": "./dist/octopus.common.js",
16
16
  "dependencies": {
17
- "@saooti/octopus-api": "^0.31.2",
17
+ "@saooti/octopus-api": "^0.31.3",
18
18
  "@vue/cli": "^5.0.4",
19
19
  "@vue/compat": "^3.2.31",
20
20
  "axios": "^0.24.0",
@@ -11,7 +11,7 @@
11
11
  <template v-if="display">
12
12
  <audio
13
13
  id="audio-player"
14
- :src="!live? audioUrl: undefined"
14
+ :src="!live? audioUrlToPlay: undefined"
15
15
  autoplay
16
16
  @timeupdate="onTimeUpdate"
17
17
  @ended="onFinished"
@@ -82,6 +82,7 @@ export default defineComponent({
82
82
  comments: [] as Array<CommentPodcast>,
83
83
  showTimeline: false as boolean,
84
84
  largeVersion: false as boolean,
85
+ audioUrlToPlay: "" as string
85
86
  };
86
87
  },
87
88
  computed: {
@@ -100,11 +100,15 @@ export const playerLive = defineComponent({
100
100
  },
101
101
  async endListeningProgress(): Promise<void> {
102
102
  if (!this.downloadId) return;
103
- await octopusApi.updatePlayerTime(
104
- this.downloadId,
105
- Math.round(this.listenTime)
106
- );
107
- this.setDownloadId(null);
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;
108
112
  this.notListenTime = 0;
109
113
  this.lastSend = 0;
110
114
  this.listenTime = 0;
@@ -23,6 +23,7 @@ export const playerLogic = defineComponent({
23
23
  hlsReady: false as boolean,
24
24
  comments: [] as Array<CommentPodcast>,
25
25
  showTimeline: false as boolean,
26
+ audioUrlToPlay: "" as string
26
27
  };
27
28
  },
28
29
  computed: {
@@ -44,8 +45,15 @@ export const playerLogic = defineComponent({
44
45
  },
45
46
 
46
47
  watch: {
47
- audioUrl(): void{
48
+ async audioUrl(): Promise<void>{
48
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;
49
57
  },
50
58
  podcast: {
51
59
  deep: true,
@@ -88,6 +96,14 @@ export const playerLogic = defineComponent({
88
96
  },
89
97
 
90
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
+ },
91
107
  getAudioUrl(): string{
92
108
  if (this.media) return this.media.audioUrl? this.media.audioUrl:"";
93
109
  if (!this.podcast) return '';
@@ -96,7 +112,6 @@ export const playerLogic = defineComponent({
96
112
  if (this.listenError) return this.podcast.audioStorageUrl;
97
113
  const parameters = [];
98
114
  parameters.push('origin=octopus');
99
- parameters.push('cookieName=player_' + this.podcast.podcastId);
100
115
  parameters.push('listenerId='+this.getListenerId());
101
116
  if (
102
117
  this.$store.state.authentication &&
@@ -109,7 +124,7 @@ export const playerLogic = defineComponent({
109
124
  if("SECURED" === this.podcast.organisation.privacy && this.$store.state.authentication.isAuthenticated && this.$store.state.oAuthParam.accessToken){
110
125
  parameters.push('access_token='+this.$store.state.oAuthParam.accessToken);
111
126
  }
112
- return this.podcast.audioUrl + '?' + parameters.join('&');
127
+ return this.podcast.podcastId + '.mp3?' + parameters.join('&');
113
128
  },
114
129
  reInitPlayer():void{
115
130
  this.setDownloadId(null);
@@ -123,12 +138,7 @@ export const playerLogic = defineComponent({
123
138
  let listenerId = this.getCookie("octopus_listenerId");
124
139
  if(!listenerId){
125
140
  listenerId = new Date().valueOf().toString() + Math.random();
126
- let domain = "";
127
- const domainArray: RegExpExecArray | null = /\.(.+)/.exec(window.location.host);
128
- if(domainArray && null !== domainArray){
129
- domain = domainArray[1];
130
- }
131
- this.setCookie("octopus_listenerId", listenerId, ';domain='+domain);
141
+ this.setCookie("octopus_listenerId", listenerId, ';domain='+this.getDomain());
132
142
  }
133
143
  return listenerId;
134
144
  },
@@ -153,9 +163,9 @@ export const playerLogic = defineComponent({
153
163
  );
154
164
  },
155
165
  onError(): void {
156
- if (this.podcast && !this.listenError) {
166
+ if (this.podcast && ""!==this.audioUrlToPlay && !this.listenError) {
157
167
  this.listenError = true;
158
- } else if (this.podcast || this.media) {
168
+ } else if ((this.podcast && ""!==this.audioUrlToPlay ) || this.media) {
159
169
  this.playerError = true;
160
170
  }
161
171
  },
@@ -163,7 +173,7 @@ export const playerLogic = defineComponent({
163
173
  const mediaTarget = (event.currentTarget as HTMLMediaElement);
164
174
  if (this.podcast || this.live) {
165
175
  if (!this.downloadId) {
166
- this.loadDownloadId();
176
+ return;
167
177
  }
168
178
  if (
169
179
  this.live &&
@@ -214,21 +224,5 @@ export const playerLogic = defineComponent({
214
224
  }
215
225
  this.forceHide = true;
216
226
  },
217
- loadDownloadId(): void {
218
- if (!this.podcast) return;
219
- const matching_cookies = document.cookie
220
- .split(';')
221
- .map(item => {
222
- const _return = item.trim().split('=');
223
- return _return.map(item => item.trim());
224
- })
225
- .filter(item => {
226
- if(!this.podcast){return '';}
227
- return 'player_' + this.podcast.podcastId === item[0];
228
- });
229
- if (1 === matching_cookies.length) {
230
- this.setDownloadId(matching_cookies[0][1]);
231
- }
232
- },
233
227
  },
234
228
  })