@saooti/octopus-sdk 37.0.17 → 37.0.18

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": "37.0.17",
3
+ "version": "37.0.18",
4
4
  "private": false,
5
5
  "description": "Javascript SDK for using octopus",
6
6
  "author": "Saooti",
@@ -14,10 +14,8 @@
14
14
  "test": "jest --coverage"
15
15
  },
16
16
  "dependencies": {
17
- "@clappr/core": "0.4.27",
18
- "@clappr/hlsjs-playback": "^1.1.0",
19
17
  "@popperjs/core": "^2.11.8",
20
- "@saooti/octopus-api": "^0.34.3",
18
+ "@saooti/octopus-api": "^0.36.0",
21
19
  "@tiptap/extension-link": "^2.0.4",
22
20
  "@tiptap/extension-underline": "^2.0.4",
23
21
  "@tiptap/pm": "^2.0.4",
@@ -40,6 +38,9 @@
40
38
  "sass": "^1.63.6",
41
39
  "sonarqube-scanner": "^3.0.0",
42
40
  "swiper": "^10.0.4",
41
+ "video.js": "^7.21.5",
42
+ "videojs-contrib-quality-levels": "^2.2.1",
43
+ "videojs-hls-quality-selector": "^1.1.4",
43
44
  "vite": "^4.4.4",
44
45
  "vue": "^3.3.4",
45
46
  "vue-i18n": "^9.2.2",
@@ -50,6 +51,8 @@
50
51
  "vue3-swatches": "^1.2.3"
51
52
  },
