@elice/material-video-file 1.220919.0 → 1.221026.0

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.
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
- import type { VideoPlayerProps } from '../video-player';
3
- declare type PickedVideoPlayerProps = Pick<VideoPlayerProps, 'videoNotUploadedPage' | 'autoPlay' | 'azureVideoPlayerUrl' | 'className' | 'isSupplement' | 'videoGetStatus' | 'videoTitle' | 'userId' | 'isLmsCourse' | 'lmsOrganizationBusinessType'>;
2
+ import type { MaterialVideoFilePlayerProps } from './MaterialVideoFilePlayer';
3
+ declare type PickedVideoPlayerProps = Pick<MaterialVideoFilePlayerProps, 'materialVideoFileTrackerDisabled' | 'mainLecturePageId' | 'lms' | 'lmsOrganizationBusinessType' | 'emptyComponent' | 'autoPlay' | 'autoPlayNext' | 'eliceVideoPlayerUrl' | 'onNavigatePreviousLecturePage' | 'onNavigateNextLecturePage'>;
4
4
  export interface MaterialVideoFileProps extends PickedVideoPlayerProps {
5
5
  materialVideoFileId: number;
6
+ className?: string;
6
7
  locale?: string;
7
8
  }
8
9
  declare const MaterialVideoFile: React.FC<MaterialVideoFileProps>;
@@ -4,11 +4,10 @@ var tslib = require('tslib');
4
4
  var React = require('react');
5
5
  var reactIntl = require('react-intl');
6
6
  var apiClient = require('@elice/api-client');
7
- var blocks = require('@elice/blocks');
8
7
  var materialSharedUtils = require('@elice/material-shared-utils');
9
8
  var classnames = require('classnames');
10
- var VideoPlayer = require('../video-player/VideoPlayer.js');
11
9
  var locales = require('./locales.js');
10
+ var MaterialVideoFilePlayer = require('./MaterialVideoFilePlayer.js');
12
11
  var MaterialVideoFile_styled = require('./MaterialVideoFile.styled.js');
13
12
 
14
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -17,14 +16,14 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
17
16
  var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
18
17
 
19
18
  const MaterialVideoFile = _a => {
20
- var _b;
19
+ var _b, _c, _d;
21
20
 
22
21
  var {
23
22
  materialVideoFileId,
24
23
  className,
25
24
  locale = 'en'
26
25
  } = _a,
27
- videoPlayerProps = tslib.__rest(_a, ["materialVideoFileId", "className", "locale"]);
26
+ playerProps = tslib.__rest(_a, ["materialVideoFileId", "className", "locale"]);
28
27
 
29
28
  const prefixCls = 'em-material-video-file';
30
29
  const {
@@ -34,27 +33,22 @@ const MaterialVideoFile = _a => {
34
33
  materialVideoFileId
35
34
  }, {
36
35
  signal
37
- }), [materialVideoFileId]));
38
-
39
- const makeOtpKey = async () => {
40
- return apiClient.postGlobalAuthOtpKeyMake().then(res => res.otpKey);
41
- }; //
36
+ }), [materialVideoFileId])); //
42
37
  //
43
38
  //
44
39
 
45
-
46
40
  return React__default["default"].createElement(MaterialVideoFile_styled.StyledMaterialVideoFileWrap, {
47
41
  className: classnames__default["default"](prefixCls, className)
48
42
  }, React__default["default"].createElement(reactIntl.IntlProvider, {
49
43
  locale: locale,
50
44
  defaultLocale: "en",
51
45
  messages: locale in locales ? locales[locale] : locales.en
52
- }, (materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.materialVideoFile) ? React__default["default"].createElement(VideoPlayer, Object.assign({}, videoPlayerProps, {
53
- material: (_b = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.materialVideoFile) !== null && _b !== void 0 ? _b : null,
46
+ }, React__default["default"].createElement(MaterialVideoFilePlayer, Object.assign({}, playerProps, {
54
47
  orgNameShort: orgNameShort,
55
- videoGetStatus: materialVideoFileStatus,
56
- onOtpRequest: makeOtpKey
57
- })) : React__default["default"].createElement(blocks.Spinner, null)));
48
+ materialVideoFile: (_b = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.materialVideoFile) !== null && _b !== void 0 ? _b : null,
49
+ materialVideoFileStatus: materialVideoFileStatus,
50
+ title: (_d = (_c = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.materialVideoFile.azureMediaVideo) === null || _c === void 0 ? void 0 : _c.videoAssetName) !== null && _d !== void 0 ? _d : undefined
51
+ }))));
58
52
  };
59
53
 
