@elice/material-video-file 1.220803.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.
- package/README.md +3 -0
- package/cjs/components/material-video-file/MaterialVideoFile.d.ts +9 -0
- package/cjs/components/material-video-file/MaterialVideoFile.js +60 -0
- package/cjs/components/material-video-file/MaterialVideoFile.styled.d.ts +1 -0
- package/cjs/components/material-video-file/MaterialVideoFile.styled.js +16 -0
- package/cjs/components/material-video-file/index.d.ts +2 -0
- package/cjs/components/material-video-file/locales.d.ts +7 -0
- package/cjs/components/material-video-file/locales.js +19 -0
- package/cjs/components/video-player/VideoPlayer.d.ts +39 -0
- package/cjs/components/video-player/VideoPlayer.js +158 -0
- package/cjs/components/video-player/VideoPlayer.styled.d.ts +2 -0
- package/cjs/components/video-player/VideoPlayer.styled.js +19 -0
- package/cjs/components/video-player/index.d.ts +2 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +9 -0
- package/es/components/material-video-file/MaterialVideoFile.d.ts +9 -0
- package/es/components/material-video-file/MaterialVideoFile.js +54 -0
- package/es/components/material-video-file/MaterialVideoFile.styled.d.ts +1 -0
- package/es/components/material-video-file/MaterialVideoFile.styled.js +8 -0
- package/es/components/material-video-file/index.d.ts +2 -0
- package/es/components/material-video-file/locales.d.ts +7 -0
- package/es/components/material-video-file/locales.js +14 -0
- package/es/components/video-player/VideoPlayer.d.ts +39 -0
- package/es/components/video-player/VideoPlayer.js +150 -0
- package/es/components/video-player/VideoPlayer.styled.d.ts +2 -0
- package/es/components/video-player/VideoPlayer.styled.js +10 -0
- package/es/components/video-player/index.d.ts +2 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/package.json +68 -0
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
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'>;
|
|
4
|
+
export interface MaterialVideoFileProps extends PickedVideoPlayerProps {
|
|
5
|
+
materialVideoFileId: number;
|
|
6
|
+
locale?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const MaterialVideoFile: React.FC<MaterialVideoFileProps>;
|
|
9
|
+
export default MaterialVideoFile;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var reactIntl = require('react-intl');
|
|
6
|
+
var apiClient = require('@elice/api-client');
|
|
7
|
+
var blocks = require('@elice/blocks');
|
|
8
|
+
var materialSharedUtils = require('@elice/material-shared-utils');
|
|
9
|
+
var classnames = require('classnames');
|
|
10
|
+
var VideoPlayer = require('../video-player/VideoPlayer.js');
|
|
11
|
+
var locales = require('./locales.js');
|
|
12
|
+
var MaterialVideoFile_styled = require('./MaterialVideoFile.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
|
+
|
|
19
|
+
const MaterialVideoFile = _a => {
|
|
20
|
+
var _b;
|
|
21
|
+
|
|
22
|
+
var {
|
|
23
|
+
materialVideoFileId,
|
|
24
|
+
className,
|
|
25
|
+
locale = 'en'
|
|
26
|
+
} = _a,
|
|
27
|
+
videoPlayerProps = tslib.__rest(_a, ["materialVideoFileId", "className", "locale"]);
|
|
28
|
+
|
|
29
|
+
const prefixCls = 'em-material-video-file';
|
|
30
|
+
const {
|
|
31
|
+
orgNameShort
|
|
32
|
+
} = materialSharedUtils.useMaterialConfig();
|
|
33
|
+
const [materialVideoFile, materialVideoFileStatus] = materialSharedUtils.useMaterialInitFetch(apiClient.config.init, React__default["default"].useCallback(signal => apiClient.getOrgMaterialVideoFileGet({
|
|
34
|
+
materialVideoFileId
|
|
35
|
+
}, {
|
|
36
|
+
signal
|
|
37
|
+
}), [materialVideoFileId]));
|
|
38
|
+
|
|
39
|
+
const makeOtpKey = async () => {
|
|
40
|
+
return apiClient.postGlobalAuthOtpKeyMake().then(res => res.otpKey);
|
|
41
|
+
}; //
|
|
42
|
+
//
|
|
43
|
+
//
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
return React__default["default"].createElement(MaterialVideoFile_styled.StyledMaterialVideoFileWrap, {
|
|
47
|
+
className: classnames__default["default"](prefixCls, className)
|
|
48
|
+
}, React__default["default"].createElement(reactIntl.IntlProvider, {
|
|
49
|
+
locale: locale,
|
|
50
|
+
defaultLocale: "en",
|
|
51
|
+
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,
|
|
54
|
+
orgNameShort: orgNameShort,
|
|
55
|
+
videoGetStatus: materialVideoFileStatus,
|
|
56
|
+
onOtpRequest: makeOtpKey
|
|
57
|
+
})) : React__default["default"].createElement(blocks.Spinner, null)));
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
module.exports = MaterialVideoFile;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const StyledMaterialVideoFileWrap: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var designTokens = require('@elice/design-tokens');
|
|
6
|
+
var styled = require('styled-components');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
11
|
+
|
|
12
|
+
const StyledMaterialVideoFileWrap = styled__default["default"].div.withConfig({
|
|
13
|
+
componentId: "sc-1a1otok-0"
|
|
14
|
+
})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:100%;background:", ";"], designTokens.base.color.gray9);
|
|
15
|
+
|
|
16
|
+
exports.StyledMaterialVideoFileWrap = StyledMaterialVideoFileWrap;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const en = {
|
|
6
|
+
'videoFile.player.preparing': 'Material on preparing.',
|
|
7
|
+
'videoFile.player.uploadVideoBtn': 'Upload File',
|
|
8
|
+
'videoFile.player.onEncoding': 'Encoding file..',
|
|
9
|
+
'videoFile.player.noVideo': 'This file does not exist.'
|
|
10
|
+
};
|
|
11
|
+
const ko = {
|
|
12
|
+
'videoFile.player.preparing': '자료를 준비 중입니다.',
|
|
13
|
+
'videoFile.player.uploadVideoBtn': '파일 업로드',
|
|
14
|
+
'videoFile.player.onEncoding': '파일 인코딩 중..',
|
|
15
|
+
'videoFile.player.noVideo': '존재하지 않는 파일입니다.'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.en = en;
|
|
19
|
+
exports.ko = ko;
|
|
@@ -0,0 +1,39 @@
|
|
|
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;
|
|
@@ -0,0 +1,158 @@
|
|
|
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;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var styled = require('styled-components');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
10
|
+
|
|
11
|
+
const StyledVideoPlayerWrap = styled__default["default"].iframe.withConfig({
|
|
12
|
+
componentId: "sc-6gevcy-0"
|
|
13
|
+
})(["width:100%;height:100%;border:0;"]);
|
|
14
|
+
const StyledVideoPlayerLoading = styled__default["default"].div.withConfig({
|
|
15
|
+
componentId: "sc-6gevcy-1"
|
|
16
|
+
})(["width:100%;height:100%;display:flex;align-items:center;justify-content:center;"]);
|
|
17
|
+
|
|
18
|
+
exports.StyledVideoPlayerLoading = StyledVideoPlayerLoading;
|
|
19
|
+
exports.StyledVideoPlayerWrap = StyledVideoPlayerWrap;
|
package/cjs/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/material-video-file';
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
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'>;
|
|
4
|
+
export interface MaterialVideoFileProps extends PickedVideoPlayerProps {
|
|
5
|
+
materialVideoFileId: number;
|
|
6
|
+
locale?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const MaterialVideoFile: React.FC<MaterialVideoFileProps>;
|
|
9
|
+
export default MaterialVideoFile;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { IntlProvider } from 'react-intl';
|
|
4
|
+
import { config, getOrgMaterialVideoFileGet, postGlobalAuthOtpKeyMake } from '@elice/api-client';
|
|
5
|
+
import { Spinner } from '@elice/blocks';
|
|
6
|
+
import { useMaterialConfig, useMaterialInitFetch } from '@elice/material-shared-utils';
|
|
7
|
+
import classnames from 'classnames';
|
|
8
|
+
import VideoPlayer from '../video-player/VideoPlayer.js';
|
|
9
|
+
import * as locales from './locales.js';
|
|
10
|
+
import { en } from './locales.js';
|
|
11
|
+
import { StyledMaterialVideoFileWrap } from './MaterialVideoFile.styled.js';
|
|
12
|
+
|
|
13
|
+
const MaterialVideoFile = _a => {
|
|
14
|
+
var _b;
|
|
15
|
+
|
|
16
|
+
var {
|
|
17
|
+
materialVideoFileId,
|
|
18
|
+
className,
|
|
19
|
+
locale = 'en'
|
|
20
|
+
} = _a,
|
|
21
|
+
videoPlayerProps = __rest(_a, ["materialVideoFileId", "className", "locale"]);
|
|
22
|
+
|
|
23
|
+
const prefixCls = 'em-material-video-file';
|
|
24
|
+
const {
|
|
25
|
+
orgNameShort
|
|
26
|
+
} = useMaterialConfig();
|
|
27
|
+
const [materialVideoFile, materialVideoFileStatus] = useMaterialInitFetch(config.init, React.useCallback(signal => getOrgMaterialVideoFileGet({
|
|
28
|
+
materialVideoFileId
|
|
29
|
+
}, {
|
|
30
|
+
signal
|
|
31
|
+
}), [materialVideoFileId]));
|
|
32
|
+
|
|
33
|
+
const makeOtpKey = async () => {
|
|
34
|
+
return postGlobalAuthOtpKeyMake().then(res => res.otpKey);
|
|
35
|
+
}; //
|
|
36
|
+
//
|
|
37
|
+
//
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
return React.createElement(StyledMaterialVideoFileWrap, {
|
|
41
|
+
className: classnames(prefixCls, className)
|
|
42
|
+
}, React.createElement(IntlProvider, {
|
|
43
|
+
locale: locale,
|
|
44
|
+
defaultLocale: "en",
|
|
45
|
+
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,
|
|
48
|
+
orgNameShort: orgNameShort,
|
|
49
|
+
videoGetStatus: materialVideoFileStatus,
|
|
50
|
+
onOtpRequest: makeOtpKey
|
|
51
|
+
})) : React.createElement(Spinner, null)));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { MaterialVideoFile as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const StyledMaterialVideoFileWrap: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { base } from '@elice/design-tokens';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
const StyledMaterialVideoFileWrap = styled.div.withConfig({
|
|
5
|
+
componentId: "sc-1a1otok-0"
|
|
6
|
+
})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:100%;background:", ";"], base.color.gray9);
|
|
7
|
+
|
|
8
|
+
export { StyledMaterialVideoFileWrap };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const en = {
|
|
2
|
+
'videoFile.player.preparing': 'Material on preparing.',
|
|
3
|
+
'videoFile.player.uploadVideoBtn': 'Upload File',
|
|
4
|
+
'videoFile.player.onEncoding': 'Encoding file..',
|
|
5
|
+
'videoFile.player.noVideo': 'This file does not exist.'
|
|
6
|
+
};
|
|
7
|
+
const ko = {
|
|
8
|
+
'videoFile.player.preparing': '자료를 준비 중입니다.',
|
|
9
|
+
'videoFile.player.uploadVideoBtn': '파일 업로드',
|
|
10
|
+
'videoFile.player.onEncoding': '파일 인코딩 중..',
|
|
11
|
+
'videoFile.player.noVideo': '존재하지 않는 파일입니다.'
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { en, ko };
|
|
@@ -0,0 +1,39 @@
|
|
|
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;
|
|
@@ -0,0 +1,150 @@
|
|
|
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 };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
const StyledVideoPlayerWrap = styled.iframe.withConfig({
|
|
4
|
+
componentId: "sc-6gevcy-0"
|
|
5
|
+
})(["width:100%;height:100%;border:0;"]);
|
|
6
|
+
const StyledVideoPlayerLoading = styled.div.withConfig({
|
|
7
|
+
componentId: "sc-6gevcy-1"
|
|
8
|
+
})(["width:100%;height:100%;display:flex;align-items:center;justify-content:center;"]);
|
|
9
|
+
|
|
10
|
+
export { StyledVideoPlayerLoading, StyledVideoPlayerWrap };
|
package/es/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/material-video-file';
|
package/es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as MaterialVideoFile } from './components/material-video-file/MaterialVideoFile.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@elice/material-video-file",
|
|
3
|
+
"version": "1.220803.0",
|
|
4
|
+
"description": "User view and editing components of Elice material video file",
|
|
5
|
+
"repository": "https://git.elicer.io/elice/frontend/library/elice-material",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"main": "./cjs/index.js",
|
|
8
|
+
"module": "./es/index.js",
|
|
9
|
+
"types": "./es/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"es",
|
|
12
|
+
"cjs",
|
|
13
|
+
"package.json",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": "~16.14",
|
|
19
|
+
"yarn": ">=1.20 <2"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"start": "run-s watch",
|
|
23
|
+
"prebuild": "run-s clean",
|
|
24
|
+
"build": "run-p build:es build:cjs",
|
|
25
|
+
"build:es": "rollup -c ../../rollup.config.ts -f es",
|
|
26
|
+
"build:cjs": "rollup -c ../../rollup.config.ts -f cjs",
|
|
27
|
+
"watch": "rollup -c ../../rollup.config.ts -f es -w",
|
|
28
|
+
"lint": "eslint --ext .ts,.tsx ./src --max-warnings=0",
|
|
29
|
+
"clean": "del-cli \"es/*\" \"cjs/*\" \"dist/*\""
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@elice/api-client": "^1.220802.1",
|
|
33
|
+
"@elice/blocks": "^1.220803.0",
|
|
34
|
+
"@elice/design-tokens": "^1.220803.0",
|
|
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.220802.1",
|
|
39
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
40
|
+
"react-intl": "^5.0.0",
|
|
41
|
+
"react-use": "^17.0.0",
|
|
42
|
+
"styled-components": "^5.2.0"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"classnames": "^2.2.0",
|
|
46
|
+
"query-string": "^7.1.0",
|
|
47
|
+
"tslib": "^2.3.1"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@elice/api-client": "^1.220802.1",
|
|
51
|
+
"@elice/blocks": "^1.220803.0",
|
|
52
|
+
"@elice/design-tokens": "^1.220803.0",
|
|
53
|
+
"@elice/icons": "^1.220803.0",
|
|
54
|
+
"@elice/icons-legacy": "npm:@elice/icons@0.220803.1",
|
|
55
|
+
"@elice/material-shared-types": "1.220803.0",
|
|
56
|
+
"@elice/material-shared-utils": "1.220803.0",
|
|
57
|
+
"@elice/types": "^1.220802.1",
|
|
58
|
+
"@types/classnames": "^2.3.1",
|
|
59
|
+
"@types/query-string": "^6.3.0",
|
|
60
|
+
"@types/react": "~17.0.9",
|
|
61
|
+
"@types/styled-components": "^5.1.21",
|
|
62
|
+
"react": "^17.0.2",
|
|
63
|
+
"react-intl": "^5.20.10",
|
|
64
|
+
"react-use": "^17.2.4",
|
|
65
|
+
"styled-components": "^5.3.0"
|
|
66
|
+
},
|
|
67
|
+
"gitHead": "21c6b42ae6550e7899c57bf39fa78cea0f47e64c"
|
|
68
|
+
}
|