@cloud-app-dev/vidc 3.0.17 → 3.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/.umirc.ts +1 -1
  2. package/es/Map/hook/useMapEvent.js +9 -8
  3. package/es/Player/api/index.d.ts +3 -1
  4. package/es/Player/api/index.js +27 -24
  5. package/es/Player/context.d.ts +21 -0
  6. package/es/Player/context.js +16 -0
  7. package/es/Player/contraller_bar/contraller_event.d.ts +1 -4
  8. package/es/Player/contraller_bar/contraller_event.js +37 -28
  9. package/es/Player/contraller_bar/index.d.ts +2 -7
  10. package/es/Player/contraller_bar/index.js +4 -12
  11. package/es/Player/contraller_bar/left_bar.d.ts +2 -7
  12. package/es/Player/contraller_bar/left_bar.js +26 -23
  13. package/es/Player/contraller_bar/right_bar.d.ts +1 -6
  14. package/es/Player/contraller_bar/right_bar.js +6 -3
  15. package/es/Player/contraller_bar/useBarStatus.js +17 -24
  16. package/es/Player/demo.js +5 -1
  17. package/es/Player/event/errorEvent.js +34 -43
  18. package/es/Player/event/eventName.d.ts +17 -2
  19. package/es/Player/event/eventName.js +5 -1
  20. package/es/Player/event/index.d.ts +2 -0
  21. package/es/Player/event/index.js +55 -3
  22. package/es/Player/fps_play.d.ts +10 -0
  23. package/es/Player/fps_play.js +80 -0
  24. package/es/Player/frontend_player.js +0 -2
  25. package/es/Player/frontend_timeline.d.ts +1 -5
  26. package/es/Player/frontend_timeline.js +8 -4
  27. package/es/Player/live_heart.js +1 -1
  28. package/es/Player/message.js +69 -84
  29. package/es/Player/player.d.ts +10 -15
  30. package/es/Player/segment_player.js +13 -29
  31. package/es/Player/segment_timeline.d.ts +1 -6
  32. package/es/Player/segment_timeline.js +11 -7
  33. package/es/Player/single_player.js +76 -35
  34. package/es/Player/style/bar.css +1 -0
  35. package/es/Player/style/index.css +8 -0
  36. package/es/Player/timeline.d.ts +1 -1
  37. package/es/Player/timeline.js +26 -37
  38. package/es/Player/util.d.ts +1 -1
  39. package/es/Player/util.js +2 -5
  40. package/es/ScreenPlayer/Live.js +0 -1
  41. package/es/ScreenPlayer/PlayerWithExt.d.ts +1 -1
  42. package/es/ScreenPlayer/PlayerWithExt.js +2 -4
  43. package/es/ScreenPlayer/Record.js +0 -1
  44. package/es/ScreenPlayer/demo2.js +1 -1
  45. package/es/index.d.ts +1 -0
  46. package/es/index.js +1 -0
  47. package/es/useRafInterval/index.d.ts +5 -0
  48. package/es/useRafInterval/index.js +94 -0
  49. package/package.json +1 -1
  50. package/es/Player/event/browserTabEvent.d.ts +0 -9
  51. package/es/Player/event/browserTabEvent.js +0 -57
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.eyJvcmdhbml6YXRpb25JZCI6IjEwMDEwMTAwMDQ0NSIsImV4dCI6MTY2MjI1ODMwNzUxNSwidWlkIjoiMTAxMDAwMDAwNjk5IiwidmFsaWRTdGF0ZSI6MTA0NDA2LCJyb2xlSWQiOlsxMDAwMDAxMTA1MTgsMTAwMDAwMTEwNzI4XSwidmFsaWRUaW1lIjoxNzA0MzgzOTk5MDAwLCJvcHRDZW50ZXJJZCI6IjEwMDEwMDAwMDIzMyIsInVzZXJUeXBlIjoxMDA3MDQsImlhdCI6MTY2MTk5OTEwNzUxNX0.uk_G3vqBCFqxQM2jbV6CSN-z9YNVt_cx5nWXkSuCOIA';
5
+ 'eyJhbGciOiJIUzI1NiJ9.eyJvcmdhbml6YXRpb25JZCI6IjEwMDEwMTAwMDQ0NSIsImV4dCI6MTY2MzQwNTM5ODYzOCwidWlkIjoiMTAxMDAwMDAwNjk5IiwidmFsaWRTdGF0ZSI6MTA0NDA2LCJyb2xlSWQiOlsxMDAwMDAxMTA1MTgsMTAwMDAwMTEwNzI4XSwidmFsaWRUaW1lIjoxNzA0MzgzOTk5MDAwLCJvcHRDZW50ZXJJZCI6IjEwMDEwMDAwMDIzMyIsInVzZXJUeXBlIjoxMDA3MDQsImlhdCI6MTY2MzE0NjE5ODYzOH0.EPh_1eNPNFl-fmLODbHo0mu5R_1kKdt3UUu_0qfBGFY';
6
6
 
