@uncinc/uncinc-react-kitchen-sink 2.20.10 → 2.20.11

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.
@@ -8,10 +8,12 @@ import React, { useEffect, useMemo } from 'react';
8
8
  import c from 'classnames';
9
9
  import { useVideoJS } from 'react-hook-videojs';
10
10
  import { useTranslation } from 'react-i18next';
11
+ import VideoJSTypes from 'video.js';
11
12
  import 'video.js/dist/video-js.css';
12
13
  import './style.scss';
13
14
  var MediaPlayer = function MediaPlayer(_ref) {
14
15
  var src = _ref.src,
16
+ altVideoSrc = _ref.altVideoSrc,
15
17
  type = _ref.type,
16
18
  controls = _ref.controls,
17
19
  posterUrl = _ref.posterUrl,
@@ -44,6 +46,7 @@ var MediaPlayer = function MediaPlayer(_ref) {
44
46
  duration: 'durationDisplay',
45
47
  seekbar: 'progressControl',
46
48
  captions: 'subsCapsButton',
49
+ audioDescription: 'audioTrackButton',
47
50
  volume: 'volumePanel',
48
51
  fullscreen: 'fullscreenToggle'
49
52
  };
@@ -96,6 +99,55 @@ var MediaPlayer = function MediaPlayer(_ref) {
96
99
  if (onReady) {
97
100
  onReady(player);
98
101
  }
102
+ if (altVideoSrc) {
103
+ var audioTracks = player.audioTracks();
104
+
105
+ // @ts-ignore
106
+ audioTracks.addTrack(new VideoJSTypes.AudioTrack({
107
+ id: 'main',
108
+ kind: 'main',
109
+ label: t('organisms.media_player.standard_audio'),
110
+ language: altVideoSrc.language,
111
+ enabled: true
112
+ }));
113
+
114
+ // @ts-ignore
115
+ audioTracks.addTrack(new VideoJSTypes.AudioTrack({
116
+ id: 'ad',
117
+ kind: 'alternative',
118
+ label: t('organisms.media_player.alt_audio'),
119
+ language: altVideoSrc.language,
120
+ enabled: false
121
+ }));
122
+
123
+ // Handle switching
124
+ audioTracks.on('change', function () {
125
+ var currentTime = player.currentTime();
126
+ var isPaused = player.paused();
127
+ var activeTrack = Array.from(audioTracks).find(function (track) {
128
+ return track.enabled;
129
+ });
130
+ if (!activeTrack) return;
131
+ if (activeTrack.id === 'ad') {
132
+ player.src({
133
+ src: altVideoSrc.src,
134
+ type: type
135
+ });
136
+ } else {
137
+ player.src({
138
+ src: src,
139
+ type: type
140
+ });
141
+ }
142
+ player.one('loadedmetadata', function () {
143
+ player.currentTime(currentTime);
144
+ if (!isPaused) {
145
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
146
+ player.play();
147
+ }
148
+ });
149
+ });
150
+ }
99
151
  if (autoPlay && onPlay) {
100
152
  player.one('play', function (event) {
101
153
  return onPlay(player, event);
@@ -1,12 +1,16 @@
1
1
  import type { VideoJsPlayer as NativeVideoJsPlayer, VideoJsPlayerOptions } from 'video.js';
2
2
  export type MimeType = 'audio/3gpp' | 'audio/aac' | 'audio/flac' | 'audio/mpeg' | 'audio/mp3' | 'audio/mp4' | 'audio/ogg' | 'audio/wav' | 'audio/webm' | 'video/3gpp' | 'video/mpeg' | 'video/mpeg' | 'video/mp4' | 'video/ogg' | 'video/quicktime' | 'video/webm' | 'video/youtube' | 'video/vimeo';
3
- export type Control = 'play' | 'currentTime' | 'timeDivider' | 'duration' | 'seekbar' | 'captions' | 'volume' | 'fullscreen';
3
+ export type Control = 'play' | 'currentTime' | 'timeDivider' | 'duration' | 'seekbar' | 'captions' | 'volume' | 'fullscreen' | 'audioDescription';
4
4
  export type VideoJSControls = {
5
5
  [K in Control]: string;
6
6
  };
7
7
  export type VideoJsPlayer = NativeVideoJsPlayer;
8
8
  export type MediaPlayerProps = {
9
9
  src: string;
10
+ altVideoSrc?: {
11
+ src: string;
12
+ language: string;
13
+ };
10
14
  type: MimeType;
11
15
  controls?: Control[] | false;
12
16
  posterUrl?: string;
@@ -34,7 +34,9 @@
34
34
  },
35
35
  "organisms": {
36
36
  "media_player": {
37
- "not_supported_message": "The current file cannot be played."
37
+ "not_supported_message": "The current file cannot be played.",
38
+ "standard_audio" : "Standard audio",
39
+ "alt_audio": "Alternative audio"
38
40
  },
39
41
  "text": {
40
42
  "read_more": "Read more",
@@ -72,7 +72,9 @@
72
72
  },
73
73
  "organisms": {
74
74
  "media_player": {
75
- "not_supported_message": "Het huidige bestand kan niet worden afgespeeld."
75
+ "not_supported_message": "Het huidige bestand kan niet worden afgespeeld.",
76
+ "standard_audio" : "Standaard audio",
77
+ "alt_audio": "Alternatieve audio"
76
78
  },
77
79
  "text": {
78
80
  "read_more": "Lees meer",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uncinc/uncinc-react-kitchen-sink",
3
- "version": "2.20.10",
3
+ "version": "2.20.11",
4
4
  "description": "Default React components that are easily extended.",
5
5
  "author": "uncinc",
6
6
  "license": "MIT",