@cloud-app-dev/vidc 3.0.10 → 3.0.13
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/.prettierrc +1 -1
- package/.umirc.ts +1 -1
- package/clear-cache.sh +4 -0
- package/es/CustomRenderSelect/index.d.ts +1 -1
- package/es/CustomRenderSelect/index.js +8 -2
- package/es/List/DynamicGridList/index.js +4 -3
- package/es/List/DynamicList/utils.d.ts +1 -1
- package/es/List/DynamicList/utils.js +1 -1
- package/es/List/GridList/Demo.js +1 -1
- package/es/Player/api/index.d.ts +4 -4
- package/es/Player/contraller_bar/contraller_event.js +1 -1
- package/es/Player/event/errorEvent.d.ts +2 -2
- package/es/Player/event/errorEvent.js +2 -2
- package/es/Player/frontend_player.js +1 -0
- package/es/Player/live_heart.d.ts +4 -2
- package/es/Player/live_heart.js +24 -12
- package/es/Player/message.js +4 -4
- package/es/Player/player.d.ts +4 -4
- package/es/Player/single_player.js +2 -1
- package/es/Player/util.d.ts +1 -1
- package/es/Player/util.js +17 -22
- package/es/ScreenPlayer/Live.d.ts +6 -1
- package/es/ScreenPlayer/Live.js +54 -12
- package/es/ScreenPlayer/LiveTools.d.ts +3 -1
- package/es/ScreenPlayer/LiveTools.js +16 -10
- package/es/ScreenPlayer/PlayerWithExt.js +2 -2
- package/es/ScreenPlayer/Record.d.ts +1 -1
- package/es/ScreenPlayer/Record.js +43 -11
- package/es/ScreenPlayer/RecordTools.d.ts +2 -1
- package/es/ScreenPlayer/RecordTools.js +6 -4
- package/es/ScreenPlayer/SegmentTimeLine.d.ts +2 -2
- package/es/ScreenPlayer/SegmentTimeLine.js +17 -36
- package/es/ScreenPlayer/TimeSlider.d.ts +2 -2
- package/es/ScreenPlayer/TimeSlider.js +15 -15
- package/es/ScreenPlayer/demo.js +4 -4
- package/es/ScreenPlayer/demo2.js +1 -1
- package/es/ScreenPlayer/index.css +3 -0
- package/es/ScreenPlayer/interface.d.ts +19 -2
- package/es/ScreenPlayer/useTimeSlider.d.ts +22 -0
- package/es/ScreenPlayer/useTimeSlider.js +519 -0
- package/es/ScreenPlayer/utils.js +1 -1
- package/package.json +2 -2
package/.prettierrc
CHANGED
package/.umirc.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { defineConfig } from 'dumi';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
|
|
4
4
|
const token =
|
|
5
|
-
'eyJhbGciOiJIUzI1NiJ9.
|
|
5
|
+
'eyJhbGciOiJIUzI1NiJ9.eyJvcmdhbml6YXRpb25JZCI6IjEwMDEwMTAwMDQ0NSIsImV4dCI6MTY2MjI1ODMwNzUxNSwidWlkIjoiMTAxMDAwMDAwNjk5IiwidmFsaWRTdGF0ZSI6MTA0NDA2LCJyb2xlSWQiOlsxMDAwMDAxMTA1MTgsMTAwMDAwMTEwNzI4XSwidmFsaWRUaW1lIjoxNzA0MzgzOTk5MDAwLCJvcHRDZW50ZXJJZCI6IjEwMDEwMDAwMDIzMyIsInVzZXJUeXBlIjoxMDA3MDQsImlhdCI6MTY2MTk5OTEwNzUxNX0.uk_G3vqBCFqxQM2jbV6CSN-z9YNVt_cx5nWXkSuCOIA';
|
|
6
6
|
|
|
7
7
|
export default defineConfig({
|
|
8
8
|
title: 'CloudApp VIDC',
|
package/clear-cache.sh
ADDED
|
@@ -6,5 +6,5 @@ interface ICustomRenderSelectProps extends SelectProps {
|
|
|
6
6
|
value: any;
|
|
7
7
|
customRender: (value: any) => JSX.Element;
|
|
8
8
|
}
|
|
9
|
-
declare function CustomRenderSelect({ children, value, customRender, dropdownClassName, ...props }: ICustomRenderSelectProps): JSX.Element;
|
|
9
|
+
declare function CustomRenderSelect({ children, value, customRender, dropdownClassName, getPopupContainer, ...props }: ICustomRenderSelectProps): JSX.Element;
|
|
10
10
|
export default CustomRenderSelect;
|
|
@@ -25,7 +25,8 @@ function CustomRenderSelect(_a) {
|
|
|
25
25
|
value = _a.value,
|
|
26
26
|
customRender = _a.customRender,
|
|
27
27
|
dropdownClassName = _a.dropdownClassName,
|
|
28
|
-
|
|
28
|
+
getPopupContainer = _a.getPopupContainer,
|
|
29
|
+
props = __rest(_a, ["children", "value", "customRender", "dropdownClassName", "getPopupContainer"]);
|
|
29
30
|
|
|
30
31
|
var classname = useMemo(function () {
|
|
31
32
|
return "custom-render-select-dropdown-".concat(_uuid());
|
|
@@ -57,11 +58,16 @@ function CustomRenderSelect(_a) {
|
|
|
57
58
|
}, /*#__PURE__*/React.createElement(_Select, Object.assign({}, props, {
|
|
58
59
|
value: value,
|
|
59
60
|
dropdownClassName: "custom-render-select-dropdown ".concat(classname, " ").concat(dropdownClassName),
|
|
61
|
+
getPopupContainer: getPopupContainer ? getPopupContainer : function () {
|
|
62
|
+
return domRef.current.parentElement.parentElement;
|
|
63
|
+
},
|
|
60
64
|
open: open
|
|
61
65
|
}), children), /*#__PURE__*/React.createElement("div", {
|
|
62
66
|
className: "custom-render-box",
|
|
63
67
|
onClick: toggle
|
|
64
|
-
}, customRender(value))
|
|
68
|
+
}, customRender(value)), /*#__PURE__*/React.createElement("div", {
|
|
69
|
+
className: "popup-container"
|
|
70
|
+
}));
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
export default CustomRenderSelect;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import "antd/lib/message/style";
|
|
2
2
|
import _message from "antd/lib/message";
|
|
3
|
+
import _useUpdateEffect from "ahooks/es/useUpdateEffect";
|
|
3
4
|
import { __rest } from "tslib";
|
|
4
|
-
import React, {
|
|
5
|
+
import React, { useMemo, useRef } from 'react';
|
|
5
6
|
import GridList from '../GridList';
|
|
6
7
|
import useInfiniteScroll from '../../useInfiniteScroll';
|
|
7
8
|
|
|
@@ -28,8 +29,8 @@ function DynamicGridList(_a) {
|
|
|
28
29
|
data = _useInfiniteScroll.data,
|
|
29
30
|
noMore = _useInfiniteScroll.noMore;
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
return _message.success('数据已全部加载完成!');
|
|
32
|
+
_useUpdateEffect(function () {
|
|
33
|
+
return noMore && _message.success('数据已全部加载完成!');
|
|
33
34
|
}, [noMore]);
|
|
34
35
|
|
|
35
36
|
function getItemData(data) {
|
package/es/List/GridList/Demo.js
CHANGED
package/es/Player/api/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Flvjs from '@cloud-app-dev/flv.js';
|
|
2
2
|
import Hls, { HlsConfig } from 'hls.js';
|
|
3
3
|
import type { FlvPlayerConfig } from '../player';
|
|
4
4
|
declare class Api {
|
|
@@ -57,9 +57,9 @@ declare class Api {
|
|
|
57
57
|
}
|
|
58
58
|
export declare type TypeAndPlay = {
|
|
59
59
|
type?: string;
|
|
60
|
-
flv?:
|
|
60
|
+
flv?: Flvjs.Player;
|
|
61
61
|
hls?: Hls;
|
|
62
62
|
};
|
|
63
|
-
export declare function useTypeAndPlay(url?: string, type?: string, isLive?: boolean, container?: HTMLElement, segments?:
|
|
64
|
-
export declare function usePlayerApi(url?: string, type?: string, isLive?: boolean, container?: HTMLElement, segments?:
|
|
63
|
+
export declare function useTypeAndPlay(url?: string, type?: string, isLive?: boolean, container?: HTMLElement, segments?: Flvjs.MediaSegment[], flvConfig?: FlvPlayerConfig, hlsConfig?: HlsConfig): [string, Flvjs.Player, Hls];
|
|
64
|
+
export declare function usePlayerApi(url?: string, type?: string, isLive?: boolean, container?: HTMLElement, segments?: Flvjs.MediaSegment[], flvConfig?: FlvPlayerConfig, hlsConfig?: HlsConfig): [Api, [string, Flvjs.Player, Hls]];
|
|
65
65
|
export default Api;
|
|
@@ -47,7 +47,7 @@ function ContrallerEvent(_ref) {
|
|
|
47
47
|
container.removeEventListener('mouseenter', showContraller, false);
|
|
48
48
|
container.removeEventListener('mouseleave', hideContraller, false);
|
|
49
49
|
};
|
|
50
|
-
}, [event]);
|
|
50
|
+
}, [container, event]);
|
|
51
51
|
return /*#__PURE__*/React.createElement(React.Fragment, null, React.Children.map(children, function (child) {
|
|
52
52
|
return /*#__PURE__*/React.isValidElement(child) ? /*#__PURE__*/React.cloneElement(child, {
|
|
53
53
|
visibel: visibel
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type VideoEventInstance from '.';
|
|
3
3
|
import type Api from '../api';
|
|
4
|
-
import
|
|
4
|
+
import Flvjs from '@cloud-app-dev/flv.js';
|
|
5
5
|
import Hls from 'hls.js';
|
|
6
6
|
interface IErrorEventProps {
|
|
7
7
|
event: VideoEventInstance;
|
|
8
8
|
api: Api;
|
|
9
9
|
errorReloadTimer: number;
|
|
10
|
-
flv:
|
|
10
|
+
flv: Flvjs.Player;
|
|
11
11
|
hls: Hls;
|
|
12
12
|
reload: () => void;
|
|
13
13
|
unload: () => void;
|
|
@@ -20,7 +20,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
20
20
|
|
|
21
21
|
import React, { useState, useEffect, useRef } from 'react';
|
|
22
22
|
import EventName from './eventName';
|
|
23
|
-
import
|
|
23
|
+
import Flvjs from '@cloud-app-dev/flv.js';
|
|
24
24
|
import Hls from 'hls.js';
|
|
25
25
|
|
|
26
26
|
function ErrorEvent(_ref) {
|
|
@@ -70,7 +70,7 @@ function ErrorEvent(_ref) {
|
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
if (flv) {
|
|
73
|
-
flv.on(
|
|
73
|
+
flv.on(Flvjs.Events.ERROR, errorHandle);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
if (hls) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import Api from './api';
|
|
3
|
-
|
|
2
|
+
import type Api from './api';
|
|
3
|
+
import type VideoEventInstance from './event';
|
|
4
|
+
declare function LiveHeart({ api, event }: {
|
|
4
5
|
api: Api;
|
|
6
|
+
event: VideoEventInstance;
|
|
5
7
|
}): JSX.Element;
|
|
6
8
|
export default LiveHeart;
|
package/es/Player/live_heart.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import _useRafInterval from "ahooks/es/useRafInterval";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import _useUpdateEffect from "ahooks/es/useUpdateEffect";
|
|
3
|
+
import _useDocumentVisibility from "ahooks/es/useDocumentVisibility";
|
|
4
|
+
import React, { useRef } from 'react';
|
|
5
|
+
import Events from './event/eventName';
|
|
4
6
|
|
|
5
7
|
function LiveHeart(_ref) {
|
|
6
|
-
var api = _ref.api
|
|
8
|
+
var api = _ref.api,
|
|
9
|
+
event = _ref.event;
|
|
10
|
+
|
|
11
|
+
var documentVisibility = _useDocumentVisibility();
|
|
12
|
+
|
|
13
|
+
var cTimeRef = useRef(null);
|
|
7
14
|
|
|
8
15
|
var run = function run() {
|
|
9
16
|
var current = api.getCurrentTime();
|
|
@@ -16,21 +23,26 @@ function LiveHeart(_ref) {
|
|
|
16
23
|
}
|
|
17
24
|
};
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
26
|
+
_useUpdateEffect(function () {
|
|
27
|
+
return run();
|
|
28
|
+
}, [documentVisibility]);
|
|
23
29
|
|
|
24
|
-
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
|
-
}, [api]);
|
|
30
|
+
_useRafInterval(function () {
|
|
31
|
+
return cTimeRef.current = api.getCurrentTime();
|
|
32
|
+
}, 1 * 1000);
|
|
29
33
|
|
|
30
34
|
_useRafInterval(function () {
|
|
31
35
|
return run();
|
|
32
36
|
}, 30 * 1000);
|
|
33
37
|
|
|
38
|
+
_useRafInterval(function () {
|
|
39
|
+
var cuurentTime = api.getCurrentTime();
|
|
40
|
+
|
|
41
|
+
if (!api.video.paused && cuurentTime === cTimeRef.current) {
|
|
42
|
+
event.emit(Events.ERROR);
|
|
43
|
+
}
|
|
44
|
+
}, 20 * 1000);
|
|
45
|
+
|
|
34
46
|
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
35
47
|
}
|
|
36
48
|
|
package/es/Player/message.js
CHANGED
|
@@ -110,8 +110,8 @@ function VideoMessage(_ref) {
|
|
|
110
110
|
api.pause();
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
event.addEventListener('loadstart', openLoading);
|
|
114
|
-
|
|
113
|
+
event.addEventListener('loadstart', openLoading); // event.addEventListener('waiting', openLoading);
|
|
114
|
+
// event.addEventListener('seeking', openLoading)
|
|
115
115
|
|
|
116
116
|
event.addEventListener('loadeddata', closeLoading);
|
|
117
117
|
event.addEventListener('canplay', closeLoading);
|
|
@@ -122,8 +122,8 @@ function VideoMessage(_ref) {
|
|
|
122
122
|
event.on(EventName.HISTORY_PLAY_END, playEnd);
|
|
123
123
|
event.on(EventName.CLEAR_ERROR_TIMER, reloadSuccess);
|
|
124
124
|
return function () {
|
|
125
|
-
event.removeEventListener('loadstart', openLoading);
|
|
126
|
-
|
|
125
|
+
event.removeEventListener('loadstart', openLoading); // event.removeEventListener('waiting', openLoading);
|
|
126
|
+
// event.removeEventListener('seeking', openLoading)
|
|
127
127
|
|
|
128
128
|
event.removeEventListener('loadeddata', closeLoading);
|
|
129
129
|
event.removeEventListener('canplay', closeLoading);
|
package/es/Player/player.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type Flvjs from '@cloud-app-dev/flv.js';
|
|
2
2
|
import type Hls, { HlsConfig } from 'hls.js';
|
|
3
3
|
import type React from 'react';
|
|
4
4
|
import type Api from './api';
|
|
5
5
|
import type VideoEventInstance from './event';
|
|
6
6
|
|
|
7
7
|
export type FlvPlayerConfig = {
|
|
8
|
-
mediaDataSource:
|
|
9
|
-
config:
|
|
8
|
+
mediaDataSource: Flvjs.MediaDataSource;
|
|
9
|
+
config: Flvjs.Config;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export interface ISinglePlayerProps {
|
|
@@ -198,7 +198,7 @@ export type ExportPlayerType = {
|
|
|
198
198
|
container: HTMLElement;
|
|
199
199
|
api: Api;
|
|
200
200
|
event: VideoEventInstance;
|
|
201
|
-
plugins: [
|
|
201
|
+
plugins: [Flvjs.Player, Hls];
|
|
202
202
|
fit?: string;
|
|
203
203
|
setIndex?: (i: number) => void;
|
|
204
204
|
seekTo?: (i: number) => void;
|
|
@@ -213,7 +213,8 @@ var SinglePlayer = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
213
213
|
reload: reload,
|
|
214
214
|
errorReloadTimer: errorReloadTimer
|
|
215
215
|
}), isLive && /*#__PURE__*/React.createElement(LiveHeart, {
|
|
216
|
-
api: playApi
|
|
216
|
+
api: playApi,
|
|
217
|
+
event: playEvent
|
|
217
218
|
})), children);
|
|
218
219
|
});
|
|
219
220
|
SinglePlayer.defaultProps = {
|
package/es/Player/util.d.ts
CHANGED
package/es/Player/util.js
CHANGED
|
@@ -3,7 +3,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
3
3
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
4
4
|
|
|
5
5
|
import { __awaiter } from "tslib";
|
|
6
|
-
import Flvjs from 'flv.
|
|
6
|
+
import Flvjs from '@cloud-app-dev/flv.js';
|
|
7
7
|
import Hls from 'hls.js';
|
|
8
8
|
import Events from './event/eventName';
|
|
9
9
|
/**
|
|
@@ -39,21 +39,17 @@ export function createFlvPlayer(video, url, isLive, flvConfig) {
|
|
|
39
39
|
return undefined;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
Flvjs.LoggingControl.enableDebug = false;
|
|
43
|
+
Flvjs.LoggingControl.enableVerbose = false;
|
|
44
|
+
Flvjs.LoggingControl.enableWarn = false;
|
|
42
45
|
var mediaDataSource = Object.assign({
|
|
43
46
|
type: 'flv',
|
|
44
47
|
url: url
|
|
45
48
|
}, flvConfig.mediaDataSource);
|
|
46
49
|
var config = Object.assign({
|
|
47
50
|
enableWorker: true,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// lazyLoadMaxDuration: 0,
|
|
51
|
-
// autoCleanupMaxBackwardDuration: 3,
|
|
52
|
-
// autoCleanupMinBackwardDuration: 2,
|
|
53
|
-
// autoCleanupSourceBuffer: true,
|
|
54
|
-
enableStashBuffer: false,
|
|
55
|
-
stashInitialSize: 128,
|
|
56
|
-
isLive: isLive !== null && isLive !== void 0 ? isLive : true
|
|
51
|
+
isLive: isLive !== null && isLive !== void 0 ? isLive : true,
|
|
52
|
+
enableStashBuffer: !isLive
|
|
57
53
|
}, flvConfig.config);
|
|
58
54
|
var player = Flvjs.createPlayer(mediaDataSource, config);
|
|
59
55
|
player.attachMediaElement(video);
|
|
@@ -65,21 +61,21 @@ export var playReload = function playReload(video, event, flv, hls, url) {
|
|
|
65
61
|
video.removeAttribute('src');
|
|
66
62
|
|
|
67
63
|
if (flv) {
|
|
68
|
-
flv.unload();
|
|
69
|
-
flv.load();
|
|
70
64
|
tryCatch(function () {
|
|
71
|
-
|
|
65
|
+
flv.unload();
|
|
66
|
+
flv.load();
|
|
67
|
+
flv.play();
|
|
72
68
|
});
|
|
73
69
|
}
|
|
74
70
|
|
|
75
71
|
if (hls) {
|
|
76
|
-
hls.swapAudioCodec();
|
|
77
|
-
hls.recoverMediaError();
|
|
78
|
-
hls.stopLoad();
|
|
79
|
-
hls.startLoad();
|
|
80
|
-
hls.loadSource(url);
|
|
81
72
|
tryCatch(function () {
|
|
82
|
-
|
|
73
|
+
hls.swapAudioCodec();
|
|
74
|
+
hls.recoverMediaError();
|
|
75
|
+
hls.stopLoad();
|
|
76
|
+
hls.startLoad();
|
|
77
|
+
hls.loadSource(url);
|
|
78
|
+
video.play();
|
|
83
79
|
});
|
|
84
80
|
}
|
|
85
81
|
|
|
@@ -145,15 +141,14 @@ export function tryCatch(fn) {
|
|
|
145
141
|
return fn();
|
|
146
142
|
|
|
147
143
|
case 3:
|
|
148
|
-
_context.next =
|
|
144
|
+
_context.next = 7;
|
|
149
145
|
break;
|
|
150
146
|
|
|
151
147
|
case 5:
|
|
152
148
|
_context.prev = 5;
|
|
153
149
|
_context.t0 = _context["catch"](0);
|
|
154
|
-
console.debug(_context.t0);
|
|
155
150
|
|
|
156
|
-
case
|
|
151
|
+
case 7:
|
|
157
152
|
case "end":
|
|
158
153
|
return _context.stop();
|
|
159
154
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ILivePlayerProps } from './interface';
|
|
3
3
|
import './index.less';
|
|
4
|
-
declare function LivePlayer({ list, children, onIndexChange, onClose, onCloseAll }: ILivePlayerProps): JSX.Element;
|
|
4
|
+
declare function LivePlayer({ list, children, onIndexChange, onClose, onCloseAll, snapshot, defaultScreen, screenChange, defaultSelectIndex }: ILivePlayerProps): JSX.Element;
|
|
5
|
+
declare namespace LivePlayer {
|
|
6
|
+
var defaultProps: {
|
|
7
|
+
list: any[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
5
10
|
export default LivePlayer;
|
package/es/ScreenPlayer/Live.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _useUpdateEffect from "ahooks/es/useUpdateEffect";
|
|
2
|
+
|
|
1
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
4
|
|
|
3
5
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -26,16 +28,19 @@ import useVideoFit from './useVideoFit';
|
|
|
26
28
|
import "./index.css";
|
|
27
29
|
|
|
28
30
|
function LivePlayer(_ref) {
|
|
29
|
-
var
|
|
30
|
-
list = _ref$list === void 0 ? [] : _ref$list,
|
|
31
|
+
var list = _ref.list,
|
|
31
32
|
children = _ref.children,
|
|
32
33
|
onIndexChange = _ref.onIndexChange,
|
|
33
34
|
onClose = _ref.onClose,
|
|
34
|
-
onCloseAll = _ref.onCloseAll
|
|
35
|
+
onCloseAll = _ref.onCloseAll,
|
|
36
|
+
snapshot = _ref.snapshot,
|
|
37
|
+
defaultScreen = _ref.defaultScreen,
|
|
38
|
+
screenChange = _ref.screenChange,
|
|
39
|
+
defaultSelectIndex = _ref.defaultSelectIndex;
|
|
35
40
|
|
|
36
41
|
var _useState = useState({
|
|
37
|
-
screenNum: 4,
|
|
38
|
-
selectIndex: 0,
|
|
42
|
+
screenNum: defaultScreen !== null && defaultScreen !== void 0 ? defaultScreen : 4,
|
|
43
|
+
selectIndex: defaultSelectIndex !== null && defaultSelectIndex !== void 0 ? defaultSelectIndex : 0,
|
|
39
44
|
modes: []
|
|
40
45
|
}),
|
|
41
46
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -87,18 +92,50 @@ function LivePlayer(_ref) {
|
|
|
87
92
|
setState(function (old) {
|
|
88
93
|
return Object.assign(Object.assign({}, old), obj);
|
|
89
94
|
});
|
|
90
|
-
}; //
|
|
91
|
-
|
|
95
|
+
}; // 当前窗口信息
|
|
96
|
+
|
|
92
97
|
|
|
98
|
+
var segmentItem = useMemo(function () {
|
|
99
|
+
return list[state.selectIndex] || {};
|
|
100
|
+
}, [state.selectIndex, list]);
|
|
101
|
+
/**
|
|
102
|
+
* 同步外部的selectIndex变化
|
|
103
|
+
*/
|
|
93
104
|
|
|
94
105
|
useEffect(function () {
|
|
95
|
-
|
|
106
|
+
if (typeof defaultSelectIndex !== 'number') {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
setState(function (old) {
|
|
111
|
+
if (old.selectIndex !== defaultSelectIndex) {
|
|
112
|
+
return Object.assign(Object.assign({}, old), {
|
|
113
|
+
selectIndex: defaultSelectIndex
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return old;
|
|
118
|
+
});
|
|
119
|
+
}, [defaultSelectIndex]); // index变化同步到父组件
|
|
120
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
121
|
+
|
|
122
|
+
_useUpdateEffect(function () {
|
|
123
|
+
return onIndexChange && onIndexChange(state.selectIndex);
|
|
96
124
|
}, [state.selectIndex]);
|
|
125
|
+
/**
|
|
126
|
+
* 通知screenNum变化
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
_useUpdateEffect(function () {
|
|
131
|
+
return screenChange && onIndexChange(state.screenNum);
|
|
132
|
+
}, [state.screenNum]);
|
|
133
|
+
|
|
97
134
|
return /*#__PURE__*/React.createElement("div", {
|
|
98
|
-
className: "split-screen-player-wrapper"
|
|
99
|
-
ref: domRef
|
|
135
|
+
className: "split-screen-player-wrapper split-screen-player-live-wrapper"
|
|
100
136
|
}, /*#__PURE__*/React.createElement("div", {
|
|
101
|
-
className: "player-layout"
|
|
137
|
+
className: "player-layout",
|
|
138
|
+
ref: domRef
|
|
102
139
|
}, screenList.map(function (item, index) {
|
|
103
140
|
var _a;
|
|
104
141
|
|
|
@@ -126,15 +163,20 @@ function LivePlayer(_ref) {
|
|
|
126
163
|
onClose: onClose,
|
|
127
164
|
onCloseAll: onCloseAll,
|
|
128
165
|
fit: fit,
|
|
166
|
+
disabled: !segmentItem.url,
|
|
129
167
|
toggleFit: toggleFit,
|
|
130
168
|
getPlayerItem: getPlayerItem,
|
|
131
169
|
screenNum: state.screenNum,
|
|
132
170
|
mode: state.modes[state.selectIndex],
|
|
133
171
|
containerRef: domRef,
|
|
134
|
-
updateState: updateState
|
|
172
|
+
updateState: updateState,
|
|
173
|
+
snapshot: snapshot
|
|
135
174
|
}), children && /*#__PURE__*/React.cloneElement(children, {
|
|
136
175
|
selectIndex: state.selectIndex
|
|
137
176
|
}));
|
|
138
177
|
}
|
|
139
178
|
|
|
179
|
+
LivePlayer.defaultProps = {
|
|
180
|
+
list: []
|
|
181
|
+
};
|
|
140
182
|
export default LivePlayer;
|
|
@@ -14,6 +14,8 @@ interface IToolsProps {
|
|
|
14
14
|
toggleFit?: () => void;
|
|
15
15
|
onClose?: () => void;
|
|
16
16
|
onCloseAll?: () => void;
|
|
17
|
+
disabled: boolean;
|
|
18
|
+
snapshot?: (base64?: string) => void;
|
|
17
19
|
}
|
|
18
|
-
declare function LiveTools({ containerRef, updateState, screenNum, getPlayerItem, mode, toggleFit, fit, onClose, onCloseAll }: IToolsProps): JSX.Element;
|
|
20
|
+
declare function LiveTools({ containerRef, updateState, screenNum, getPlayerItem, mode, toggleFit, fit, onClose, onCloseAll, disabled, snapshot }: IToolsProps): JSX.Element;
|
|
19
21
|
export default LiveTools;
|
|
@@ -16,6 +16,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
16
16
|
import React from 'react';
|
|
17
17
|
import IconFont from '../Player/iconfont';
|
|
18
18
|
import ScreenSelect from './ScreenSelect';
|
|
19
|
+
import DisableMark from '../DisableMark';
|
|
19
20
|
|
|
20
21
|
function LiveTools(_ref) {
|
|
21
22
|
var containerRef = _ref.containerRef,
|
|
@@ -26,7 +27,9 @@ function LiveTools(_ref) {
|
|
|
26
27
|
toggleFit = _ref.toggleFit,
|
|
27
28
|
fit = _ref.fit,
|
|
28
29
|
onClose = _ref.onClose,
|
|
29
|
-
onCloseAll = _ref.onCloseAll
|
|
30
|
+
onCloseAll = _ref.onCloseAll,
|
|
31
|
+
disabled = _ref.disabled,
|
|
32
|
+
snapshot = _ref.snapshot;
|
|
30
33
|
|
|
31
34
|
var _useFullscreen = _useFullscreen3(containerRef),
|
|
32
35
|
_useFullscreen2 = _slicedToArray(_useFullscreen, 2),
|
|
@@ -50,14 +53,17 @@ function LiveTools(_ref) {
|
|
|
50
53
|
player ? player.reload ? player.reload() : player.api.reload() : undefined;
|
|
51
54
|
};
|
|
52
55
|
|
|
53
|
-
var
|
|
56
|
+
var snapshotaction = function snapshotaction() {
|
|
54
57
|
var player = getPlayerItem();
|
|
55
|
-
|
|
58
|
+
var base64 = player ? player.api.snapshot() : undefined;
|
|
59
|
+
snapshot && snapshot(base64);
|
|
56
60
|
};
|
|
57
61
|
|
|
58
62
|
var player = getPlayerItem();
|
|
59
63
|
return /*#__PURE__*/React.createElement("div", {
|
|
60
64
|
className: "player-tools"
|
|
65
|
+
}, /*#__PURE__*/React.createElement(DisableMark, {
|
|
66
|
+
disabled: disabled
|
|
61
67
|
}, /*#__PURE__*/React.createElement("div", {
|
|
62
68
|
className: "player-tools-left"
|
|
63
69
|
}, /*#__PURE__*/React.createElement("span", {
|
|
@@ -70,7 +76,7 @@ function LiveTools(_ref) {
|
|
|
70
76
|
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
71
77
|
type: "lm-player-xiangji1fill",
|
|
72
78
|
title: "\u622A\u56FE",
|
|
73
|
-
onClick:
|
|
79
|
+
onClick: snapshotaction
|
|
74
80
|
})), /*#__PURE__*/React.createElement("span", {
|
|
75
81
|
className: "player-tools-item",
|
|
76
82
|
onClick: reload
|
|
@@ -92,9 +98,7 @@ function LiveTools(_ref) {
|
|
|
92
98
|
},
|
|
93
99
|
type: "lm-player-S_Device_shezhi",
|
|
94
100
|
title: "\u5207\u6362".concat(mode === 1 ? '插件' : '浏览器', "\u6A21\u5F0F")
|
|
95
|
-
}))
|
|
96
|
-
className: "player-tools-mid"
|
|
97
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
101
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
98
102
|
className: "player-tools-item",
|
|
99
103
|
onClick: onClose,
|
|
100
104
|
style: {
|
|
@@ -104,11 +108,13 @@ function LiveTools(_ref) {
|
|
|
104
108
|
type: "lm-player-tingzhi",
|
|
105
109
|
title: "\u505C\u6B62",
|
|
106
110
|
style: {
|
|
107
|
-
fontSize:
|
|
111
|
+
fontSize: 14,
|
|
108
112
|
position: 'relative',
|
|
109
113
|
top: 1
|
|
110
114
|
}
|
|
111
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
115
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
116
|
+
className: "player-tools-mid"
|
|
117
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
112
118
|
className: "player-tools-item",
|
|
113
119
|
onClick: playToggle,
|
|
114
120
|
style: {
|
|
@@ -163,7 +169,7 @@ function LiveTools(_ref) {
|
|
|
163
169
|
}) : /*#__PURE__*/React.createElement(IconFont, {
|
|
164
170
|
type: "lm-player-quanping",
|
|
165
171
|
title: "\u5168\u5C4F"
|
|
166
|
-
}))));
|
|
172
|
+
})))));
|
|
167
173
|
}
|
|
168
174
|
|
|
169
175
|
export default LiveTools;
|