60
54
  module.exports = MaterialVideoFile;
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import type { APIStatus } from '@elice/material-shared-types';
3
+ import type { EliceVideoPlayerSearchParams, GetOrgMaterialVideoFileGetResponses } from '@elice/types';
4
+ export interface MaterialVideoFilePlayerProps {
5
+ /** Classname for the element. */
6
+ className?: string;
7
+ /** Material video file. */
8
+ materialVideoFile: null | GetOrgMaterialVideoFileGetResponses['materialVideoFile'];
9
+ /** Fetch status of material video file. */
10
+ materialVideoFileStatus?: APIStatus;
11
+ /** Disable material video file tracker. */
12
+ materialVideoFileTrackerDisabled?: EliceVideoPlayerSearchParams['notrack'];
13
+ /**
14
+ * Linked material (main lecture page) ID.
15
+ * If this is set, the material assumed as sub lecture page.
16
+ */
17
+ mainLecturePageId?: EliceVideoPlayerSearchParams['lmid'];
18
+ /** Organization name short. */
19
+ orgNameShort: EliceVideoPlayerSearchParams['org'];
20
+ /** Run in LMS env? */
21
+ lms?: EliceVideoPlayerSearchParams['lms'];
22
+ /** Type of LMS org business. */
23
+ lmsOrganizationBusinessType?: EliceVideoPlayerSearchParams['lmstype'];
24
+ /** Auto play. */
25
+ autoPlay?: EliceVideoPlayerSearchParams['autoplay'];
26
+ /** Auto play next lecture page. */
27
+ autoPlayNext?: EliceVideoPlayerSearchParams['autoplaynext'];
28
+ /** Locale. */
29
+ locale?: EliceVideoPlayerSearchParams['locale'];
30
+ /** Elice video player url. */
31
+ eliceVideoPlayerUrl?: string;
32
+ /** Empty component. */
33
+ emptyComponent: React.ReactNode;
34
+ /** Title of player. (set on iframe) */
35
+ title?: string;
36
+ /** Navigate to previous lecture page. */
37
+ onNavigatePreviousLecturePage?: () => void;
38
+ /** Navigate to next lecture page. */
39
+ onNavigateNextLecturePage?: () => void;
40
+ }
41
+ declare enum VideoMimeType {
42
+ /** `application/vnd.ms-sstr+xml` */
43
+ Smooth = "application/vnd.ms-sstr+xml",
44
+ /** `application/vnd.apple.mpegurl` */
45
+ Hls = "application/vnd.apple.mpegurl",
46
+ /** `application/dash+xml` */
47
+ Mpeg = "application/dash+xml"
48
+ }
49
+ declare const _default: React.FC<MaterialVideoFilePlayerProps> & {
50
+ MimeType: typeof VideoMimeType;
51
+ };
52
+ export default _default;
@@ -0,0 +1,177 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var reactIntl = require('react-intl');
5
+ var apiClient = require('@elice/api-client');
6
+ var blocks = require('@elice/blocks');
7
+ var types = require('@elice/types');
8
+ var classnames = require('classnames');
9
+ var MaterialVideoFilePlayer_styled = require('./MaterialVideoFilePlayer.styled.js');
10
+
11
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
+
13
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
14
+ var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
15
+
16
+ var VideoMimeType;
17
+
18
+ (function (VideoMimeType) {
19
+ /** `application/vnd.ms-sstr+xml` */
20
+ VideoMimeType["Smooth"] = "application/vnd.ms-sstr+xml";
21
+ /** `application/vnd.apple.mpegurl` */
22
+
23
+ VideoMimeType["Hls"] = "application/vnd.apple.mpegurl";
24
+ /** `application/dash+xml` */
25
+
26
+ VideoMimeType["Mpeg"] = "application/dash+xml";
27
+ })(VideoMimeType || (VideoMimeType = {}));
28
+
29
+ const ELICE_VIDEO_PLAYER_MESSAGE_EVENT = 'elice-video-player';
30
+ const ELICE_VIDEO_PLAYER_MESSAGE_TYPE = 'navigate';
31
+
32
+ const MaterialVideoFilePlayer = ({
33
+ className,
34
+ materialVideoFile,
35
+ materialVideoFileStatus = 'idle',
36
+ materialVideoFileTrackerDisabled = false,
37
+ mainLecturePageId,
38
+ orgNameShort,
39
+ lms = false,
40
+ lmsOrganizationBusinessType = null,
41
+ autoPlay = true,
42
+ autoPlayNext = true,
43
+ locale,
44
+ eliceVideoPlayerUrl,
45
+ emptyComponent = null,
46
+ title = 'elice-video-player',
47
+ onNavigatePreviousLecturePage,
48
+ onNavigateNextLecturePage
49
+ }) => {
50
+ var _a, _b, _c;
51
+
52
+ const prefixCls = 'em-video-player';
53
+ const isVideoEncoding = ((_a = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.azureMediaVideo) === null || _a === void 0 ? void 0 : _a.status) === types.enums.AzureMediaVideoStatus.Encoding;
54
+ const isVideoUploaded = ((_b = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.azureMediaVideo) === null || _b === void 0 ? void 0 : _b.status) === types.enums.AzureMediaVideoStatus.Done && typeof ((_c = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.azureMediaVideo) === null || _c === void 0 ? void 0 : _c.videoStreamingUrl) === 'string';
55
+ const [playerFrameSrc, setPlayerFrameSrc] = React__default["default"].useState(null); //
56
+ // Get video iframe src.
57
+ //
58
+
59
+ React__default["default"].useEffect(() => {
60
+ if (!eliceVideoPlayerUrl || !materialVideoFile) {
61
+ return;
62
+ }
63
+
64
+ const abortCtrl = new AbortController();
65
+ apiClient.postGlobalAuthOtpKeyMake({
66
+ signal: abortCtrl.signal
67
+ }) // issue otp key
68
+ .then(res => res.otpKey) // create search params
69
+ .then(otp => ({
70
+ org: orgNameShort,
71
+ mid: materialVideoFile.id,
72
+ lmid: mainLecturePageId,
73
+ lms,
74
+ lmstype: lms ? lmsOrganizationBusinessType !== null && lmsOrganizationBusinessType !== void 0 ? lmsOrganizationBusinessType : undefined : undefined,
75
+ codec: VideoMimeType.Smooth,
76
+ autoplay: autoPlay,
77
+ autoplaynext: autoPlayNext,
78
+ notrack: materialVideoFileTrackerDisabled,
79
+ origin: window.location.origin,
80
+ locale,
81
+ otp
82
+ })) // create url from search params
83
+ .then(params => {
84
+ const url = new URL(eliceVideoPlayerUrl);
85
+ Object.entries(params).forEach(([key, value]) => {
86
+ if (value) {
87
+ url.searchParams.set(key, value);
88
+ }
89
+ });
90
+ return url;
91
+ }).then(url => url.href).then(setPlayerFrameSrc).catch(err => {
92
+ if (err.name !== 'AbortError') {
93
+ setPlayerFrameSrc(null);
94
+ }
95
+ });
96
+ return () => {
97
+ abortCtrl.abort();
98
+ };
99
+ }, [orgNameShort, materialVideoFile, materialVideoFileTrackerDisabled, mainLecturePageId, lms, lmsOrganizationBusinessType, eliceVideoPlayerUrl, autoPlay, autoPlayNext, locale]); //
100
+ // Add event listener for navigating prev and next lecture page.
101
+ //
102
+
103
+ React__default["default"].useEffect(() => {
104
+ const _handle = event => {
105
+ var _a, _b, _c;
106
+
107
+ try {
108
+ const edata = JSON.parse(event.data);
109
+
110
+ if (edata.key !== ELICE_VIDEO_PLAYER_MESSAGE_EVENT || ((_a = edata.event) === null || _a === void 0 ? void 0 : _a.type) !== ELICE_VIDEO_PLAYER_MESSAGE_TYPE) {
111
+ return;
112
+ }
113
+
114
+ switch ((_c = (_b = edata.event) === null || _b === void 0 ? void 0 : _b.args) === null || _c === void 0 ? void 0 : _c.direction) {
115
+ case 'previous':
116
+ if (typeof onNavigatePreviousLecturePage === 'function') {
117
+ onNavigatePreviousLecturePage();
118
+ }
119
+
120
+ break;
121
+
122
+ case 'next':
123
+ if (typeof onNavigateNextLecturePage === 'function') {
124
+ onNavigateNextLecturePage === null || onNavigateNextLecturePage === void 0 ? void 0 : onNavigateNextLecturePage();
125
+ }
126
+
127
+ break;
128
+ }
129
+ } catch (_) {//
130
+ }
131
+ };
132
+
133
+ window.addEventListener('message', _handle);
134
+ return () => {
135
+ window.removeEventListener('message', _handle);
136
+ };
137
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
138
+ []); //
139
+ //
140
+ //
141
+ // pending
142
+
143
+ if (materialVideoFileStatus === 'idle' || materialVideoFileStatus === 'pending' || materialVideoFileStatus === 'resolved' && !playerFrameSrc) {
144
+ return React__default["default"].createElement(MaterialVideoFilePlayer_styled.StyledVideoPlayerLoading, null, React__default["default"].createElement(blocks.Spinner, null));
145
+ } // empty video / rejected
146
+
147
+
148
+ if (!isVideoUploaded || materialVideoFileStatus === 'rejected') {
149
+ return React__default["default"].createElement(React__default["default"].Fragment, {
150
+ children: emptyComponent
151
+ });
152
+ } // encoding
153
+
154
+
155
+ if (isVideoEncoding) {
156
+ return React__default["default"].createElement(MaterialVideoFilePlayer_styled.StyledVideoPlayerLoading, null, React__default["default"].createElement(blocks.Spinner, null), React__default["default"].createElement(blocks.Text, {
157
+ role: "gray3"
158
+ }, React__default["default"].createElement(reactIntl.FormattedMessage, {
159
+ id: "videoFile.player.onEncoding"
160
+ })));
161
+ } // resolved
162
+
163
+
164
+ return React__default["default"].createElement(MaterialVideoFilePlayer_styled.StyledVideoPlayerWrap, {
165
+ className: classnames__default["default"](prefixCls, className),
166
+ src: playerFrameSrc,
167
+ title: title,
168
+ allow: "autoplay",
169
+ allowFullScreen: true
170
+ });
171
+ };
172
+
173
+ var MaterialVideoFilePlayer$1 = Object.assign(MaterialVideoFilePlayer, {
174
+ MimeType: VideoMimeType
175
+ });
176
+
177
+ module.exports = MaterialVideoFilePlayer$1;
@@ -9,10 +9,10 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
9
9
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
10
10
 
11
11
  const StyledVideoPlayerWrap = styled__default["default"].iframe.withConfig({
12
- componentId: "sc-6gevcy-0"
12
+ componentId: "sc-1ocq3lp-0"
13
13
  })(["width:100%;height:100%;border:0;"]);
14
14
  const StyledVideoPlayerLoading = styled__default["default"].div.withConfig({
15
- componentId: "sc-6gevcy-1"
15
+ componentId: "sc-1ocq3lp-1"
16
16
  })(["width:100%;height:100%;display:flex;align-items:center;justify-content:center;"]);
17
17
 
18
18
  exports.StyledVideoPlayerLoading = StyledVideoPlayerLoading;
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
- import type { VideoPlayerProps } from '../video-player';
3
- declare type PickedVideoPlayerProps = Pick<VideoPlayerProps, 'videoNotUploadedPage' | 'autoPlay' | 'azureVideoPlayerUrl' | 'className' | 'isSupplement' | 'videoGetStatus' | 'videoTitle' | 'userId' | 'isLmsCourse' | 'lmsOrganizationBusinessType'>;
2
+ import type { MaterialVideoFilePlayerProps } from './MaterialVideoFilePlayer';
3
+ declare type PickedVideoPlayerProps = Pick<MaterialVideoFilePlayerProps, 'materialVideoFileTrackerDisabled' | 'mainLecturePageId' | 'lms' | 'lmsOrganizationBusinessType' | 'emptyComponent' | 'autoPlay' | 'autoPlayNext' | 'eliceVideoPlayerUrl' | 'onNavigatePreviousLecturePage' | 'onNavigateNextLecturePage'>;
4
4
  export interface MaterialVideoFileProps extends PickedVideoPlayerProps {
5
5
  materialVideoFileId: number;
6
+ className?: string;
6
7
  locale?: string;
7
8
  }
8
9
  declare const MaterialVideoFile: React.FC<MaterialVideoFileProps>;
@@ -1,24 +1,23 @@
1
1
  import { __rest } from 'tslib';
2
2
  import React from 'react';
3
3
  import { IntlProvider } from 'react-intl';
4
- import { config, getOrgMaterialVideoFileGet, postGlobalAuthOtpKeyMake } from '@elice/api-client';
5
- import { Spinner } from '@elice/blocks';
4
+ import { config, getOrgMaterialVideoFileGet } from '@elice/api-client';
6
5
  import { useMaterialConfig, useMaterialInitFetch } from '@elice/material-shared-utils';
7
6
  import classnames from 'classnames';
8
- import VideoPlayer from '../video-player/VideoPlayer.js';
9
7
  import * as locales from './locales.js';
10
8
  import { en } from './locales.js';
9
+ import MaterialVideoFilePlayer from './MaterialVideoFilePlayer.js';
11
10
  import { StyledMaterialVideoFileWrap } from './MaterialVideoFile.styled.js';
12
11
 
13
12
  const MaterialVideoFile = _a => {
14
- var _b;
13
+ var _b, _c, _d;
15
14
 
16
15
  var {
17
16
  materialVideoFileId,
18
17
  className,
19
18
  locale = 'en'
20
19
  } = _a,
21
- videoPlayerProps = __rest(_a, ["materialVideoFileId", "className", "locale"]);
20
+ playerProps = __rest(_a, ["materialVideoFileId", "className", "locale"]);
22
21
 
23
22
  const prefixCls = 'em-material-video-file';
24
23
  const {
@@ -28,27 +27,22 @@ const MaterialVideoFile = _a => {
28
27
  materialVideoFileId
29
28
  }, {
30
29
  signal
31
- }), [materialVideoFileId]));
32
-
33
- const makeOtpKey = async () => {
34
- return postGlobalAuthOtpKeyMake().then(res => res.otpKey);
35
- }; //
30
+ }), [materialVideoFileId])); //
36
31
  //
37
32
  //
38
33
 
39
-
40
34
  return React.createElement(StyledMaterialVideoFileWrap, {
41
35
  className: classnames(prefixCls, className)
42
36
  }, React.createElement(IntlProvider, {
43
37
  locale: locale,
44
38
  defaultLocale: "en",
45
39
  messages: locale in locales ? locales[locale] : en
46
- }, (materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.materialVideoFile) ? React.createElement(VideoPlayer, Object.assign({}, videoPlayerProps, {
47
- material: (_b = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.materialVideoFile) !== null && _b !== void 0 ? _b : null,
40
+ }, React.createElement(MaterialVideoFilePlayer, Object.assign({}, playerProps, {
48
41
  orgNameShort: orgNameShort,
49
- videoGetStatus: materialVideoFileStatus,
50
- onOtpRequest: makeOtpKey
51
- })) : React.createElement(Spinner, null)));
42
+ materialVideoFile: (_b = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.materialVideoFile) !== null && _b !== void 0 ? _b : null,
43
+ materialVideoFileStatus: materialVideoFileStatus,
44
+ title: (_d = (_c = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.materialVideoFile.azureMediaVideo) === null || _c === void 0 ? void 0 : _c.videoAssetName) !== null && _d !== void 0 ? _d : undefined
45
+ }))));
52
46
  };
53
47
 
54
48
  export { MaterialVideoFile as default };
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import type { APIStatus } from '@elice/material-shared-types';
3
+ import type { EliceVideoPlayerSearchParams, GetOrgMaterialVideoFileGetResponses } from '@elice/types';
4
+ export interface MaterialVideoFilePlayerProps {
5
+ /** Classname for the element. */
6
+ className?: string;
7
+ /** Material video file. */
8
+ materialVideoFile: null | GetOrgMaterialVideoFileGetResponses['materialVideoFile'];
9
+ /** Fetch status of material video file. */
10
+ materialVideoFileStatus?: APIStatus;
11
+ /** Disable material video file tracker. */
12
+ materialVideoFileTrackerDisabled?: EliceVideoPlayerSearchParams['notrack'];
13
+ /**
14
+ * Linked material (main lecture page) ID.
15
+ * If this is set, the material assumed as sub lecture page.
16
+ */
17
+ mainLecturePageId?: EliceVideoPlayerSearchParams['lmid'];
18
+ /** Organization name short. */
19
+ orgNameShort: EliceVideoPlayerSearchParams['org'];
20
+ /** Run in LMS env? */
21
+ lms?: EliceVideoPlayerSearchParams['lms'];
22
+ /** Type of LMS org business. */
23
+ lmsOrganizationBusinessType?: EliceVideoPlayerSearchParams['lmstype'];
24
+ /** Auto play. */
25
+ autoPlay?: EliceVideoPlayerSearchParams['autoplay'];
26
+ /** Auto play next lecture page. */
27
+ autoPlayNext?: EliceVideoPlayerSearchParams['autoplaynext'];
28
+ /** Locale. */
29
+ locale?: EliceVideoPlayerSearchParams['locale'];
30
+ /** Elice video player url. */
31
+ eliceVideoPlayerUrl?: string;
32
+ /** Empty component. */
33
+ emptyComponent: React.ReactNode;
34
+ /** Title of player. (set on iframe) */
35
+ title?: string;
36
+ /** Navigate to previous lecture page. */
37
+ onNavigatePreviousLecturePage?: () => void;
38
+ /** Navigate to next lecture page. */
39
+ onNavigateNextLecturePage?: () => void;
40
+ }
41
+ declare enum VideoMimeType {
42
+ /** `application/vnd.ms-sstr+xml` */
43
+ Smooth = "application/vnd.ms-sstr+xml",
44
+ /** `application/vnd.apple.mpegurl` */
45
+ Hls = "application/vnd.apple.mpegurl",
46
+ /** `application/dash+xml` */
47
+ Mpeg = "application/dash+xml"
48
+ }
49
+ declare const _default: React.FC<MaterialVideoFilePlayerProps> & {
50
+ MimeType: typeof VideoMimeType;
51
+ };
52
+ export default _default;
@@ -0,0 +1,170 @@
1
+ import React from 'react';
2
+ import { FormattedMessage } from 'react-intl';
3
+ import { postGlobalAuthOtpKeyMake } from '@elice/api-client';
4
+ import { Spinner, Text } from '@elice/blocks';
5
+ import { enums } from '@elice/types';
6
+ import classnames from 'classnames';
7
+ import { StyledVideoPlayerLoading, StyledVideoPlayerWrap } from './MaterialVideoFilePlayer.styled.js';
8
+
9
+ var VideoMimeType;
10
+
11
+ (function (VideoMimeType) {
12
+ /** `application/vnd.ms-sstr+xml` */
13
+ VideoMimeType["Smooth"] = "application/vnd.ms-sstr+xml";
14
+ /** `application/vnd.apple.mpegurl` */
15
+
16
+ VideoMimeType["Hls"] = "application/vnd.apple.mpegurl";
17
+ /** `application/dash+xml` */
18
+
19
+ VideoMimeType["Mpeg"] = "application/dash+xml";
20
+ })(VideoMimeType || (VideoMimeType = {}));
21
+
22
+ const ELICE_VIDEO_PLAYER_MESSAGE_EVENT = 'elice-video-player';
23
+ const ELICE_VIDEO_PLAYER_MESSAGE_TYPE = 'navigate';
24
+
25
+ const MaterialVideoFilePlayer = ({
26
+ className,
27
+ materialVideoFile,
28
+ materialVideoFileStatus = 'idle',
29
+ materialVideoFileTrackerDisabled = false,
30
+ mainLecturePageId,
31
+ orgNameShort,
32
+ lms = false,
33
+ lmsOrganizationBusinessType = null,
34
+ autoPlay = true,
35
+ autoPlayNext = true,
36
+ locale,
37
+ eliceVideoPlayerUrl,
38
+ emptyComponent = null,
39
+ title = 'elice-video-player',
40
+ onNavigatePreviousLecturePage,
41
+ onNavigateNextLecturePage
42
+ }) => {
43
+ var _a, _b, _c;
44
+
45
+ const prefixCls = 'em-video-player';
46
+ const isVideoEncoding = ((_a = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.azureMediaVideo) === null || _a === void 0 ? void 0 : _a.status) === enums.AzureMediaVideoStatus.Encoding;
47
+ const isVideoUploaded = ((_b = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.azureMediaVideo) === null || _b === void 0 ? void 0 : _b.status) === enums.AzureMediaVideoStatus.Done && typeof ((_c = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.azureMediaVideo) === null || _c === void 0 ? void 0 : _c.videoStreamingUrl) === 'string';
48
+ const [playerFrameSrc, setPlayerFrameSrc] = React.useState(null); //
49
+ // Get video iframe src.
50
+ //
51
+
52
+ React.useEffect(() => {
53
+ if (!eliceVideoPlayerUrl || !materialVideoFile) {
54
+ return;
55
+ }
56
+
57
+ const abortCtrl = new AbortController();
58
+ postGlobalAuthOtpKeyMake({
59
+ signal: abortCtrl.signal
60
+ }) // issue otp key
61
+ .then(res => res.otpKey) // create search params
62
+ .then(otp => ({
63
+ org: orgNameShort,
64
+ mid: materialVideoFile.id,
65
+ lmid: mainLecturePageId,
66
+ lms,
67
+ lmstype: lms ? lmsOrganizationBusinessType !== null && lmsOrganizationBusinessType !== void 0 ? lmsOrganizationBusinessType : undefined : undefined,
68
+ codec: VideoMimeType.Smooth,
69
+ autoplay: autoPlay,
70
+ autoplaynext: autoPlayNext,
71
+ notrack: materialVideoFileTrackerDisabled,
72
+ origin: window.location.origin,
73
+ locale,
74
+ otp
75
+ })) // create url from search params
76
+ .then(params => {
77
+ const url = new URL(eliceVideoPlayerUrl);
78
+ Object.entries(params).forEach(([key, value]) => {
79
+ if (value) {
80
+ url.searchParams.set(key, value);
81
+ }
82
+ });
83
+ return url;
84
+ }).then(url => url.href).then(setPlayerFrameSrc).catch(err => {
85
+ if (err.name !== 'AbortError') {
86
+ setPlayerFrameSrc(null);
87
+ }
88
+ });
89
+ return () => {
90
+ abortCtrl.abort();
91
+ };
92
+ }, [orgNameShort, materialVideoFile, materialVideoFileTrackerDisabled, mainLecturePageId, lms, lmsOrganizationBusinessType, eliceVideoPlayerUrl, autoPlay, autoPlayNext, locale]); //
93
+ // Add event listener for navigating prev and next lecture page.
94
+ //
95
+
96
+ React.useEffect(() => {
97
+ const _handle = event => {
98
+ var _a, _b, _c;
99
+
100
+ try {
101
+ const edata = JSON.parse(event.data);
102
+
103
+ if (edata.key !== ELICE_VIDEO_PLAYER_MESSAGE_EVENT || ((_a = edata.event) === null || _a === void 0 ? void 0 : _a.type) !== ELICE_VIDEO_PLAYER_MESSAGE_TYPE) {
104
+ return;
105
+ }
106
+
107
+ switch ((_c = (_b = edata.event) === null || _b === void 0 ? void 0 : _b.args) === null || _c === void 0 ? void 0 : _c.direction) {
108
+ case 'previous':
109
+ if (typeof onNavigatePreviousLecturePage === 'function') {
110
+ onNavigatePreviousLecturePage();
111
+ }
112
+
113
+ break;
114
+
115
+ case 'next':
116
+ if (typeof onNavigateNextLecturePage === 'function') {
117
+ onNavigateNextLecturePage === null || onNavigateNextLecturePage === void 0 ? void 0 : onNavigateNextLecturePage();
118
+ }
119
+
120
+ break;
121
+ }
122
+ } catch (_) {//
123
+ }
124
+ };
125
+
126
+ window.addEventListener('message', _handle);
127
+ return () => {
128
+ window.removeEventListener('message', _handle);
129
+ };
130
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
131
+ []); //
132
+ //
133
+ //
134
+ // pending
135
+
136
+ if (materialVideoFileStatus === 'idle' || materialVideoFileStatus === 'pending' || materialVideoFileStatus === 'resolved' && !playerFrameSrc) {
137
+ return React.createElement(StyledVideoPlayerLoading, null, React.createElement(Spinner, null));
138
+ } // empty video / rejected
139
+
140
+
141
+ if (!isVideoUploaded || materialVideoFileStatus === 'rejected') {
142
+ return React.createElement(React.Fragment, {
143
+ children: emptyComponent
144
+ });
145
+ } // encoding
146
+
147
+
148
+ if (isVideoEncoding) {
149
+ return React.createElement(StyledVideoPlayerLoading, null, React.createElement(Spinner, null), React.createElement(Text, {
150
+ role: "gray3"
151
+ }, React.createElement(FormattedMessage, {
152
+ id: "videoFile.player.onEncoding"
153
+ })));
154
+ } // resolved
155
+
156
+
157
+ return React.createElement(StyledVideoPlayerWrap, {
158
+ className: classnames(prefixCls, className),
159
+ src: playerFrameSrc,
160
+ title: title,
161
+ allow: "autoplay",
162
+ allowFullScreen: true
163
+ });
164
+ };
165
+
166
+ var MaterialVideoFilePlayer$1 = Object.assign(MaterialVideoFilePlayer, {
167
+ MimeType: VideoMimeType
168
+ });
169
+
170
+ export { MaterialVideoFilePlayer$1 as default };
@@ -1,10 +1,10 @@
1
1
  import styled from 'styled-components';
2
2
 
3
3
  const StyledVideoPlayerWrap = styled.iframe.withConfig({
4
- componentId: "sc-6gevcy-0"
4
+ componentId: "sc-1ocq3lp-0"
5
5
  })(["width:100%;height:100%;border:0;"]);
6
6
  const StyledVideoPlayerLoading = styled.div.withConfig({
7
- componentId: "sc-6gevcy-1"
7
+ componentId: "sc-1ocq3lp-1"
8
8
  })(["width:100%;height:100%;display:flex;align-items:center;justify-content:center;"]);
9
9
 
10
10
  export { StyledVideoPlayerLoading, StyledVideoPlayerWrap };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elice/material-video-file",
3
- "version": "1.220919.0",
3
+ "version": "1.221026.0",
4
4
  "description": "User view and editing components of Elice material video file",
5
5
  "repository": "https://git.elicer.io/elice/frontend/library/elice-material",
6
6
  "license": "UNLICENSED",
@@ -33,9 +33,9 @@
33
33
  "@elice/blocks": "^1.220803.0",
34
34
  "@elice/design-tokens": "^1.220803.0",
35
35
  "@elice/icons": "^1.220803.0",
36
- "@elice/material-shared-types": "22.7.2-1",
37
- "@elice/material-shared-utils": "22.7.2-1",
38
- "@elice/types": "^1.220914.0",
36
+ "@elice/material-shared-types": "*",
37
+ "@elice/material-shared-utils": "*",
38
+ "@elice/types": "^1.221026.1",
39
39
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
40
40
  "react-intl": "^5.0.0",
41
41
  "react-use": "^17.0.0",
@@ -52,9 +52,9 @@
52
52
  "@elice/design-tokens": "^1.220803.0",
53
53
  "@elice/icons": "^1.220803.0",
54
54
  "@elice/icons-legacy": "npm:@elice/icons@0.220803.1",
55
- "@elice/material-shared-types": "1.220919.0",
56
- "@elice/material-shared-utils": "1.220919.0",
57
- "@elice/types": "^1.220914.0",
55
+ "@elice/material-shared-types": "1.221026.0",
56
+ "@elice/material-shared-utils": "1.221026.0",
57
+ "@elice/types": "^1.221026.1",
58
58
  "@types/classnames": "^2.3.1",
59
59
  "@types/query-string": "^6.3.0",
60
60
  "@types/react": "~17.0.9",
@@ -64,5 +64,5 @@
64
64
  "react-use": "^17.2.4",
65
65
  "styled-components": "^5.3.0"
66
66
  },
