@oat-sa/tao-core-ui 3.11.0 → 3.12.1

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.
@@ -20,6 +20,7 @@ import $ from 'jquery';
20
20
  import _ from 'lodash';
21
21
  import async from 'async';
22
22
  import UrlParser from 'util/urlParser';
23
+ import request from 'core/dataProvider/request';
23
24
  import eventifier from 'core/eventifier';
24
25
  import mimetype from 'core/mimetype';
25
26
  import store from 'core/store';
@@ -242,7 +243,6 @@ function mediaplayerFactory(config) {
242
243
  this.config.mimeType = this.config.type;
243
244
  }
244
245
  this._setType(this.config.type || defaults.type);
245
-
246
246
  this._reset();
247
247
  this._updateVolumeFromStore();
248
248
  this._initEvents();
@@ -260,6 +260,8 @@ function mediaplayerFactory(config) {
260
260
  _.defer(() => this.render());
261
261
  }
262
262
  });
263
+ this._initTranscription();
264
+ this._setMaxHeight();
263
265
 
264
266
  return this;
265
267
  },
@@ -926,6 +928,22 @@ function mediaplayerFactory(config) {
926
928
  this._setState('ready', false);
927
929
  },
928
930
 
931
+ async _initTranscription() {
932
+ if (this.config.transcriptionUrl) {
933
+ try {
934
+ const response = await request(this.config.transcriptionUrl);
935
+ if (response && response.value) {
936
+ this
937
+ .$component
938
+ .find('.transcription')
939
+ .replaceWith('<div class="transcription">' + response.value + '</div>');
940
+ }
941
+ } catch (error) {
942
+ console.log('Error fetching transcription metadata:', error);
943
+ }
944
+ }
945
+ },
946
+
929
947
  /**
930
948
  * Resets the internals attributes
931
949
  * @private
@@ -1264,9 +1282,7 @@ function mediaplayerFactory(config) {
1264
1282
  this.play();
1265
1283
  }
1266
1284
 
1267
- if (this.config.preview && this.$container && this.config.height && this.config.height !== 'auto') {
1268
- this._setMaxHeight();
1269
- }
1285
+ this._setMaxHeight();
1270
1286
  },
1271
1287
 
1272
1288
  /**
@@ -1275,17 +1291,14 @@ function mediaplayerFactory(config) {
1275
1291
  * @private
1276
1292
  */
1277
1293
  _setMaxHeight() {
1278
- const $video = this.$container.find('video.video');
1279
- const controlsHeight = parseInt(window.getComputedStyle(this.$controls[0]).height);
1280
- const scale = $video.height() / this.config.height;
1281
- const playerWidth = this.$container.find('.player').width();
1282
- const videoWidth = $video.width() / scale;
1283
-
1284
- if (videoWidth > playerWidth) {
1285
- this.execute('setSize', '100%', 'auto');
1286
- } else {
1287
- this.$component.css({ maxHeight: `${this.config.height + controlsHeight}px` });
1288
- this.execute('setSize', Math.floor(videoWidth), 'auto');
1294
+ if (this.config.preview && this.$container && this.config.height && this.config.height !== 'auto') {
1295
+ const $video = this.$container.find('video.video');
1296
+ const scale = $video.height() / this.config.height;
1297
+ const playerWidth = this.$container.find('.player').width();
1298
+ const videoWidth = $video.width() / scale;
1299
+ if (videoWidth > playerWidth) {
1300
+ this.execute('setSize', '100%', 'auto');
1301
+ }
1289
1302
  }
1290
1303
  },
1291
1304
 
package/src/previewer.js CHANGED
@@ -202,8 +202,9 @@ const previewer = {
202
202
  url: options.url,
203
203
  type: options.mime,
204
204
  renderTo: $content,
205
+ transcriptionUrl: options.transcriptionUrl,
205
206
  width,
206
- height
207
+ height,
207
208
  })
208
209
  .on('ready', function() {
209
210
  /**
File without changes
File without changes
@@ -133,6 +133,12 @@ export default function (options) {
133
133
  }
134
134
  });
135
135
 
136
+ function injectTranscriptionMetadata(transcriptionUrl, metadataUri, resourceUri) {
137
+ return `${transcriptionUrl}?metadataUri=${encodeURIComponent(metadataUri)}&resourceUri=${
138
+ resourceUri.replace('taomedia://mediamanager/', '')
139
+ }`;
140
+ }
141
+
136
142
  //listen for file activation
137
143
  $(parentSelector)
138
144
  .off('click', '.files li')
@@ -144,7 +150,17 @@ export default function (options) {
144
150
  let $selected = $(this);
145
151
  let $files = $('.files > li', $fileSelector);
146
152
  let data = _.clone($selected.data());
147
-
153
+ if (
154
+ options.resourceMetadataUrl
155
+ && options.transcriptionMetadata
156
+ && data.file.includes('taomedia://mediamanager/')
157
+ ) {
158
+ data.transcriptionUrl = injectTranscriptionMetadata(
159
+ options.resourceMetadataUrl,
160
+ options.transcriptionMetadata,
161
+ data.file
162
+ );
163
+ }
148
164
  $files.removeClass('active');
149
165
  $selected.addClass('active');
150
166
  $container.trigger(`fileselect.${ns}`, [data]);
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes