@desynova-digital/player 3.9.7 → 4.0.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.
Files changed (130) hide show
  1. package/Player.js +945 -0
  2. package/control/AudioTracksMenuButton.js +91 -0
  3. package/control/AudioTracksMenuButton.jsx +80 -0
  4. package/control/ControlBar.js +303 -0
  5. package/control/ControlBar.jsx +264 -0
  6. package/control/CurrentTimeDisplay.js +34 -0
  7. package/control/CurrentTimeDisplay.jsx +35 -0
  8. package/control/DurationDisplay.js +38 -0
  9. package/control/DurationDisplay.jsx +48 -0
  10. package/control/ForwardBackwardControl.js +76 -0
  11. package/control/ForwardBackwardControl.jsx +79 -0
  12. package/control/FullscreenToggle.js +82 -0
  13. package/control/FullscreenToggle.jsx +83 -0
  14. package/control/MarkInControl.js +124 -0
  15. package/control/MarkInControl.jsx +109 -0
  16. package/control/MarkOutControl.js +137 -0
  17. package/control/MarkOutControl.jsx +131 -0
  18. package/control/MarkerBar.js +127 -0
  19. package/control/MarkerBar.jsx +107 -0
  20. package/control/MarkingControl.js +82 -0
  21. package/control/MarkingControl.jsx +143 -0
  22. package/control/MarkingDuration.js +44 -0
  23. package/control/MarkingPreview.js +49 -0
  24. package/control/MarkingPreview.jsx +60 -0
  25. package/control/PlayBackRateControl.js +106 -0
  26. package/control/PlayBackRateControl.jsx +106 -0
  27. package/control/PlayProgressBar.js +61 -0
  28. package/control/PlayProgressBar.jsx +92 -0
  29. package/control/PlayToggle.js +56 -0
  30. package/control/PlayToggle.jsx +57 -0
  31. package/control/PointersBar.js +231 -0
  32. package/control/PointersBar.jsx +286 -0
  33. package/control/ProgressControl.js +127 -0
  34. package/control/ProgressControl.jsx +155 -0
  35. package/control/SeekBar.js +204 -0
  36. package/control/SeekBar.jsx +229 -0
  37. package/control/SettingsMenuButton.js +63 -0
  38. package/control/SettingsMenuButton.jsx +69 -0
  39. package/control/Slider.js +274 -0
  40. package/control/Slider.jsx +243 -0
  41. package/control/Timeline.js +118 -0
  42. package/control/Timeline.jsx +131 -0
  43. package/control/VolumeBar.js +198 -0
  44. package/control/VolumeBar.jsx +174 -0
  45. package/control/VolumeLevel.js +61 -0
  46. package/control/VolumeLevel.jsx +66 -0
  47. package/control/VolumneMenuButton.js +112 -0
  48. package/control/VolumneMenuButton.jsx +111 -0
  49. package/header/Header.js +309 -0
  50. package/header/Header.jsx +479 -0
  51. package/index.js +9 -151
  52. package/media/AudioMeter.js +381 -0
  53. package/media/AudioMeter.jsx +411 -0
  54. package/media/SDOutline.js +82 -0
  55. package/media/SDOutline.jsx +90 -0
  56. package/media/Video.js +684 -0
  57. package/media/Video.jsx +714 -0
  58. package/package.json +5 -1
  59. package/playlist/Playlist.js +67 -0
  60. package/playlist/Playlist.jsx +91 -0
  61. package/playlist/index.js +13 -0
  62. package/shortcuts/Shortcut.js +662 -0
  63. package/utils/Menu.js +50 -0
  64. package/utils/Menu.jsx +105 -0
  65. package/{colors.js → utils/colors.js} +13 -13
  66. package/utils/dom.js +6 -16
  67. package/utils/index.js +52 -122
  68. package/Manager.js +0 -124
  69. package/actions/player.js +0 -375
  70. package/actions/video.js +0 -230
  71. package/components/AudioMeter.js +0 -414
  72. package/components/BigPlayButton.js +0 -110
  73. package/components/ImageViewer.js +0 -318
  74. package/components/MarkerBar.js +0 -138
  75. package/components/Menu.js +0 -77
  76. package/components/Player.js +0 -821
  77. package/components/PlayerHeader.js +0 -472
  78. package/components/Playlist.js +0 -133
  79. package/components/PointersBar.js +0 -299
  80. package/components/PosterImage.js +0 -61
  81. package/components/SDOutline.js +0 -68
  82. package/components/Shortcut.js +0 -621
  83. package/components/Slider.js +0 -317
  84. package/components/TagsBar.js +0 -100
  85. package/components/Video.js +0 -1431
  86. package/components/control-bar/AudioTracksMenuButton.js +0 -113
  87. package/components/control-bar/CameraButton.js +0 -88
  88. package/components/control-bar/CommentsButton.js +0 -216
  89. package/components/control-bar/ControlBar.js +0 -260
  90. package/components/control-bar/EditorControlMenuButton.js +0 -412
  91. package/components/control-bar/ForwardControl.js +0 -17
  92. package/components/control-bar/ForwardReplayControl.js +0 -122
  93. package/components/control-bar/FullscreenToggle.js +0 -101
  94. package/components/control-bar/PlayToggle.js +0 -98
  95. package/components/control-bar/ReplayControl.js +0 -17
  96. package/components/control-bar/SettingsMenuButton.js +0 -43
  97. package/components/control-bar/SubtitleLanguagesMenuButton.js +0 -174
  98. package/components/control-bar/VolumeMenuButton.js +0 -134
  99. package/components/control-bar/ZoomMenuButton.js +0 -116
  100. package/components/marking-controls/MarkInControl.js +0 -140
  101. package/components/marking-controls/MarkOutControl.js +0 -155
  102. package/components/marking-controls/MarkingAddButton.js +0 -94
  103. package/components/marking-controls/MarkingControl.js +0 -135
  104. package/components/marking-controls/MarkingDeleteButton.js +0 -84
  105. package/components/marking-controls/MarkingDuration.js +0 -77
  106. package/components/marking-controls/MarkingPreview.js +0 -86
  107. package/components/progress-bar/AudioWaveform.js +0 -144
  108. package/components/progress-bar/LoadProgressBar.js +0 -90
  109. package/components/progress-bar/MouseTimeDisplay.js +0 -53
  110. package/components/progress-bar/PlayProgressBar.js +0 -79
  111. package/components/progress-bar/ProgressControl.js +0 -222
  112. package/components/progress-bar/SeekBar.js +0 -261
  113. package/components/progress-bar/Timeline.js +0 -134
  114. package/components/settings-menu-control/PlaybackRateControl.js +0 -147
  115. package/components/settings-menu-control/SafeAreaControl.js +0 -92
  116. package/components/settings-menu-control/SettingsMenu.js +0 -68
  117. package/components/settings-menu-control/SubtitleControl.js +0 -1
  118. package/components/time-controls/CurrentTimeDisplay.js +0 -53
  119. package/components/time-controls/DurationDisplay.js +0 -51
  120. package/components/time-controls/TimeDivider.js +0 -41
  121. package/components/volume-control/VolumeBar.js +0 -216
  122. package/components/volume-control/VolumeControl.js +0 -35
  123. package/components/volume-control/VolumeLevel.js +0 -78
  124. package/components/zoom-control/ZoomBar.js +0 -189
  125. package/components/zoom-control/ZoomLevel.js +0 -68
  126. package/reducers/index.js +0 -23
  127. package/reducers/operation.js +0 -36
  128. package/reducers/player.js +0 -222
  129. package/utils/browser.js +0 -29
  130. package/utils/fullscreen.js +0 -73
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactDom = require("react-dom");
10
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
11
+ var _propTypes = require("prop-types");
12
+ var _components = require("@desynova-digital/components");
13
+ var _utils = require("../utils");
14
+ var _templateObject;
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
20
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
21
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
22
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
23
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
24
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
25
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
26
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
27
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
28
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
29
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
30
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
31
+ var propTypes = {
32
+ player: _propTypes.PropTypes.instanceOf(Object),
33
+ initialTime: _propTypes.PropTypes.number,
34
+ frameRate: _propTypes.PropTypes.number
35
+ };
36
+ var TimelineBlock = _styledComponents["default"].div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n justify-content: space-between;\n align-items: stretch;\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0px;\n left: 0;\n .player-time {\n width: 100%;\n position: relative;\n height: 46px;\n user-select: none;\n &:first-child {\n p {\n left: 0px;\n }\n }\n &:last-child {\n width: 10px;\n ", " {\n display: none;\n }\n p {\n left: auto;\n right: 0px;\n }\n }\n ", " {\n position: absolute;\n left: 0;\n bottom: 0;\n }\n p {\n color: #aaa;\n font-size: 10px;\n font-family: SFUIText-Regular;\n left: -28px;\n top: 10px;\n letter-spacing: 0.5px;\n position: absolute;\n user-select: none;\n }\n }\n"])), _components.Icon.Element, _components.Icon.Element);
37
+ var Timeline = /*#__PURE__*/function (_Component) {
38
+ _inherits(Timeline, _Component);
39
+ var _super = _createSuper(Timeline);
40
+ function Timeline(props, context) {
41
+ var _this;
42
+ _classCallCheck(this, Timeline);
43
+ _this = _super.call(this, props, context);
44
+ _this.state = {
45
+ timeArray: []
46
+ };
47
+ _this.generateTimeline = _this.generateTimeline.bind(_assertThisInitialized(_this));
48
+ return _this;
49
+ }
50
+ _createClass(Timeline, [{
51
+ key: "componentDidMount",
52
+ value: function componentDidMount() {
53
+ this.generateTimeline();
54
+ }
55
+ }, {
56
+ key: "componentDidUpdate",
57
+ value: function componentDidUpdate(prevProps, prevState) {
58
+ var _prevProps$duration, _this$props$duration;
59
+ if (((_prevProps$duration = prevProps.duration) === null || _prevProps$duration === void 0 ? void 0 : _prevProps$duration.seconds) !== ((_this$props$duration = this.props.duration) === null || _this$props$duration === void 0 ? void 0 : _this$props$duration.seconds)) {
60
+ this.generateTimeline();
61
+ }
62
+ }
63
+ }, {
64
+ key: "generateTimeline",
65
+ value: function generateTimeline() {
66
+ var seconds = this.props.duration.seconds;
67
+ var timelineBlock = (0, _reactDom.findDOMNode)(this.timelineBlock);
68
+ var perTimeWidth = 100;
69
+ var sliderWidth = timelineBlock.offsetWidth;
70
+ var timeBlocks = parseInt(sliderWidth / perTimeWidth, 10);
71
+ var timeDistance = parseInt(seconds / timeBlocks, 10);
72
+ var timeArray = [0];
73
+ for (var i = 0; i < timeBlocks; i++) {
74
+ var lastValue = timeArray[timeArray.length - 1];
75
+ var currentTime = lastValue + timeDistance;
76
+ if (currentTime + timeDistance < seconds) {
77
+ timeArray.push(currentTime);
78
+ } else {
79
+ timeArray.push(seconds);
80
+ break;
81
+ }
82
+ }
83
+ this.setState({
84
+ timeArray: timeArray
85
+ });
86
+ }
87
+ }, {
88
+ key: "render",
89
+ value: function render() {
90
+ var _this2 = this;
91
+ var _this$props = this.props,
92
+ initialTime = _this$props.initialTime,
93
+ frameRate = _this$props.frameRate;
94
+ var timeArray = this.state.timeArray;
95
+ return /*#__PURE__*/_react["default"].createElement(TimelineBlock, {
96
+ ref: function ref(c) {
97
+ _this2.timelineBlock = c;
98
+ }
99
+ }, timeArray.map(function (time) {
100
+ var formattedTime = (0, _utils.secondsToTime)(time, frameRate, initialTime);
101
+ return /*#__PURE__*/_react["default"].createElement("div", {
102
+ className: "player-time",
103
+ ref: function ref(c) {
104
+ _this2.timelineContainer = c;
105
+ },
106
+ key: time
107
+ }, /*#__PURE__*/_react["default"].createElement("p", null, formattedTime), /*#__PURE__*/_react["default"].createElement(_components.Icon, {
108
+ name: "timeline",
109
+ stroke: "#aaa"
110
+ }));
111
+ }));
112
+ }
113
+ }]);
114
+ return Timeline;
115
+ }(_react.Component);
116
+ exports["default"] = Timeline;
117
+ Timeline.propTypes = propTypes;
118
+ Timeline.displayName = 'Timeline';
@@ -0,0 +1,131 @@
1
+ import React, { Component } from 'react';
2
+ import { findDOMNode } from 'react-dom';
3
+ import styled from 'styled-components';
4
+ import { PropTypes } from 'prop-types';
5
+ import { Icon } from '@desynova-digital/components';
6
+ import { secondsToTime } from '../utils';
7
+
8
+ const propTypes = {
9
+ player: PropTypes.instanceOf(Object),
10
+ initialTime: PropTypes.number,
11
+ frameRate: PropTypes.number
12
+ };
13
+
14
+ const TimelineBlock = styled.div`
15
+ display: flex;
16
+ justify-content: space-between;
17
+ align-items: stretch;
18
+ position: absolute;
19
+ width: 100%;
20
+ height: 100%;
21
+ top: 0px;
22
+ left: 0;
23
+ .player-time {
24
+ width: 100%;
25
+ position: relative;
26
+ height: 46px;
27
+ user-select: none;
28
+ &:first-child {
29
+ p {
30
+ left: 0px;
31
+ }
32
+ }
33
+ &:last-child {
34
+ width: 10px;
35
+ ${Icon.Element} {
36
+ display: none;
37
+ }
38
+ p {
39
+ left: auto;
40
+ right: 0px;
41
+ }
42
+ }
43
+ ${Icon.Element} {
44
+ position: absolute;
45
+ left: 0;
46
+ bottom: 0;
47
+ }
48
+ p {
49
+ color: #aaa;
50
+ font-size: 10px;
51
+ font-family: SFUIText-Regular;
52
+ left: -28px;
53
+ top: 10px;
54
+ letter-spacing: 0.5px;
55
+ position: absolute;
56
+ user-select: none;
57
+ }
58
+ }
59
+ `;
60
+
61
+ export default class Timeline extends Component {
62
+ constructor(props, context) {
63
+ super(props, context);
64
+ this.state = {
65
+ timeArray: []
66
+ };
67
+ this.generateTimeline = this.generateTimeline.bind(this);
68
+ }
69
+
70
+ componentDidMount() {
71
+ this.generateTimeline();
72
+ }
73
+
74
+ componentDidUpdate(prevProps, prevState) {
75
+ if (prevProps.duration?.seconds !== this.props.duration?.seconds) {
76
+ this.generateTimeline();
77
+ }
78
+ }
79
+
80
+ generateTimeline() {
81
+ const {
82
+ duration: { seconds }
83
+ } = this.props;
84
+ const timelineBlock = findDOMNode(this.timelineBlock);
85
+ const perTimeWidth = 100;
86
+ const sliderWidth = timelineBlock.offsetWidth;
87
+ const timeBlocks = parseInt(sliderWidth / perTimeWidth, 10);
88
+ const timeDistance = parseInt(seconds / timeBlocks, 10);
89
+ const timeArray = [0];
90
+ for (let i = 0; i < timeBlocks; i++) {
91
+ const lastValue = timeArray[timeArray.length - 1];
92
+ const currentTime = lastValue + timeDistance;
93
+ if (currentTime + timeDistance < seconds) {
94
+ timeArray.push(currentTime);
95
+ } else {
96
+ timeArray.push(seconds);
97
+ break;
98
+ }
99
+ }
100
+ this.setState({ timeArray });
101
+ }
102
+
103
+ render() {
104
+ const { initialTime, frameRate } = this.props;
105
+ const { timeArray } = this.state;
106
+ return (
107
+ <TimelineBlock
108
+ ref={(c) => {
109
+ this.timelineBlock = c;
110
+ }}>
111
+ {timeArray.map((time) => {
112
+ const formattedTime = secondsToTime(time, frameRate, initialTime);
113
+ return (
114
+ <div
115
+ className="player-time"
116
+ ref={(c) => {
117
+ this.timelineContainer = c;
118
+ }}
119
+ key={time}>
120
+ <p>{formattedTime}</p>
121
+ <Icon name="timeline" stroke="#aaa" />
122
+ </div>
123
+ );
124
+ })}
125
+ </TimelineBlock>
126
+ );
127
+ }
128
+ }
129
+
130
+ Timeline.propTypes = propTypes;
131
+ Timeline.displayName = 'Timeline';
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _propTypes = require("prop-types");
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
10
+ var _colors = _interopRequireDefault(require("../utils/colors"));
11
+ var _Slider = _interopRequireDefault(require("./Slider"));
12
+ var _templateObject, _templateObject2;
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
17
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
18
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
20
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
21
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
22
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
24
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
25
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
26
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
27
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
28
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
29
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
30
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
31
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
32
+ var propTypes = {
33
+ actions: _propTypes.PropTypes.instanceOf(Object),
34
+ player: _propTypes.PropTypes.instanceOf(Object),
35
+ vertical: _propTypes.PropTypes.bool,
36
+ onFocus: _propTypes.PropTypes.func,
37
+ onBlur: _propTypes.PropTypes.func
38
+ };
39
+ var defaultProps = _defineProperty({
40
+ actions: {},
41
+ player: {},
42
+ vertical: false,
43
+ onFocus: null,
44
+ onBlur: null,
45
+ percentage: '100%'
46
+ }, "vertical", false);
47
+ var VolumeControlBar = _styledComponents["default"].div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: 85%;\n position: absolute;\n cursor: pointer;\n z-index: 1;\n width: 2px;\n margin: 0 auto;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n"])));
48
+ var VolumeLevelBar = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n width: ", ";\n height: ", ";\n left: 0;\n top: ", ";\n bottom: ", ";\n background: ", ";\n &:after {\n content: '';\n width: 8px;\n height: 8px;\n position: absolute;\n background: ", ";\n border-radius: 100%;\n right: -3px;\n top: -4px;\n box-shadow: 0 0 14px 1px ", ";\n }\n"])), function (props) {
49
+ return props.vertical ? '100%' : '0px';
50
+ }, function (props) {
51
+ return props.vertical ? '0' : '100%';
52
+ }, function (props) {
53
+ return props.vertical ? 'initial' : '0px';
54
+ }, function (props) {
55
+ return props.vertical ? '0px' : 'initial';
56
+ }, function (props) {
57
+ return _colors["default"].common.video[props.assetType].base;
58
+ }, function (props) {
59
+ return _colors["default"].common.video[props.assetType].base;
60
+ }, function (props) {
61
+ return _colors["default"].common.video[props.assetType].base;
62
+ });
63
+ var VolumeBar = /*#__PURE__*/function (_Component) {
64
+ _inherits(VolumeBar, _Component);
65
+ var _super = _createSuper(VolumeBar);
66
+ function VolumeBar(props, context) {
67
+ var _this;
68
+ _classCallCheck(this, VolumeBar);
69
+ _this = _super.call(this, props, context);
70
+ _this.state = {
71
+ percentage: '0%'
72
+ };
73
+ _this.handleMouseMove = _this.handleMouseMove.bind(_assertThisInitialized(_this));
74
+ _this.handlePercentageChange = _this.handlePercentageChange.bind(_assertThisInitialized(_this));
75
+ _this.checkMuted = _this.checkMuted.bind(_assertThisInitialized(_this));
76
+ _this.getPercent = _this.getPercent.bind(_assertThisInitialized(_this));
77
+ _this.stepForward = _this.stepForward.bind(_assertThisInitialized(_this));
78
+ _this.stepBack = _this.stepBack.bind(_assertThisInitialized(_this));
79
+ // this.handleFocus = this.handleFocus.bind(this);
80
+ // this.handleBlur = this.handleBlur.bind(this);
81
+ _this.handleClick = _this.handleClick.bind(_assertThisInitialized(_this));
82
+ return _this;
83
+ }
84
+ _createClass(VolumeBar, [{
85
+ key: "componentDidMount",
86
+ value: function componentDidMount() {}
87
+ }, {
88
+ key: "getPercent",
89
+ value: function getPercent() {
90
+ var _this$props = this.props,
91
+ muted = _this$props.muted,
92
+ volume = _this$props.volume;
93
+ if (muted) {
94
+ return 0;
95
+ }
96
+ return volume;
97
+ }
98
+ }, {
99
+ key: "checkMuted",
100
+ value: function checkMuted() {
101
+ var _this$props2 = this.props,
102
+ actionClick = _this$props2.actionClick,
103
+ muted = _this$props2.muted;
104
+ if (muted) {
105
+ actionClick({
106
+ action: 'mute',
107
+ value: false
108
+ });
109
+ }
110
+ }
111
+ }, {
112
+ key: "handleMouseMove",
113
+ value: function handleMouseMove(event) {
114
+ var actionClick = this.props.actionClick;
115
+ this.checkMuted();
116
+ var distance = this.slider.calculateDistance(event);
117
+ actionClick({
118
+ action: 'volume',
119
+ value: distance
120
+ });
121
+ }
122
+ }, {
123
+ key: "stepForward",
124
+ value: function stepForward() {
125
+ var volume = this.props.volume;
126
+ this.checkMuted();
127
+ actions.changeVolume(volume + 0.1);
128
+ }
129
+ }, {
130
+ key: "stepBack",
131
+ value: function stepBack() {
132
+ var volume = this.props.volume;
133
+ this.checkMuted();
134
+ actions.changeVolume(volume - 0.1);
135
+ }
136
+ }, {
137
+ key: "handlePercentageChange",
138
+ value: function handlePercentageChange(percent) {
139
+ var percentage = this.state.percentage;
140
+ if (percent !== percentage) {
141
+ this.setState({
142
+ percentage: percent
143
+ });
144
+ }
145
+ }
146
+ }, {
147
+ key: "handleClick",
148
+ value: function handleClick(event) {
149
+ event.stopPropagation();
150
+ }
151
+ }, {
152
+ key: "render",
153
+ value: function render() {
154
+ var _this2 = this;
155
+ var _this$props3 = this.props,
156
+ vertical = _this$props3.vertical,
157
+ assetType = _this$props3.assetType,
158
+ playerType = _this$props3.playerType,
159
+ volume = _this$props3.volume;
160
+ var style = {};
161
+ if (vertical) {
162
+ style.height = this.getPercent() * 100;
163
+ } else {
164
+ style.width = this.getPercent() * 100;
165
+ }
166
+ var volumeData = (volume * 100).toFixed(2);
167
+ return /*#__PURE__*/_react["default"].createElement(VolumeControlBar, null, /*#__PURE__*/_react["default"].createElement(_Slider["default"], _extends({
168
+ ref: function ref(c) {
169
+ _this2.slider = c;
170
+ },
171
+ label: "volume level",
172
+ valuenow: volumeData,
173
+ valuetext: "".concat(volumeData, "%"),
174
+ onMouseMove: this.handleMouseMove,
175
+ onFocus: this.handleFocus,
176
+ onBlur: this.handleBlur,
177
+ onClick: this.handleClick,
178
+ sliderActive: this.handleFocus,
179
+ sliderInactive: this.handleBlur,
180
+ getPercent: this.getPercent,
181
+ onPercentageChange: this.handlePercentageChange,
182
+ stepForward: this.stepForward,
183
+ stepBack: this.stepBack
184
+ }, this.props), /*#__PURE__*/_react["default"].createElement(VolumeLevelBar, {
185
+ style: style,
186
+ assetType: assetType,
187
+ playerType: playerType,
188
+ vertical: vertical
189
+ })));
190
+ }
191
+ }]);
192
+ return VolumeBar;
193
+ }(_react.Component);
194
+ VolumeBar.propTypes = propTypes;
195
+ VolumeBar.defaultProps = defaultProps;
196
+ VolumeBar.displayName = 'VolumeBar';
197
+ var _default = VolumeBar;
198
+ exports["default"] = _default;
@@ -0,0 +1,174 @@
1
+ import { PropTypes } from 'prop-types';
2
+ import React, { Component } from 'react';
3
+ import styled from 'styled-components';
4
+ // import VolumeLevel from './VolumeLevel';
5
+ import colors from '../utils/colors';
6
+ import Slider from './Slider';
7
+
8
+ const propTypes = {
9
+ actions: PropTypes.instanceOf(Object),
10
+ player: PropTypes.instanceOf(Object),
11
+ vertical: PropTypes.bool,
12
+ onFocus: PropTypes.func,
13
+ onBlur: PropTypes.func
14
+ };
15
+
16
+ const defaultProps = {
17
+ actions: {},
18
+ player: {},
19
+ vertical: false,
20
+ onFocus: null,
21
+ onBlur: null,
22
+ percentage: '100%',
23
+ vertical: false
24
+ };
25
+
26
+ const VolumeControlBar = styled.div`
27
+ height: 85%;
28
+ position: absolute;
29
+ cursor: pointer;
30
+ z-index: 1;
31
+ width: 2px;
32
+ margin: 0 auto;
33
+ top: 50%;
34
+ left: 50%;
35
+ transform: translate(-50%, -50%);
36
+ `;
37
+
38
+ const VolumeLevelBar = styled.div`
39
+ position: absolute;
40
+ width: ${(props) => (props.vertical ? '100%' : '0px')};
41
+ height: ${(props) => (props.vertical ? '0' : '100%')};
42
+ left: 0;
43
+ top: ${(props) => (props.vertical ? 'initial' : '0px')};
44
+ bottom: ${(props) => (props.vertical ? '0px' : 'initial')};
45
+ background: ${(props) => colors.common.video[props.assetType].base};
46
+ &:after {
47
+ content: '';
48
+ width: 8px;
49
+ height: 8px;
50
+ position: absolute;
51
+ background: ${(props) => colors.common.video[props.assetType].base};
52
+ border-radius: 100%;
53
+ right: -3px;
54
+ top: -4px;
55
+ box-shadow: 0 0 14px 1px ${(props) => colors.common.video[props.assetType].base};
56
+ }
57
+ `;
58
+
59
+ class VolumeBar extends Component {
60
+ constructor(props, context) {
61
+ super(props, context);
62
+
63
+ this.state = {
64
+ percentage: '0%'
65
+ };
66
+
67
+ this.handleMouseMove = this.handleMouseMove.bind(this);
68
+ this.handlePercentageChange = this.handlePercentageChange.bind(this);
69
+ this.checkMuted = this.checkMuted.bind(this);
70
+ this.getPercent = this.getPercent.bind(this);
71
+ this.stepForward = this.stepForward.bind(this);
72
+ this.stepBack = this.stepBack.bind(this);
73
+ // this.handleFocus = this.handleFocus.bind(this);
74
+ // this.handleBlur = this.handleBlur.bind(this);
75
+ this.handleClick = this.handleClick.bind(this);
76
+ }
77
+
78
+ componentDidMount() {}
79
+
80
+ getPercent() {
81
+ const { muted, volume } = this.props;
82
+ if (muted) {
83
+ return 0;
84
+ }
85
+ return volume;
86
+ }
87
+
88
+ checkMuted() {
89
+ const { actionClick, muted } = this.props;
90
+ if (muted) {
91
+ actionClick({
92
+ action: 'mute',
93
+ value: false
94
+ });
95
+ }
96
+ }
97
+
98
+ handleMouseMove(event) {
99
+ const { actionClick } = this.props;
100
+ this.checkMuted();
101
+ const distance = this.slider.calculateDistance(event);
102
+ actionClick({
103
+ action: 'volume',
104
+ value: distance
105
+ });
106
+ }
107
+
108
+ stepForward() {
109
+ const { volume } = this.props;
110
+ this.checkMuted();
111
+ actions.changeVolume(volume + 0.1);
112
+ }
113
+
114
+ stepBack() {
115
+ const { volume } = this.props;
116
+ this.checkMuted();
117
+ actions.changeVolume(volume - 0.1);
118
+ }
119
+
120
+ handlePercentageChange(percent) {
121
+ const { percentage } = this.state;
122
+ if (percent !== percentage) {
123
+ this.setState({
124
+ percentage: percent
125
+ });
126
+ }
127
+ }
128
+
129
+ handleClick(event) {
130
+ event.stopPropagation();
131
+ }
132
+
133
+ render() {
134
+ const { vertical, assetType, playerType, volume } = this.props;
135
+ const style = {};
136
+ if (vertical) {
137
+ style.height = this.getPercent() * 100;
138
+ } else {
139
+ style.width = this.getPercent() * 100;
140
+ }
141
+
142
+ const volumeData = (volume * 100).toFixed(2);
143
+ return (
144
+ <VolumeControlBar>
145
+ <Slider
146
+ ref={(c) => {
147
+ this.slider = c;
148
+ }}
149
+ label="volume level"
150
+ valuenow={volumeData}
151
+ valuetext={`${volumeData}%`}
152
+ onMouseMove={this.handleMouseMove}
153
+ onFocus={this.handleFocus}
154
+ onBlur={this.handleBlur}
155
+ onClick={this.handleClick}
156
+ sliderActive={this.handleFocus}
157
+ sliderInactive={this.handleBlur}
158
+ getPercent={this.getPercent}
159
+ onPercentageChange={this.handlePercentageChange}
160
+ stepForward={this.stepForward}
161
+ stepBack={this.stepBack}
162
+ {...this.props}>
163
+ <VolumeLevelBar style={style} assetType={assetType} playerType={playerType} vertical={vertical} />
164
+ </Slider>
165
+ </VolumeControlBar>
166
+ );
167
+ }
168
+ }
169
+
170
+ VolumeBar.propTypes = propTypes;
171
+ VolumeBar.defaultProps = defaultProps;
172
+ VolumeBar.displayName = 'VolumeBar';
173
+
174
+ export default VolumeBar;