67
- "gitHead": "bddb3a6f9165572b2ba351356d5443f85d0ff519"
67
+ "gitHead": "7de772c5b7ffa0c09afe214c732b3557f5958471"
68
68
  }
@@ -1,39 +0,0 @@
1
- import React from 'react';
2
- import type { APIStatus } from '@elice/material-shared-types';
3
- import type { EliceVideoPlayerSearchParams } from '@elice/types';
4
- import type { GetOrgMaterialVideoFileGetResponses } from '@elice/types';
5
- declare type PickedEliceVideoPlayerSearchParams = Pick<EliceVideoPlayerSearchParams, 'isLmsCourse' | 'userId' | 'lmsOrganizationBusinessType'>;
6
- export interface VideoPlayerProps extends PickedEliceVideoPlayerSearchParams {
7
- /** Material video file data */
8
- material: null | GetOrgMaterialVideoFileGetResponses['materialVideoFile'];
9
- /** Elice organization name short. */
10
- orgNameShort: string;
11
- /** The page that shows when the video is not uploaded */
12
- videoNotUploadedPage: React.ReactNode;
13
- /** Play videos automatically */
14
- autoPlay?: boolean;
15
- /** Video api server */
16
- azureVideoPlayerUrl?: string;
17
- /** Classname for the element. */
18
- className?: string;
19
- /** Check supplement */
20
- isSupplement?: boolean;
21
- /** Video get api status */
22
- videoGetStatus?: APIStatus;
23
- /** Video iframe title */
24
- videoTitle?: string;
25
- /** Get Otp callback */
26
- onOtpRequest: () => Promise<string>;
27
- }
28
- declare enum VideoMimeType {
29
- /** `application/vnd.ms-sstr+xml` */
30
- Smooth = "application/vnd.ms-sstr+xml",
31
- /** `application/vnd.apple.mpegurl` */
32
- Hls = "application/vnd.apple.mpegurl",
33
- /** `application/dash+xml` */
34
- Mpeg = "application/dash+xml"
35
- }
36
- declare const _default: React.FC<VideoPlayerProps> & {
37
- MimeType: typeof VideoMimeType;
38
- };
39
- export default _default;
@@ -1,158 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var reactIntl = require('react-intl');
5
- var reactUse = require('react-use');
6
- var blocks = require('@elice/blocks');
7
- var designTokens = require('@elice/design-tokens');
8
- var icons = require('@elice/icons');
9
- var types = require('@elice/types');
10
- var classnames = require('classnames');
11
- var QueryString = require('query-string');
12
- var VideoPlayer_styled = require('./VideoPlayer.styled.js');
13
-
14
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
-
16
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
17
- var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
18
- var QueryString__default = /*#__PURE__*/_interopDefaultLegacy(QueryString);
19
-
20
- var VideoMimeType;
21
-
22
- (function (VideoMimeType) {
23
- /** `application/vnd.ms-sstr+xml` */
24
- VideoMimeType["Smooth"] = "application/vnd.ms-sstr+xml";
25
- /** `application/vnd.apple.mpegurl` */
26
-
27
- VideoMimeType["Hls"] = "application/vnd.apple.mpegurl";
28
- /** `application/dash+xml` */
29
-
30
- VideoMimeType["Mpeg"] = "application/dash+xml";
31
- })(VideoMimeType || (VideoMimeType = {}));
32
-
33
- const VideoPlayer = ({
34
- material,
35
- orgNameShort,
36
- videoNotUploadedPage,
37
- autoPlay = true,
38
- azureVideoPlayerUrl,
39
- className,
40
- isLmsCourse = false,
41
- isSupplement,
42
- userId,
43
- videoTitle,
44
- videoGetStatus,
45
- lmsOrganizationBusinessType,
46
- onOtpRequest
47
- }) => {
48
- var _a, _b;
49
-
50
- const prefixCls = 'em-video-player';
51
- const [otp, setOtp] = React__default["default"].useState();
52
- /**
53
- * Get user otp
54
- *
55
- * Every time `material` changes, `otp` is called.
56
- * Using the previous `otp` result in the following error:
57
- *"EliceApiClientError: [invalid_otp_key] logic - the otp key is invalid"
58
- */
59
-
60
- reactUse.useDeepCompareEffect(() => {
61
- onOtpRequest().then(setOtp).catch(() =>
62
- /**
63
- * When Otp is undefined, appear error dialog.
64
- * Them message is "OTP 세션정보가 없습니다."
65
- */
66
- setOtp(undefined));
67
- }, [material]);
68
- /**
69
- * Make video search params
70
- */
71
-
72
- const makeEncodedUri = () => {
73
- var _a, _b;
74
-
75
- const serverUrl = azureVideoPlayerUrl !== null && azureVideoPlayerUrl !== void 0 ? azureVideoPlayerUrl : '';
76
- const videoFileUrl = (_b = (_a = material === null || material === void 0 ? void 0 : material.azureMediaVideo) === null || _a === void 0 ? void 0 : _a.videoStreamingUrl) !== null && _b !== void 0 ? _b : '';
77
- const videoSearchParams = {
78
- src: videoFileUrl,
79
- type: VideoMimeType.Smooth,
80
- orgNameShort,
81
- courseId: material === null || material === void 0 ? void 0 : material.courseId,
82
- lectureId: material === null || material === void 0 ? void 0 : material.lectureId,
83
- materialId: material === null || material === void 0 ? void 0 : material.id,
84
- mainOrderNo: !isSupplement ? material === null || material === void 0 ? void 0 : material.mainOrderNo : 0,
85
- isLmsCourse,
86
- autoplay: autoPlay,
87
- userId,
88
- location: window.location.hash,
89
- otp
90
- }; // When only lms, add `lmsOrganizationBusinessType` to search params.
91
-
92
- if (isLmsCourse && typeof lmsOrganizationBusinessType !== undefined) {
93
- videoSearchParams.lmsOrganizationBusinessType = lmsOrganizationBusinessType;
94
- }
95
-
96
- const encodedUri = `${serverUrl}/?${QueryString__default["default"].stringify(videoSearchParams)}`;
97
- return encodedUri;
98
- };
99
- /**
100
- * Check video streaming url
101
- */
102
-
103
-
104
- const isVideoUploaded = Boolean((_a = material === null || material === void 0 ? void 0 : material.azureMediaVideo) === null || _a === void 0 ? void 0 : _a.videoStreamingUrl);
105
- /**
106
- * Check video encoding
107
- */
108
-
109
- const isVideoOnEncoding = Boolean(((_b = material === null || material === void 0 ? void 0 : material.azureMediaVideo) === null || _b === void 0 ? void 0 : _b.status) === types.enums.AzureMediaVideoStatus.Encoding);
110
-
111
- if (videoGetStatus === 'pending') {
112
- return React__default["default"].createElement(blocks.Spinner, null);
113
- } // When Video file not found
114
-
115
-
116
- if (videoGetStatus === 'rejected' || !material) {
117
- return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(blocks.Icon, {
118
- icon: icons.eilStatusWarn,
119
- color: designTokens.base.color.white,
120
- style: {
121
- width: '4rem',
122
- height: '4rem'
123
- }
124
- }), React__default["default"].createElement(blocks.Vspace, {
125
- height: 1
126
- }), React__default["default"].createElement(blocks.Text, {
127
- role: "gray3"
128
- }, React__default["default"].createElement(reactIntl.FormattedMessage, {
129
- id: "videoFile.player.noVideo"
130
- })));
131
- }
132
-
133
- if (isVideoOnEncoding) {
134
- return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(blocks.Spinner, null), React__default["default"].createElement(blocks.Text, {
135
- role: "gray3"
136
- }, React__default["default"].createElement(reactIntl.FormattedMessage, {
137
- id: "videoFile.player.onEncoding"
138
- })));
139
- }
140
-
141
- if (!isVideoUploaded) {
142
- return React__default["default"].createElement(React__default["default"].Fragment, null, videoNotUploadedPage);
143
- }
144
-
145
- return otp ? React__default["default"].createElement(VideoPlayer_styled.StyledVideoPlayerWrap, {
146
- allowFullScreen: true,
147
- className: classnames__default["default"](prefixCls, className),
148
- title: videoTitle !== null && videoTitle !== void 0 ? videoTitle : 'video-player',
149
- src: makeEncodedUri(),
150
- allow: "autoplay"
151
- }) : React__default["default"].createElement(VideoPlayer_styled.StyledVideoPlayerLoading, null, React__default["default"].createElement(blocks.Spinner, null));
152
- };
153
-
154
- var VideoPlayer$1 = Object.assign(VideoPlayer, {
155
- MimeType: VideoMimeType
156
- });
157
-
158
- module.exports = VideoPlayer$1;
@@ -1,2 +0,0 @@
1
- export { default as VideoPlayer } from './VideoPlayer';
2
- export type { VideoPlayerProps } from './VideoPlayer';
@@ -1,39 +0,0 @@
1
- import React from 'react';
2
- import type { APIStatus } from '@elice/material-shared-types';
3
- import type { EliceVideoPlayerSearchParams } from '@elice/types';
4
- import type { GetOrgMaterialVideoFileGetResponses } from '@elice/types';
5
- declare type PickedEliceVideoPlayerSearchParams = Pick<EliceVideoPlayerSearchParams, 'isLmsCourse' | 'userId' | 'lmsOrganizationBusinessType'>;
6
- export interface VideoPlayerProps extends PickedEliceVideoPlayerSearchParams {
7
- /** Material video file data */
8
- material: null | GetOrgMaterialVideoFileGetResponses['materialVideoFile'];
9
- /** Elice organization name short. */
10
- orgNameShort: string;
11
- /** The page that shows when the video is not uploaded */
12
- videoNotUploadedPage: React.ReactNode;
13
- /** Play videos automatically */
14
- autoPlay?: boolean;
15
- /** Video api server */
16
- azureVideoPlayerUrl?: string;
17
- /** Classname for the element. */
18
- className?: string;
19
- /** Check supplement */
20
- isSupplement?: boolean;
21
- /** Video get api status */
22
- videoGetStatus?: APIStatus;
23
- /** Video iframe title */
24
- videoTitle?: string;
25
- /** Get Otp callback */
26
- onOtpRequest: () => Promise<string>;
27
- }
28
- declare enum VideoMimeType {
29
- /** `application/vnd.ms-sstr+xml` */
30
- Smooth = "application/vnd.ms-sstr+xml",
31
- /** `application/vnd.apple.mpegurl` */
32
- Hls = "application/vnd.apple.mpegurl",
33
- /** `application/dash+xml` */
34
- Mpeg = "application/dash+xml"
35
- }
36
- declare const _default: React.FC<VideoPlayerProps> & {
37
- MimeType: typeof VideoMimeType;
38
- };
39
- export default _default;
@@ -1,150 +0,0 @@
1
- import React from 'react';
2
- import { FormattedMessage } from 'react-intl';
3
- import { useDeepCompareEffect } from 'react-use';
4
- import { Spinner, Icon, Vspace, Text } from '@elice/blocks';
5
- import { base } from '@elice/design-tokens';
6
- import { eilStatusWarn } from '@elice/icons';
7
- import { enums } from '@elice/types';
8
- import classnames from 'classnames';
9
- import QueryString from 'query-string';
10
- import { StyledVideoPlayerWrap, StyledVideoPlayerLoading } from './VideoPlayer.styled.js';
11
-
12
- var VideoMimeType;
13
-
14
- (function (VideoMimeType) {
15
- /** `application/vnd.ms-sstr+xml` */
16
- VideoMimeType["Smooth"] = "application/vnd.ms-sstr+xml";
17
- /** `application/vnd.apple.mpegurl` */
18
-
19
- VideoMimeType["Hls"] = "application/vnd.apple.mpegurl";
20
- /** `application/dash+xml` */
21
-
22
- VideoMimeType["Mpeg"] = "application/dash+xml";
23
- })(VideoMimeType || (VideoMimeType = {}));
24
-
25
- const VideoPlayer = ({
26
- material,
27
- orgNameShort,
28
- videoNotUploadedPage,
29
- autoPlay = true,
30
- azureVideoPlayerUrl,
31
- className,
32
- isLmsCourse = false,
33
- isSupplement,
34
- userId,
35
- videoTitle,
36
- videoGetStatus,
37
- lmsOrganizationBusinessType,
38
- onOtpRequest
39
- }) => {
40
- var _a, _b;
41
-
42
- const prefixCls = 'em-video-player';
43
- const [otp, setOtp] = React.useState();
44
- /**
45
- * Get user otp
46
- *
47
- * Every time `material` changes, `otp` is called.
48
- * Using the previous `otp` result in the following error:
49
- *"EliceApiClientError: [invalid_otp_key] logic - the otp key is invalid"
50
- */
51
-
52
- useDeepCompareEffect(() => {
53
- onOtpRequest().then(setOtp).catch(() =>
54
- /**
55
- * When Otp is undefined, appear error dialog.
56
- * Them message is "OTP 세션정보가 없습니다."
57
- */
58
- setOtp(undefined));
59
- }, [material]);
60
- /**
61
- * Make video search params
62
- */
63
-
64
- const makeEncodedUri = () => {
65
- var _a, _b;
66
-
67
- const serverUrl = azureVideoPlayerUrl !== null && azureVideoPlayerUrl !== void 0 ? azureVideoPlayerUrl : '';
68
- const videoFileUrl = (_b = (_a = material === null || material === void 0 ? void 0 : material.azureMediaVideo) === null || _a === void 0 ? void 0 : _a.videoStreamingUrl) !== null && _b !== void 0 ? _b : '';
69
- const videoSearchParams = {
70
- src: videoFileUrl,
71
- type: VideoMimeType.Smooth,
72
- orgNameShort,
73
- courseId: material === null || material === void 0 ? void 0 : material.courseId,
74
- lectureId: material === null || material === void 0 ? void 0 : material.lectureId,
75
- materialId: material === null || material === void 0 ? void 0 : material.id,
76
- mainOrderNo: !isSupplement ? material === null || material === void 0 ? void 0 : material.mainOrderNo : 0,
77
- isLmsCourse,
78
- autoplay: autoPlay,
79
- userId,
80
- location: window.location.hash,
81
- otp
82
- }; // When only lms, add `lmsOrganizationBusinessType` to search params.
83
-
84
- if (isLmsCourse && typeof lmsOrganizationBusinessType !== undefined) {
85
- videoSearchParams.lmsOrganizationBusinessType = lmsOrganizationBusinessType;
86
- }
87
-
88
- const encodedUri = `${serverUrl}/?${QueryString.stringify(videoSearchParams)}`;
89
- return encodedUri;
90
- };
91
- /**
92
- * Check video streaming url
93
- */
94
-
95
-
96
- const isVideoUploaded = Boolean((_a = material === null || material === void 0 ? void 0 : material.azureMediaVideo) === null || _a === void 0 ? void 0 : _a.videoStreamingUrl);
97
- /**
98
- * Check video encoding
99
- */
100
-
101
- const isVideoOnEncoding = Boolean(((_b = material === null || material === void 0 ? void 0 : material.azureMediaVideo) === null || _b === void 0 ? void 0 : _b.status) === enums.AzureMediaVideoStatus.Encoding);
102
-
103
- if (videoGetStatus === 'pending') {
104
- return React.createElement(Spinner, null);
105
- } // When Video file not found
106
-
107
-
108
- if (videoGetStatus === 'rejected' || !material) {
109
- return React.createElement(React.Fragment, null, React.createElement(Icon, {
110
- icon: eilStatusWarn,
111
- color: base.color.white,
112
- style: {
113
- width: '4rem',
114
- height: '4rem'
115
- }
116
- }), React.createElement(Vspace, {
117
- height: 1
118
- }), React.createElement(Text, {
119
- role: "gray3"
120
- }, React.createElement(FormattedMessage, {
121
- id: "videoFile.player.noVideo"
122
- })));
123
- }
124
-
125
- if (isVideoOnEncoding) {
126
- return React.createElement(React.Fragment, null, React.createElement(Spinner, null), React.createElement(Text, {
127
- role: "gray3"
128
- }, React.createElement(FormattedMessage, {
129
- id: "videoFile.player.onEncoding"
130
- })));
131
- }
132
-
133
- if (!isVideoUploaded) {
134
- return React.createElement(React.Fragment, null, videoNotUploadedPage);
135
- }
136
-
137
- return otp ? React.createElement(StyledVideoPlayerWrap, {
138
- allowFullScreen: true,
139
- className: classnames(prefixCls, className),
140
- title: videoTitle !== null && videoTitle !== void 0 ? videoTitle : 'video-player',
141
- src: makeEncodedUri(),
142
- allow: "autoplay"
143
- }) : React.createElement(StyledVideoPlayerLoading, null, React.createElement(Spinner, null));
144
- };
145
-
146
- var VideoPlayer$1 = Object.assign(VideoPlayer, {
147
- MimeType: VideoMimeType
148
- });
149
-
150
- export { VideoPlayer$1 as default };
@@ -1,2 +0,0 @@
1
- export { default as VideoPlayer } from './VideoPlayer';
2
- export type { VideoPlayerProps } from './VideoPlayer';