52
53
  "devDependencies": {
54
+ "@types/videojs-contrib-quality-levels": "^2.0.1",
55
+ "@types/videojs-hls-quality-selector": "^1.1.0",
53
56
  "@types/vue-select": "^3.16.2",
54
57
  "@typescript-eslint/eslint-plugin": "^6.0.0",
55
58
  "@typescript-eslint/parser": "^6.0.0",
@@ -51,6 +51,15 @@
51
51
  :label="textNotValidate"
52
52
  />
53
53
  </div>
54
+ <ClassicCheckbox
55
+ v-if="!isEmission"
56
+ :textInit="onlyVideo"
57
+ class="flex-shrink-0 mt-3"
58
+ id-checkbox="only-video-checkbox"
59
+ :label="$t('Show only episodes with video')"
60
+ @update:textInit="$emit('update:onlyVideo', $event)"
61
+ />
62
+
54
63
  </div>
55
64
  <div class="d-flex flex-column">
56
65
  <div class="text-primary mb-2">
@@ -96,6 +105,7 @@ export default defineComponent({
96
105
  isEducation: { default: false, type: Boolean },
97
106
  includeHidden: { default: false, type: Boolean },
98
107
  sortCriteria: { default: "DATE", type: String },
108
+ onlyVideo: { default: false, type: Boolean },
99
109
  },
100
110
 
101
111
  emits: [
@@ -107,6 +117,7 @@ export default defineComponent({
107
117
  "includeHidden",
108
118
  "notValid",
109
119
  "updateRubriquageFilter",
120
+ "update:onlyVideo"
110
121
  ],
111
122
  data() {
112
123
  return {
@@ -60,7 +60,7 @@ export default defineComponent({
60
60
  <style lang="scss">
61
61
  .octopus-app {
62
62
  .video-wrapper{
63
- border-radius: 2rem;
63
+ border-radius: 1rem;
64
64
  overflow: hidden;
65
65
  position: fixed;
66
66
  bottom: 2.5rem;
@@ -1,23 +1,19 @@
1
1
  <template>
2
- <div class="video-player">
2
+ <div id="player-video-hls" class="video-player">
3
3
  <div v-if="errorPlay.length" class="video-live-error">{{errorPlay}}</div>
4
- <video
5
- v-show="useVideoSrc"
6
- ref="videoelement"
7
- playsinline
8
- />
9
- <div
10
- ref="videocontainer"
11
- class="video-container"
12
- />
4
+ <video id="video-element-hls" ref="videoelement" class="video-js" playsinline></video>
13
5
  </div>
14
6
  </template>
15
7
  <script lang="ts">
16
-
17
- // @ts-ignore
18
- import Clappr from '@clappr/core';
19
- // @ts-ignore
20
- import HlsjsPlayback from '@clappr/hlsjs-playback';
8
+ import videojs, { VideoJsPlayer } from 'video.js';
9
+ import qualitySelector from 'videojs-hls-quality-selector';
10
+ import qualityLevels from 'videojs-contrib-quality-levels';
11
+ if (!videojs.getPlugin('qualityLevels')) {
12
+ videojs.registerPlugin('qualityLevels', qualityLevels);
13
+ }
14
+ if (!videojs.getPlugin('hlsQualitySelector')) {
15
+ videojs.registerPlugin('hlsQualitySelector', qualitySelector);
16
+ }
21
17
  import { defineComponent } from 'vue';
22
18
  export default defineComponent({
23
19
  name: "PlayerVideoHls",
@@ -31,21 +27,44 @@ export default defineComponent({
31
27
  return {
32
28
  errorPlay: "" as string,
33
29
  useVideoSrc: false as boolean,
34
- player: undefined as Clappr.Player,
30
+ player: undefined as VideoJsPlayer|undefined,
35
31
  playing: false as boolean,
36
32
  stalledTimout: undefined as ReturnType<typeof setTimeout>|undefined,
37
33
  };
38
34
  },
39
35
  computed:{
40
- videoContainer(): HTMLElement{
41
- return (this.$refs.videocontainer as HTMLElement);
42
- },
43
36
  videoElement(): HTMLVideoElement{
44
37
  return (this.$refs.videoelement as HTMLVideoElement);
45
38
  },
39
+ videoOptions(){
40
+ return {
41
+ autoplay: true,
42
+ controls: true,
43
+ liveui: true,
44
+ sources: [
45
+ {
46
+ src: this.hlsUrl,
47
+ type: 'application/x-mpegURL',
48
+ }
49
+ ],
50
+ html5: {
51
+ vhs: {
52
+ overrideNative: !videojs.browser.IS_SAFARI,
53
+ },
54
+ nativeAudioTracks: false,
55
+ nativeVideoTracks: false,
56
+ },
57
+ plugins: {
58
+ hlsQualitySelector: {
59
+ displayCurrentQuality: true,
60
+ },
61
+ },
62
+ }
63
+ }
46
64
  },
47
65
  mounted(){
48
66
  this.playLive();
67
+ this.useVideoSrc = ""!==this.videoElement.canPlayType('application/vnd.apple.mpegurl') && !navigator.userAgent.includes('Android');
49
68
  },
50
69
 
51
70
  beforeUnmount() {
@@ -64,51 +83,26 @@ export default defineComponent({
64
83
  async playLive(): Promise<void> {
65
84
  clearTimeout(this.stalledTimout);
66
85
  this.definedStalledTimeout();
67
- if (this.videoElement.canPlayType('application/vnd.apple.mpegurl') && !navigator.userAgent.includes('Android')) {
68
- this.useVideoSrc = true;
86
+ if (this.useVideoSrc) {
69
87
  this.playLiveIos();
70
88
  return;
71
89
  }
72
- this.player = new Clappr.Player({
73
- source: this.hlsUrl,
74
- autoPlay: false,
75
- height: '100%',
76
- width: '100%',
77
- plugins: {
78
- playback: [HlsjsPlayback],
79
- },
80
- playback: {
81
- controls: true,
82
- playInline: true,
83
- hlsjsConfig: {
84
- enableWorker: false,
85
- debug:true,
86
- }
87
- },
88
- events: {
89
- onError: async(error: Clappr.error) =>{
90
- this.stopLive();
91
- if (error.description && error.description.includes('403')) {
92
- this.errorPlay = this.$t('Video is unavailable');
93
- }else{
94
- this.errorPlay = this.$t('Podcast play error');
95
- }
96
- },
97
- onPlay:()=>{
98
- this.errorPlay = "";
99
- this.playing = true;
100
- },
101
- onTimeUpdate:()=>{
102
- clearTimeout(this.stalledTimout);
103
- this.definedStalledTimeout();
104
- }
90
+ this.player = videojs((document.getElementById("video-element-hls") as Element), this.videoOptions, () => {
91
+ this.errorPlay = "";
92
+ this.playing = true;
93
+ });
94
+ this.player.on('timeupdate', () => {
95
+ clearTimeout(this.stalledTimout);
96
+ this.definedStalledTimeout();
97
+ });
98
+ this.player.on('error', (error) => {
99
+ this.stopLive();
100
+ if (error.description && error.description.includes('403')) {
101
+ this.errorPlay = this.$t('Video is unavailable');
102
+ }else{
103
+ this.errorPlay = this.$t('Podcast play error');
105
104
  }
106
105
  });
107
- this.playing = true;
108
- this.player.attachTo(this.videoContainer);
109
- if(0!==this.videoContainer.getElementsByTagName("video").length){
110
- this.videoContainer.getElementsByTagName("video")[0].play();
111
- }
112
106
  },
113
107
  async playLiveIos(): Promise<void>{
114
108
  this.videoElement.onloadedmetadata = ()=>{
@@ -140,7 +134,19 @@ export default defineComponent({
140
134
  this.videoElement.load();
141
135
  return;
142
136
  }
143
- this.player.destroy();
137
+ if(this.player){
138
+ this.player.dispose();
139
+ //Redraw
140
+ const video_parent = document.getElementById("player-video-hls");
141
+ if(video_parent){
142
+ const video = document.createElement('video');
143
+ video.id="video-element-hls";
144
+ video.className="video-js";
145
+ video.preload="auto";
146
+ video.setAttribute("playsinline","true");
147
+ video_parent.appendChild(video);
148
+ }
149
+ }
144
150
  },
145
151
  stopLive(): void{
146
152
  clearTimeout(this.stalledTimout);
@@ -154,6 +160,7 @@ export default defineComponent({
154
160
  </script>
155
161
 
156
162
  <style lang="scss">
163
+ @import 'video.js';
157
164
  @import "@scss/_variables.scss";
158
165
  .octopus-app{
159
166
  .video-live-error{
@@ -168,7 +175,7 @@ export default defineComponent({
168
175
  background: $danger;
169
176
  z-index: 1;
170
177
  }
171
- .video-container{
178
+ .video-js{
172
179
  width: 500px;
173
180
  height: 281px;
174
181
  }
@@ -5,6 +5,7 @@
5
5
  v-model:search-pattern="searchPattern"
6
6
  />
7
7
  <AdvancedSearch
8
+ v-model:only-video="onlyVideo"
8
9
  :is-education="isEducation"
9
10
  :is-emission="false"
10
11
  :reset-rubriquage="resetRubriquage"
@@ -79,6 +80,8 @@ export default defineComponent({
79
80
  noRubriquageId: [] as Array<number>,
80
81
  rubriquageId: [] as Array<number>,
81
82
  rubriqueId: [] as Array<number>,
83
+ //VIDEO_WORK
84
+ onlyVideo: false as boolean,
82
85
  };
83
86
  },
84
87
 
package/src/locale/fr.ts CHANGED
@@ -351,4 +351,7 @@ export default {
351
351
  "List":"Liste",
352
352
  "Display HTML":"Afficher HTML",
353
353
  "Video is unavailable":"La vidéo est indisponible",
354
+
355
+
356
+ "Show only episodes with video":"Afficher uniquement les épisodes avec une vidéo",
354
357
  };