@webitel/ui-sdk 1.0.25 → 1.0.28

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": "@webitel/ui-sdk",
3
- "version": "1.0.25",
3
+ "version": "1.0.28",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve-lib": "vue-cli-service serve",
@@ -33,7 +33,7 @@ export default {
33
33
  border-radius: 50%;
34
34
 
35
35
  &--outside {
36
- transform: translate(-100%, -100%);
36
+ transform: translate(100%, -100%);
37
37
  }
38
38
  }
39
39
  </style>
@@ -1,13 +1,14 @@
1
1
  <template>
2
2
  <aside class="wt-player">
3
- <audio
4
- id="wt-player__player"
5
- ref="audio"
3
+ <component
4
+ :is="playerType"
5
+ class="wt-player__player"
6
+ ref="player"
6
7
  :src="src"
7
8
  :autoplay="autoplay"
8
9
  controls
9
10
  v-on="listeners"
10
- ></audio>
11
+ ></component>
11
12
 
12
13
  <!-- The "wt-icon-btn" component is append in to "audio" element by "setCloseIcon" method-->
13
14
  <wt-icon-btn
@@ -38,6 +39,24 @@ export default {
38
39
  type: [String, Function, Boolean],
39
40
  default: () => (url) => url.replace('/stream', '/download'),
40
41
  },
42
+ mime: {
43
+ type: String,
44
+ default: 'audio',
45
+ },
46
+ // plyr-specific options
47
+ resetOnEnd: {
48
+ type: Boolean,
49
+ default: false,
50
+ },
51
+ invertTime: {
52
+ type: Boolean,
53
+ default: true,
54
+ },
55
+ // plyr is caching volume settings so we should reset them at init
56
+ resetVolume: {
57
+ type: Boolean,
58
+ default: false,
59
+ },
41
60
  },
42
61
  data: () => ({
43
62
  player: null,
@@ -62,26 +81,42 @@ export default {
62
81
  ...this.$listeners,
63
82
  };
64
83
  },
84
+ playerType() {
85
+ return this.mime.includes('video') ? 'video' : 'audio';
86
+ },
65
87
  },
66
88
 
67
89
  methods: {
68
- setupPlayer() {
90
+ async setupPlayer() {
91
+ await this.$nextTick(); // test is failing to render component if element is passed to Plyr as Vue $ref
69
92
  const baseURL = this.$baseURL || process.env.BASE_URL;
70
- if (this.player) this.player.restart();
93
+ if (this.player) this.player.destroy();
71
94
  const controls = ['play-large', 'play', 'progress', 'current-time',
72
95
  'mute', 'volume', 'captions', 'settings', 'pip',
73
96
  'airplay', 'fullscreen'];
74
97
  if (this.download) controls.push('download');
75
- this.player = new Plyr('#wt-player__player', {
98
+ this.player = new Plyr(this.$refs.player, {
99
+ // this.player = new Plyr('.wt-player__player', {
76
100
  autoplay: this.autoplay,
77
101
  loadSprite: false,
102
+ resetOnEnd: this.resetOnEnd,
103
+ invertTime: this.invertTime,
78
104
  iconUrl: `${baseURL}img/plyr.svg`,
79
105
  controls,
80
106
  loop: {
81
107
  active: this.loop,
82
108
  },
83
109
  });
110
+
111
+ if (this.resetVolume) this.makeVolumeReset();
112
+ if (this.download) this.setupDownload();
113
+
84
114
  this.appendCloseIcon();
115
+ this.$emit('initialized', this.player);
116
+ },
117
+ makeVolumeReset() {
118
+ this.player.volume = 1;
119
+ this.player.muted = false;
85
120
  },
86
121
  setupDownload() {
87
122
  if (!this.download) this.setupPlayer();
@@ -92,7 +127,7 @@ export default {
92
127
  }
93
128
  },
94
129
  appendCloseIcon() {
95
- const plyrControls = this.$refs.audio.plyr?.elements?.controls;
130
+ const plyrControls = this.$refs.player.plyr?.elements?.controls;
96
131
  const closeIcon = this.$refs['close-icon'].$el;
97
132
  if (plyrControls) {
98
133
  plyrControls.append(closeIcon);
@@ -111,6 +146,7 @@ export default {
111
146
  bottom: 60px;
112
147
 
113
148
  .plyr {
149
+ max-width: 100%; // prevents <video> container overflow
114
150
  border-radius: var(--border-radius);
115
151
  box-shadow: var(--box-shadow);
116
152
  }
@@ -125,6 +161,10 @@ export default {
125
161
  color: var(--text-primary-color);
126
162
  }
127
163
 
164
+ .plyr__control--overlaid svg {
165
+ left: 0; // reset plyr style for video "play" button icon
166
+ }
167
+
128
168
  //.plyr__control[role='menuitemradio']::before,
129
169
  //.plyr__control[role='menuitemradio']:hover::before {
130
170
  // border: 2px solid var(--secondary-color);