7
7
  export default defineConfig({
8
8
  title: 'CloudApp VIDC',
@@ -1,22 +1,23 @@
1
- import _useCreation from "ahooks/es/useCreation";
1
+ import _useLatest from "ahooks/es/useLatest";
2
2
  import { useContext, useEffect } from 'react';
3
3
  import { mapContext } from '../Context';
4
4
 
5
5
  function useMapEvent(type, fn) {
6
- var action = _useCreation(function () {
7
- return fn;
8
- }, []);
6
+ var fnRef = _useLatest(fn);
9
7
 
10
8
  var _useContext = useContext(mapContext),
11
9
  instance = _useContext.instance;
12
10
 
13
11
  useEffect(function () {
14
- console.log(11111);
15
- instance.on(type, action);
12
+ var eventAction = function eventAction(event) {
13
+ fnRef.current(event);
14
+ };
15
+
16
+ instance.on(type, eventAction);
16
17
  return function () {
17
- return instance.off(type, action);
18
+ return instance.off(type, eventAction);
18
19
  }; // eslint-disable-next-line react-hooks/exhaustive-deps
19
- }, []);
20
+ }, [instance, type]);
20
21
  }
21
22
 
22
23
  export default useMapEvent;
@@ -7,6 +7,7 @@ declare class Api {
7
7
  get video(): HTMLVideoElement;
8
8
  play: () => void;
9
9
  pause: () => void;
10
+ get paused(): boolean;
10
11
  /**
11
12
  * 设置currentTime实现seek
12
13
  * @param {*} seconds
@@ -51,7 +52,8 @@ declare class Api {
51
52
  unload: () => void;
52
53
  reload: () => void;
53
54
  toggleFit: () => void;
54
- setIndex: (i: number) => void;
55
+ openFpsPlay: () => void;
56
+ closeFpsPlay: () => void;
55
57
  destroy: () => void;
56
58
  }
57
59
  export declare type TypeAndPlay = {
@@ -164,7 +164,9 @@ var Api = /*#__PURE__*/function () {
164
164
 
165
165
  this.toggleFit = function () {};
166
166
 
167
- this.setIndex = function (i) {};
167
+ this.openFpsPlay = function () {};
168
+
169
+ this.closeFpsPlay = function () {};
168
170
 
169
171
  this.destroy = function () {
170
172
  _this.container = null;
@@ -178,6 +180,11 @@ var Api = /*#__PURE__*/function () {
178
180
  get: function get() {
179
181
  return this.container.querySelector('video');
180
182
  }
183
+ }, {
184
+ key: "paused",
185
+ get: function get() {
186
+ return this.video.paused;
187
+ }
181
188
  }]);
182
189
 
183
190
  return Api;
@@ -195,37 +202,33 @@ export function useTypeAndPlay(url, type, isLive, container, segments, flvConfig
195
202
  setState = _useState2[1];
196
203
 
197
204
  useEffect(function () {
198
- if (!container) {
205
+ var isReady = container && (url || type === 'flv' && segments);
206
+
207
+ if (!isReady) {
199
208
  return undefined;
200
209
  }
201
210
 
202
211
  var video = container.querySelector('video');
203
212
  var options = {};
204
213
 
205
- if (type === 'flv') {
206
- if (!(url || segments)) {
207
- return undefined;
208
- }
209
-
210
- options.type = 'flv';
211
- options.flv = createFlvPlayer(video, url, isLive, flvConfig);
212
- }
213
-
214
- if (type === 'hls') {
215
- if (!url) {
216
- return undefined;
217
- }
218
-
219
- options.type = 'hls';
220
- options.hls = createHlsPlayer(video, url, hlsConfig);
221
- }
222
-
223
- if (url && type === 'native') {
224
- options.type = 'native';
225
- video.setAttribute('src', url);
214
+ switch (type) {
215
+ case 'flv':
216
+ options.type = 'flv';
217
+ options.flv = createFlvPlayer(video, url, isLive, flvConfig);
218
+ break;
219
+
220
+ case 'hls':
221
+ options.type = 'hls';
222
+ options.hls = createHlsPlayer(video, url, isLive, hlsConfig);
223
+ break;
224
+
225
+ default:
226
+ options.type = 'native';
227
+ video.setAttribute('src', url);
228
+ break;
226
229
  }
227
230
 
228
- url && video.paused && tryCatch(function () {
231
+ video.paused && tryCatch(function () {
229
232
  return video.play();
230
233
  });
231
234
  setState(options);
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import type Api from './api';
3
+ import type VideoEventInstance from './event';
4
+ export interface IPlayerContextProps {
5
+ /**
6
+ * @description 用于获取微应用顶层的dom节点
7
+ */
8
+ container: HTMLElement;
9
+ api: Api;
10
+ event: VideoEventInstance;
11
+ isLive: boolean;
12
+ isFpsPlay: boolean;
13
+ children: React.ReactNode;
14
+ }
15
+ export declare const Context: React.Context<Omit<IPlayerContextProps, "children">>;
16
+ export declare function Provider({ children, ...props }: IPlayerContextProps): JSX.Element;
17
+ export declare namespace Provider {
18
+ var defaultProps: {
19
+ getContainer: () => HTMLElement;
20
+ };
21
+ }
@@ -0,0 +1,16 @@
1
+ import { __rest } from "tslib";
2
+ import React from 'react';
3
+ export var Context = /*#__PURE__*/React.createContext(null);
4
+ export function Provider(_a) {
5
+ var children = _a.children,
6
+ props = __rest(_a, ["children"]);
7
+
8
+ return /*#__PURE__*/React.createElement(Context.Provider, {
9
+ value: Object.assign({}, props)
10
+ }, children);
11
+ }
12
+ Provider.defaultProps = {
13
+ getContainer: function getContainer() {
14
+ return document.body;
15
+ }
16
+ };
@@ -1,9 +1,6 @@
1
1
  import React from 'react';
2
- import VideoEventInstance from '../event';
3
2
  interface IContrallerEventProps {
4
- event?: VideoEventInstance;
5
- container?: HTMLElement;
6
3
  children?: React.ReactNode;
7
4
  }
8
- declare function ContrallerEvent({ event, container, children }: IContrallerEventProps): JSX.Element;
5
+ declare function ContrallerEvent({ children }: IContrallerEventProps): JSX.Element;
9
6
  export default ContrallerEvent;
@@ -1,3 +1,6 @@
1
+ import _useEventListener from "ahooks/es/useEventListener";
2
+ import _useMount from "ahooks/es/useMount";
3
+
1
4
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
5
 
3
6
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -10,13 +13,17 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
10
13
 
11
14
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
15
 
13
- import React, { useEffect, useState, useRef } from 'react';
16
+ import React, { useState, useRef, useContext } from 'react';
17
+ import { Context } from '../context';
14
18
  import EventName from '../event/eventName';
15
19
 
16
20
  function ContrallerEvent(_ref) {
17
- var event = _ref.event,
18
- container = _ref.container,
19
- children = _ref.children;
21
+ var children = _ref.children;
22
+
23
+ var _useContext = useContext(Context),
24
+ event = _useContext.event,
25
+ container = _useContext.container;
26
+
20
27
  var timer = useRef(null);
21
28
 
22
29
  var _useState = useState(true),
@@ -24,30 +31,32 @@ function ContrallerEvent(_ref) {
24
31
  visibel = _useState2[0],
25
32
  setVisibel = _useState2[1];
26
33
 
27
- useEffect(function () {
28
- var showContraller = function showContraller() {
29
- clearTimeout(timer.current);
30
- setVisibel(true);
31
- event.emit(EventName.SHOW_CONTRALLER);
32
- };
33
-
34
- var hideContraller = function hideContraller() {
35
- clearTimeout(timer.current);
36
- timer.current = setTimeout(function () {
37
- setVisibel(false);
38
- event.emit(EventName.HIDE_CONTRALLER);
39
- }, 3 * 1000);
40
- }; // 默认执行延时hide
41
-
42
-
43
- hideContraller();
44
- container.addEventListener('mouseenter', showContraller, false);
45
- container.addEventListener('mouseleave', hideContraller, false);
46
- return function () {
47
- container.removeEventListener('mouseenter', showContraller, false);
48
- container.removeEventListener('mouseleave', hideContraller, false);
49
- };
50
- }, [container, event]);
34
+ var showContraller = function showContraller() {
35
+ clearTimeout(timer.current);
36
+ setVisibel(true);
37
+ event.emit(EventName.SHOW_CONTRALLER);
38
+ };
39
+
40
+ var hideContraller = function hideContraller() {
41
+ clearTimeout(timer.current);
42
+ timer.current = setTimeout(function () {
43
+ setVisibel(false);
44
+ event.emit(EventName.HIDE_CONTRALLER);
45
+ }, 3 * 1000);
46
+ };
47
+
48
+ _useMount(function () {
49
+ return hideContraller();
50
+ });
51
+
52
+ _useEventListener('mouseenter', showContraller, {
53
+ target: container
54
+ });
55
+
56
+ _useEventListener('mouseleave', hideContraller, {
57
+ target: container
58
+ });
59
+
51
60
  return /*#__PURE__*/React.createElement(React.Fragment, null, React.Children.map(children, function (child) {
52
61
  return /*#__PURE__*/React.isValidElement(child) ? /*#__PURE__*/React.cloneElement(child, {
53
62
  visibel: visibel
@@ -1,19 +1,14 @@
1
1
  import React from 'react';
2
- import type Api from '../api';
3
- import type VideoEventInstance from '../event';
4
2
  import '../style/bar.less';
5
3
  interface IContrallerBarProps {
6
- container?: HTMLElement;
7
4
  rightExtContents: React.ReactNode;
8
5
  rightMidExtContents: React.ReactNode;
9
6
  visibel?: boolean;
10
- api: Api;
11
- event: VideoEventInstance;
12
- isLive?: boolean;
13
7
  leftExtContents: React.ReactNode;
14
8
  leftMidExtContents: React.ReactNode;
15
9
  reload: () => void;
16
10
  hideTimeProgress?: boolean;
11
+ oneFpsPlay?: boolean;
17
12
  }
18
- declare function ContrallerBar({ container, rightExtContents, rightMidExtContents, visibel, api, event, isLive, leftExtContents, leftMidExtContents, reload, hideTimeProgress, }: IContrallerBarProps): JSX.Element;
13
+ declare function ContrallerBar({ rightExtContents, rightMidExtContents, visibel, leftExtContents, leftMidExtContents, reload, hideTimeProgress, oneFpsPlay, }: IContrallerBarProps): JSX.Element;
19
14
  export default ContrallerBar;
@@ -4,31 +4,23 @@ import RightBar from './right_bar';
4
4
  import "../style/bar.css";
5
5
 
6
6
  function ContrallerBar(_ref) {
7
- var container = _ref.container,
8
- rightExtContents = _ref.rightExtContents,
7
+ var rightExtContents = _ref.rightExtContents,
9
8
  rightMidExtContents = _ref.rightMidExtContents,
10
9
  visibel = _ref.visibel,
11
- api = _ref.api,
12
- event = _ref.event,
13
- isLive = _ref.isLive,
14
10
  leftExtContents = _ref.leftExtContents,
15
11
  leftMidExtContents = _ref.leftMidExtContents,
16
12
  reload = _ref.reload,
17
- hideTimeProgress = _ref.hideTimeProgress;
13
+ hideTimeProgress = _ref.hideTimeProgress,
14
+ oneFpsPlay = _ref.oneFpsPlay;
18
15
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
19
16
  className: "contraller-bar-layout ".concat(!visibel ? 'hide-contraller-bar' : '')
20
17
  }, /*#__PURE__*/React.createElement(LeftBar, {
18
+ oneFpsPlay: oneFpsPlay,
21
19
  hideTimeProgress: hideTimeProgress,
22
- api: api,
23
20
  reload: reload,
24
- event: event,
25
- container: container,
26
- isLive: isLive,
27
21
  leftMidExtContents: leftMidExtContents,
28
22
  leftExtContents: leftExtContents
29
23
  }), /*#__PURE__*/React.createElement(RightBar, {
30
- api: api,
31
- container: container,
32
24
  rightExtContents: rightExtContents,
33
25
  rightMidExtContents: rightMidExtContents
34
26
  })));
@@ -1,15 +1,10 @@
1
1
  import React from 'react';
2
- import Api from '../api';
3
- import VideoEventInstance from '../event';
4
2
  interface ILeftBarProps {
5
- api: Api;
6
- event: VideoEventInstance;
7
- container: HTMLElement;
8
- isLive: boolean;
9
3
  leftExtContents?: React.ReactNode;
10
4
  leftMidExtContents?: React.ReactNode;
11
5
  reload: () => void;
12
6
  hideTimeProgress?: boolean;
7
+ oneFpsPlay?: boolean;
13
8
  }
14
- declare function LeftBar({ api, event, container, isLive, reload, leftExtContents, leftMidExtContents, hideTimeProgress }: ILeftBarProps): JSX.Element;
9
+ declare function LeftBar({ reload, leftExtContents, leftMidExtContents, hideTimeProgress, oneFpsPlay }: ILeftBarProps): JSX.Element;
15
10
  export default LeftBar;
@@ -10,41 +10,40 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
10
10
 
11
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
- import React, { useState, useEffect, useCallback, useMemo } from 'react';
13
+ import React, { useState, useCallback, useMemo, useContext } from 'react';
14
14
  import IconFont from '../iconfont';
15
15
  import Bar from './bar';
16
16
  import { useTimes } from '../timeline';
17
17
  import { timeStamp } from '../util';
18
+ import { Context } from '../context';
19
+ import { useVideoEvent } from '../event';
18
20
 
19
21
  function LeftBar(_ref) {
20
- var api = _ref.api,
21
- event = _ref.event,
22
- container = _ref.container,
23
- isLive = _ref.isLive,
24
- reload = _ref.reload,
22
+ var reload = _ref.reload,
25
23
  leftExtContents = _ref.leftExtContents,
26
24
  leftMidExtContents = _ref.leftMidExtContents,
27
- hideTimeProgress = _ref.hideTimeProgress;
25
+ hideTimeProgress = _ref.hideTimeProgress,
26
+ oneFpsPlay = _ref.oneFpsPlay;
27
+
28
+ var _useContext = useContext(Context),
29
+ api = _useContext.api,
30
+ event = _useContext.event,
31
+ container = _useContext.container,
32
+ isLive = _useContext.isLive,
33
+ isFpsPlay = _useContext.isFpsPlay;
28
34
 
29
35
  var _useState = useState(Date.now()),
30
36
  _useState2 = _slicedToArray(_useState, 2),
31
37
  dep = _useState2[0],
32
38
  setDep = _useState2[1];
33
39
 
34
- useEffect(function () {
35
- var updateRender = function updateRender() {
36
- return setDep(Date.now());
37
- };
38
-
39
- event.addEventListener('play', updateRender);
40
- event.addEventListener('pause', updateRender);
41
- event.addEventListener('volumechange', updateRender);
42
- return function () {
43
- event.removeEventListener('play', updateRender);
44
- event.removeEventListener('pause', updateRender);
45
- event.removeEventListener('volumechange', updateRender);
46
- };
47
- }, [event]);
40
+ var updateRender = function updateRender() {
41
+ return setDep(Date.now());
42
+ };
43
+
44
+ useVideoEvent('play', updateRender);
45
+ useVideoEvent('pause', updateRender);
46
+ useVideoEvent('volumechange', updateRender);
48
47
  var video = container.querySelector('video'); //缓存值
49
48
  // eslint-disable-next-line react-hooks/exhaustive-deps
50
49
 
@@ -58,7 +57,7 @@ function LeftBar(_ref) {
58
57
  return paused ? '播放' : '暂停';
59
58
  }, [paused]);
60
59
 
61
- var _useTimes = useTimes(api, event, hideTimeProgress),
60
+ var _useTimes = useTimes(api, event, isFpsPlay),
62
61
  _useTimes2 = _slicedToArray(_useTimes, 3),
63
62
  current = _useTimes2[0],
64
63
  duration = _useTimes2[2]; //TODO 方法
@@ -75,7 +74,7 @@ function LeftBar(_ref) {
75
74
  }, [video, api]);
76
75
  return /*#__PURE__*/React.createElement("div", {
77
76
  className: "contraller-left-bar"
78
- }, leftExtContents, /*#__PURE__*/React.createElement(Bar, null, /*#__PURE__*/React.createElement(IconFont, {
77
+ }, leftExtContents, !isFpsPlay && /*#__PURE__*/React.createElement(Bar, null, /*#__PURE__*/React.createElement(IconFont, {
79
78
  onClick: changePlayStatus,
80
79
  type: statusIconClassName,
81
80
  title: statusText
@@ -85,6 +84,10 @@ function LeftBar(_ref) {
85
84
  onClick: reload,
86
85
  type: "lm-player-Refresh_Main",
87
86
  title: "\u91CD\u8F7D"
87
+ })), !isLive && oneFpsPlay && /*#__PURE__*/React.createElement(Bar, null, /*#__PURE__*/React.createElement(IconFont, {
88
+ onClick: isFpsPlay ? api.closeFpsPlay : api.openFpsPlay,
89
+ type: "lm-player-Refresh_Main",
90
+ title: "\u9010\u5E27\u64AD\u653E"
88
91
  })), leftMidExtContents);
89
92
  }
90
93
 
@@ -1,13 +1,8 @@
1
1
  import React from 'react';
2
- import Api from '../api';
3
2
  interface IRightBarProps {
4
- container?: HTMLElement;
5
3
  visibel?: boolean;
6
- api: Api;
7
- video?: HTMLVideoElement;
8
- isLive?: boolean;
9
4
  rightExtContents: React.ReactNode;
10
5
  rightMidExtContents: React.ReactNode;
11
6
  }
12
- declare function RightBar({ container, rightExtContents, rightMidExtContents }: IRightBarProps): JSX.Element;
7
+ declare function RightBar({ rightExtContents, rightMidExtContents }: IRightBarProps): JSX.Element;
13
8
  export default RightBar;
@@ -10,16 +10,19 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
10
10
 
11
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
- import React from 'react';
13
+ import React, { useContext } from 'react';
14
14
  import IconFont from '../iconfont';
15
15
  import Bar from './bar';
16
16
  import useFullscreen from '../../useFullscreen';
17
+ import { Context } from '../context';
17
18
 
18
19
  function RightBar(_ref) {
19
- var container = _ref.container,
20
- rightExtContents = _ref.rightExtContents,
20
+ var rightExtContents = _ref.rightExtContents,
21
21
  rightMidExtContents = _ref.rightMidExtContents;
22
22
 
23
+ var _useContext = useContext(Context),
24
+ container = _useContext.container;
25
+
23
26
  var _useFullscreen = useFullscreen(container),
24
27
  _useFullscreen2 = _slicedToArray(_useFullscreen, 2),
25
28
  isFullScreen = _useFullscreen2[0],
@@ -10,7 +10,8 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
10
10
 
11
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
- import { useEffect, useState } from 'react';
13
+ import { useState } from 'react';
14
+ import { useRegisterPlayerEvents } from '../event';
14
15
  import EventName from '../event/eventName';
15
16
 
16
17
  function useBarStatus(event) {
@@ -19,33 +20,25 @@ function useBarStatus(event) {
19
20
  }),
20
21
  _useState2 = _slicedToArray(_useState, 2),
21
22
  state = _useState2[0],
22
- setState = _useState2[1]; // 监听
23
+ setState = _useState2[1];
23
24
 
24
-
25
- useEffect(function () {
26
- var show = function show() {
27
- return setState(function (old) {
28
- return Object.assign(Object.assign({}, old), {
29
- status: 1
30
- });
25
+ var show = function show() {
26
+ return setState(function (old) {
27
+ return Object.assign(Object.assign({}, old), {
28
+ status: 1
31
29
  });
32
- };
30
+ });
31
+ };
33
32
 
34
- var hide = function hide() {
35
- return setState(function (old) {
36
- return Object.assign(Object.assign({}, old), {
37
- status: 0
38
- });
33
+ var hide = function hide() {
34
+ return setState(function (old) {
35
+ return Object.assign(Object.assign({}, old), {
36
+ status: 0
39
37
  });
40
- };
41
-
42
- event.on(EventName.SHOW_CONTRALLER, show);
43
- event.on(EventName.HIDE_CONTRALLER, hide);
44
- return function () {
45
- event.off(EventName.SHOW_CONTRALLER, show);
46
- event.off(EventName.HIDE_CONTRALLER, hide);
47
- };
48
- }, []);
38
+ });
39
+ };
40
+
41
+ useRegisterPlayerEvents(event, [[EventName.SHOW_CONTRALLER, show], [EventName.HIDE_CONTRALLER, hide]]);
49
42
  return state.status;
50
43
  }
51
44
 
package/es/Player/demo.js CHANGED
@@ -117,6 +117,8 @@ function Demo1() {
117
117
  });
118
118
  }
119
119
  }, "\u64AD\u653E")), /*#__PURE__*/React.createElement(Player, {
120
+ fpsDelay: 800,
121
+ oneFpsPlay: true,
120
122
  type: state.type,
121
123
  url: state.url,
122
124
  isLive: !!state.isLive,
@@ -214,6 +216,7 @@ function Demo2() {
214
216
  });
215
217
  }
216
218
  }, "\u64AD\u653E")), /*#__PURE__*/React.createElement(SegmentPlayer, {
219
+ oneFpsPlay: true,
217
220
  begin: mm.valueOf(),
218
221
  segments: state.segments,
219
222
  isLive: false
@@ -278,7 +281,8 @@ function Demo3() {
278
281
  url: "".concat(old.url, "?").concat(time)
279
282
  });
280
283
  });
281
- }
284
+ },
285
+ type: "native"
282
286
  }));
283
287
  }
284
288