@draftbit/core 48.1.1-7606b6.2 → 48.1.1-bfaf07.2
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/lib/src/components/AudioPlayer/AudioPlayerCommon.d.ts +39 -0
- package/lib/src/components/AudioPlayer/AudioPlayerCommon.js.map +1 -0
- package/lib/src/components/AudioPlayer/AudioPlayerWithInterface.d.ts +6 -0
- package/lib/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/AudioPlayerWithInterface.js +2 -2
- package/lib/src/components/AudioPlayer/AudioPlayerWithInterface.js.map +1 -0
- package/lib/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/HeadlessAudioPlayer.d.ts +2 -3
- package/{src/components/MediaPlayer → lib/src/components}/AudioPlayer/HeadlessAudioPlayer.js +48 -9
- package/lib/src/components/AudioPlayer/HeadlessAudioPlayer.js.map +1 -0
- package/lib/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/index.d.ts +4 -5
- package/lib/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/index.js +1 -1
- package/lib/src/components/AudioPlayer/index.js.map +1 -0
- package/lib/src/components/Progress/CircularProgress/CircularProgress.d.ts +6 -0
- package/lib/src/components/Progress/CircularProgress/CircularProgress.js +101 -0
- package/lib/src/components/Progress/CircularProgress/CircularProgress.js.map +1 -0
- package/lib/src/components/Progress/CircularProgress/index.d.ts +6 -0
- package/lib/src/components/Progress/CircularProgress/index.js +14 -0
- package/lib/src/components/Progress/CircularProgress/index.js.map +1 -0
- package/lib/src/components/Progress/IndeterminateProgress.d.ts +7 -0
- package/lib/src/components/Progress/IndeterminateProgress.js +39 -0
- package/lib/src/components/Progress/IndeterminateProgress.js.map +1 -0
- package/lib/src/components/Progress/LinearProgress/LinearProgress.d.ts +6 -0
- package/lib/src/components/Progress/LinearProgress/LinearProgress.js +54 -0
- package/lib/src/components/Progress/LinearProgress/LinearProgress.js.map +1 -0
- package/lib/src/components/Progress/LinearProgress/index.d.ts +6 -0
- package/lib/src/components/Progress/LinearProgress/index.js +14 -0
- package/lib/src/components/Progress/LinearProgress/index.js.map +1 -0
- package/lib/src/components/Progress/ProgressCommon.d.ts +40 -0
- package/lib/src/components/Progress/ProgressCommon.js +2 -0
- package/lib/src/components/Progress/ProgressCommon.js.map +1 -0
- package/lib/src/components/SwipeableItem/SwipeableItem.js +9 -2
- package/lib/src/components/SwipeableItem/SwipeableItem.js.map +1 -1
- package/lib/src/components/SwipeableItem/SwipeableItemCommon.d.ts +3 -2
- package/lib/src/components/SwipeableItem/SwipeableItemCommon.js.map +1 -1
- package/lib/src/index.d.ts +3 -2
- package/lib/src/index.js +3 -2
- package/lib/src/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -10
- package/src/components/AudioPlayer/AudioPlayerCommon.ts +44 -0
- package/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/AudioPlayerWithInterface.js +2 -2
- package/src/components/AudioPlayer/AudioPlayerWithInterface.js.map +1 -0
- package/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/AudioPlayerWithInterface.tsx +9 -7
- package/{lib/src/components/MediaPlayer → src/components}/AudioPlayer/HeadlessAudioPlayer.js +48 -9
- package/src/components/AudioPlayer/HeadlessAudioPlayer.js.map +1 -0
- package/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/HeadlessAudioPlayer.tsx +64 -19
- package/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/index.js +1 -1
- package/src/components/AudioPlayer/index.js.map +1 -0
- package/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/index.tsx +4 -4
- package/src/components/Progress/CircularProgress/CircularProgress.js +101 -0
- package/src/components/Progress/CircularProgress/CircularProgress.js.map +1 -0
- package/src/components/Progress/CircularProgress/CircularProgress.tsx +200 -0
- package/src/components/Progress/CircularProgress/index.js +14 -0
- package/src/components/Progress/CircularProgress/index.js.map +1 -0
- package/src/components/Progress/CircularProgress/index.tsx +28 -0
- package/src/components/Progress/IndeterminateProgress.js +39 -0
- package/src/components/Progress/IndeterminateProgress.js.map +1 -0
- package/src/components/Progress/IndeterminateProgress.tsx +74 -0
- package/src/components/Progress/LinearProgress/LinearProgress.js +54 -0
- package/src/components/Progress/LinearProgress/LinearProgress.js.map +1 -0
- package/src/components/Progress/LinearProgress/LinearProgress.tsx +132 -0
- package/src/components/Progress/LinearProgress/index.js +14 -0
- package/src/components/Progress/LinearProgress/index.js.map +1 -0
- package/src/components/Progress/LinearProgress/index.tsx +25 -0
- package/src/components/Progress/ProgressCommon.js +2 -0
- package/src/components/Progress/ProgressCommon.js.map +1 -0
- package/src/components/Progress/ProgressCommon.ts +44 -0
- package/src/components/SwipeableItem/SwipeableItem.js +9 -2
- package/src/components/SwipeableItem/SwipeableItem.js.map +1 -1
- package/src/components/SwipeableItem/SwipeableItem.tsx +9 -1
- package/src/components/SwipeableItem/SwipeableItemCommon.js.map +1 -1
- package/src/components/SwipeableItem/SwipeableItemCommon.ts +3 -2
- package/src/index.js +3 -2
- package/src/index.js.map +1 -1
- package/src/index.tsx +3 -5
- package/lib/src/components/MediaPlayer/AudioPlayer/AudioPlayerCommon.d.ts +0 -22
- package/lib/src/components/MediaPlayer/AudioPlayer/AudioPlayerCommon.js.map +0 -1
- package/lib/src/components/MediaPlayer/AudioPlayer/AudioPlayerWithInterface.d.ts +0 -7
- package/lib/src/components/MediaPlayer/AudioPlayer/AudioPlayerWithInterface.js.map +0 -1
- package/lib/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.js.map +0 -1
- package/lib/src/components/MediaPlayer/AudioPlayer/index.js.map +0 -1
- package/lib/src/components/MediaPlayer/MediaPlaybackWrapper.d.ts +0 -15
- package/lib/src/components/MediaPlayer/MediaPlaybackWrapper.js +0 -32
- package/lib/src/components/MediaPlayer/MediaPlaybackWrapper.js.map +0 -1
- package/lib/src/components/MediaPlayer/MediaPlayerCommon.d.ts +0 -21
- package/lib/src/components/MediaPlayer/MediaPlayerCommon.js +0 -24
- package/lib/src/components/MediaPlayer/MediaPlayerCommon.js.map +0 -1
- package/lib/src/components/MediaPlayer/VideoPlayer/VideoPlayer.d.ts +0 -15
- package/lib/src/components/MediaPlayer/VideoPlayer/VideoPlayer.js +0 -73
- package/lib/src/components/MediaPlayer/VideoPlayer/VideoPlayer.js.map +0 -1
- package/lib/src/components/MediaPlayer/VideoPlayer/index.d.ts +0 -2
- package/lib/src/components/MediaPlayer/VideoPlayer/index.js +0 -2
- package/lib/src/components/MediaPlayer/VideoPlayer/index.js.map +0 -1
- package/src/components/MediaPlayer/AudioPlayer/AudioPlayerCommon.ts +0 -25
- package/src/components/MediaPlayer/AudioPlayer/AudioPlayerWithInterface.js.map +0 -1
- package/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.js.map +0 -1
- package/src/components/MediaPlayer/AudioPlayer/index.js.map +0 -1
- package/src/components/MediaPlayer/MediaPlaybackWrapper.js +0 -32
- package/src/components/MediaPlayer/MediaPlaybackWrapper.js.map +0 -1
- package/src/components/MediaPlayer/MediaPlaybackWrapper.tsx +0 -56
- package/src/components/MediaPlayer/MediaPlayerCommon.js +0 -24
- package/src/components/MediaPlayer/MediaPlayerCommon.js.map +0 -1
- package/src/components/MediaPlayer/MediaPlayerCommon.ts +0 -50
- package/src/components/MediaPlayer/VideoPlayer/VideoPlayer.js +0 -73
- package/src/components/MediaPlayer/VideoPlayer/VideoPlayer.js.map +0 -1
- package/src/components/MediaPlayer/VideoPlayer/VideoPlayer.tsx +0 -136
- package/src/components/MediaPlayer/VideoPlayer/index.js +0 -2
- package/src/components/MediaPlayer/VideoPlayer/index.js.map +0 -1
- package/src/components/MediaPlayer/VideoPlayer/index.ts +0 -2
- /package/lib/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/AudioPlayerCommon.js +0 -0
- /package/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/AudioPlayerCommon.js +0 -0
- /package/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/AudioPlayerCommon.js.map +0 -0
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export function mapToMediaPlayerStatus(status) {
|
|
2
|
-
if (status.isLoaded) {
|
|
3
|
-
return {
|
|
4
|
-
isPlaying: status.isPlaying,
|
|
5
|
-
isLoading: false,
|
|
6
|
-
isBuffering: status.isBuffering,
|
|
7
|
-
currentPositionMillis: status.positionMillis || 0,
|
|
8
|
-
durationMillis: status.durationMillis || 0,
|
|
9
|
-
bufferedDurationMillis: status.playableDurationMillis || 0,
|
|
10
|
-
isError: false,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
return {
|
|
14
|
-
isPlaying: false,
|
|
15
|
-
isLoading: false,
|
|
16
|
-
isBuffering: false,
|
|
17
|
-
currentPositionMillis: 0,
|
|
18
|
-
durationMillis: 0,
|
|
19
|
-
bufferedDurationMillis: 0,
|
|
20
|
-
isError: true,
|
|
21
|
-
error: status.error,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=MediaPlayerCommon.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MediaPlayerCommon.js","sourceRoot":"","sources":["MediaPlayerCommon.ts"],"names":[],"mappings":"AAwBA,MAAM,UAAU,sBAAsB,CACpC,MAAwB;IAExB,IAAI,MAAM,CAAC,QAAQ,EAAE;QACnB,OAAO;YACL,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,SAAS,EAAE,KAAK;YAChB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,qBAAqB,EAAE,MAAM,CAAC,cAAc,IAAI,CAAC;YACjD,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,CAAC;YAC1C,sBAAsB,EAAE,MAAM,CAAC,sBAAsB,IAAI,CAAC;YAC1D,OAAO,EAAE,KAAK;SACf,CAAC;KACH;IAED,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,KAAK;QAChB,WAAW,EAAE,KAAK;QAClB,qBAAqB,EAAE,CAAC;QACxB,cAAc,EAAE,CAAC;QACjB,sBAAsB,EAAE,CAAC;QACzB,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { AVPlaybackSource, AVPlaybackStatus } from "expo-av";
|
|
2
|
-
|
|
3
|
-
export interface MediaPlayerStatus {
|
|
4
|
-
isPlaying: boolean;
|
|
5
|
-
isLoading: boolean;
|
|
6
|
-
isBuffering: boolean;
|
|
7
|
-
currentPositionMillis: number;
|
|
8
|
-
durationMillis: number;
|
|
9
|
-
bufferedDurationMillis: number;
|
|
10
|
-
isError: boolean;
|
|
11
|
-
error?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface MediaPlayerRef {
|
|
15
|
-
seekToPosition: (positionMillis: number) => void;
|
|
16
|
-
togglePlayback: () => void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface MediaPlayerProps {
|
|
20
|
-
onPlaybackStatusUpdate?: (status: MediaPlayerStatus) => void;
|
|
21
|
-
onPlaybackFinish?: () => void;
|
|
22
|
-
source: AVPlaybackSource;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function mapToMediaPlayerStatus(
|
|
26
|
-
status: AVPlaybackStatus
|
|
27
|
-
): MediaPlayerStatus {
|
|
28
|
-
if (status.isLoaded) {
|
|
29
|
-
return {
|
|
30
|
-
isPlaying: status.isPlaying,
|
|
31
|
-
isLoading: false,
|
|
32
|
-
isBuffering: status.isBuffering,
|
|
33
|
-
currentPositionMillis: status.positionMillis || 0,
|
|
34
|
-
durationMillis: status.durationMillis || 0,
|
|
35
|
-
bufferedDurationMillis: status.playableDurationMillis || 0,
|
|
36
|
-
isError: false,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
isPlaying: false,
|
|
42
|
-
isLoading: false,
|
|
43
|
-
isBuffering: false,
|
|
44
|
-
currentPositionMillis: 0,
|
|
45
|
-
durationMillis: 0,
|
|
46
|
-
bufferedDurationMillis: 0,
|
|
47
|
-
isError: true,
|
|
48
|
-
error: status.error,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Video as VideoPlayerComponent, ResizeMode as ExpoResizeMode, VideoFullscreenUpdate, } from "expo-av";
|
|
3
|
-
import { extractSizeStyles } from "../../../utilities";
|
|
4
|
-
import MediaPlaybackWrapper from "../MediaPlaybackWrapper";
|
|
5
|
-
import { mapToMediaPlayerStatus, } from "../MediaPlayerCommon";
|
|
6
|
-
const VideoPlayer = React.forwardRef(({ style, resizeMode = "contain", posterResizeMode = "cover", onPlaybackStatusUpdate: onPlaybackStatusUpdateProp, onPlaybackFinish, ...rest }, ref) => {
|
|
7
|
-
const [videoMediaObject, setVideoMediaObject] = React.useState();
|
|
8
|
-
const [isPlaying, setIsPlaying] = React.useState(false);
|
|
9
|
-
const [isFullscreen, setIsFullscreen] = React.useState(false);
|
|
10
|
-
const mediaPlaybackWrapperRef = React.useRef(null);
|
|
11
|
-
const sizeStyles = extractSizeStyles(style);
|
|
12
|
-
let mappedResizeMode;
|
|
13
|
-
switch (resizeMode) {
|
|
14
|
-
case "contain":
|
|
15
|
-
mappedResizeMode = ExpoResizeMode.CONTAIN;
|
|
16
|
-
break;
|
|
17
|
-
case "cover":
|
|
18
|
-
mappedResizeMode = ExpoResizeMode.COVER;
|
|
19
|
-
break;
|
|
20
|
-
case "stretch":
|
|
21
|
-
mappedResizeMode = ExpoResizeMode.STRETCH;
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
const onPlaybackStatusUpdate = (status) => {
|
|
25
|
-
const mappedStatus = mapToMediaPlayerStatus(status);
|
|
26
|
-
onPlaybackStatusUpdateProp === null || onPlaybackStatusUpdateProp === void 0 ? void 0 : onPlaybackStatusUpdateProp(mappedStatus);
|
|
27
|
-
if (status.isLoaded) {
|
|
28
|
-
if (status.didJustFinish) {
|
|
29
|
-
onPlaybackFinish === null || onPlaybackFinish === void 0 ? void 0 : onPlaybackFinish();
|
|
30
|
-
}
|
|
31
|
-
setIsPlaying(status.isPlaying);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
const onFullscreenUpdate = (fullscreenUpdate) => {
|
|
35
|
-
switch (fullscreenUpdate) {
|
|
36
|
-
case VideoFullscreenUpdate.PLAYER_DID_PRESENT:
|
|
37
|
-
case VideoFullscreenUpdate.PLAYER_WILL_PRESENT:
|
|
38
|
-
setIsFullscreen(true);
|
|
39
|
-
break;
|
|
40
|
-
case VideoFullscreenUpdate.PLAYER_DID_DISMISS:
|
|
41
|
-
case VideoFullscreenUpdate.PLAYER_WILL_DISMISS:
|
|
42
|
-
setIsFullscreen(false);
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const toggleFullscreen = React.useCallback(async () => {
|
|
47
|
-
if (isFullscreen) {
|
|
48
|
-
await (videoMediaObject === null || videoMediaObject === void 0 ? void 0 : videoMediaObject.dismissFullscreenPlayer());
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
await (videoMediaObject === null || videoMediaObject === void 0 ? void 0 : videoMediaObject.presentFullscreenPlayer());
|
|
52
|
-
}
|
|
53
|
-
}, [isFullscreen, videoMediaObject]);
|
|
54
|
-
React.useImperativeHandle(ref, () => {
|
|
55
|
-
var _a, _b;
|
|
56
|
-
return ({
|
|
57
|
-
toggleFullscreen,
|
|
58
|
-
seekToPosition: ((_a = mediaPlaybackWrapperRef.current) === null || _a === void 0 ? void 0 : _a.seekToPosition) || (() => { }),
|
|
59
|
-
togglePlayback: ((_b = mediaPlaybackWrapperRef.current) === null || _b === void 0 ? void 0 : _b.togglePlayback) || (() => { }),
|
|
60
|
-
});
|
|
61
|
-
},
|
|
62
|
-
// Include 'isPlaying' as dependency because 'togglePlayback' changes when it changes
|
|
63
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
|
-
[toggleFullscreen, isPlaying]);
|
|
65
|
-
return (React.createElement(MediaPlaybackWrapper, { media: videoMediaObject, isPlaying: isPlaying, ref: mediaPlaybackWrapperRef },
|
|
66
|
-
React.createElement(VideoPlayerComponent
|
|
67
|
-
// https://docs.expo.dev/versions/latest/sdk/av/#example-video to see why ref is handled this way
|
|
68
|
-
, {
|
|
69
|
-
// https://docs.expo.dev/versions/latest/sdk/av/#example-video to see why ref is handled this way
|
|
70
|
-
ref: (component) => setVideoMediaObject(component), style: style, videoStyle: sizeStyles, resizeMode: mappedResizeMode, posterStyle: [sizeStyles, { resizeMode: posterResizeMode }], onPlaybackStatusUpdate: onPlaybackStatusUpdate, onFullscreenUpdate: (e) => onFullscreenUpdate(e.fullscreenUpdate), ...rest })));
|
|
71
|
-
});
|
|
72
|
-
export default VideoPlayer;
|
|
73
|
-
//# sourceMappingURL=VideoPlayer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VideoPlayer.js","sourceRoot":"","sources":["VideoPlayer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,KAAK,IAAI,oBAAoB,EAE7B,UAAU,IAAI,cAAc,EAE5B,qBAAqB,GACtB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAGL,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAiB9B,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAClC,CACE,EACE,KAAK,EACL,UAAU,GAAG,SAAS,EACtB,gBAAgB,GAAG,OAAO,EAC1B,sBAAsB,EAAE,0BAA0B,EAClD,gBAAgB,EAChB,GAAG,IAAI,EACR,EACD,GAAG,EACH,EAAE;IACF,MAAM,CAAC,gBAAgB,EAAE,mBAA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C5B,WAAW,EAAE,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC,EAC3D,sBAAsB,EAAE,sBAAsB,EAC9C,kBAAkB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAC7D,IAAI,GACR,CACmB,CACxB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ImageResizeMode } from "react-native";
|
|
3
|
-
import {
|
|
4
|
-
Video as VideoPlayerComponent,
|
|
5
|
-
VideoProps as ExpoVideoProps,
|
|
6
|
-
ResizeMode as ExpoResizeMode,
|
|
7
|
-
AVPlaybackStatus,
|
|
8
|
-
VideoFullscreenUpdate,
|
|
9
|
-
} from "expo-av";
|
|
10
|
-
import { extractSizeStyles } from "../../../utilities";
|
|
11
|
-
import MediaPlaybackWrapper from "../MediaPlaybackWrapper";
|
|
12
|
-
import type { Playback } from "expo-av/src/AV";
|
|
13
|
-
import {
|
|
14
|
-
MediaPlayerProps,
|
|
15
|
-
MediaPlayerRef,
|
|
16
|
-
mapToMediaPlayerStatus,
|
|
17
|
-
} from "../MediaPlayerCommon";
|
|
18
|
-
|
|
19
|
-
type ResizeMode = "contain" | "cover" | "stretch";
|
|
20
|
-
type ExpoVideoPropsOmitted = Omit<
|
|
21
|
-
ExpoVideoProps,
|
|
22
|
-
"videoStyle" | "resizeMode" | "onPlaybackStatusUpdate" | "source"
|
|
23
|
-
>;
|
|
24
|
-
|
|
25
|
-
interface VideoPlayerProps extends ExpoVideoPropsOmitted, MediaPlayerProps {
|
|
26
|
-
resizeMode?: ResizeMode;
|
|
27
|
-
posterResizeMode?: ImageResizeMode;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface VideoPlayerRef extends MediaPlayerRef {
|
|
31
|
-
toggleFullscreen: () => void;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const VideoPlayer = React.forwardRef<VideoPlayerRef, VideoPlayerProps>(
|
|
35
|
-
(
|
|
36
|
-
{
|
|
37
|
-
style,
|
|
38
|
-
resizeMode = "contain",
|
|
39
|
-
posterResizeMode = "cover",
|
|
40
|
-
onPlaybackStatusUpdate: onPlaybackStatusUpdateProp,
|
|
41
|
-
onPlaybackFinish,
|
|
42
|
-
...rest
|
|
43
|
-
},
|
|
44
|
-
ref
|
|
45
|
-
) => {
|
|
46
|
-
const [videoMediaObject, setVideoMediaObject] =
|
|
47
|
-
React.useState<VideoPlayerComponent | null>();
|
|
48
|
-
const [isPlaying, setIsPlaying] = React.useState(false);
|
|
49
|
-
const [isFullscreen, setIsFullscreen] = React.useState(false);
|
|
50
|
-
const mediaPlaybackWrapperRef = React.useRef<MediaPlayerRef>(null);
|
|
51
|
-
|
|
52
|
-
const sizeStyles = extractSizeStyles(style);
|
|
53
|
-
|
|
54
|
-
let mappedResizeMode;
|
|
55
|
-
switch (resizeMode) {
|
|
56
|
-
case "contain":
|
|
57
|
-
mappedResizeMode = ExpoResizeMode.CONTAIN;
|
|
58
|
-
break;
|
|
59
|
-
case "cover":
|
|
60
|
-
mappedResizeMode = ExpoResizeMode.COVER;
|
|
61
|
-
break;
|
|
62
|
-
case "stretch":
|
|
63
|
-
mappedResizeMode = ExpoResizeMode.STRETCH;
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const onPlaybackStatusUpdate = (status: AVPlaybackStatus) => {
|
|
68
|
-
const mappedStatus = mapToMediaPlayerStatus(status);
|
|
69
|
-
onPlaybackStatusUpdateProp?.(mappedStatus);
|
|
70
|
-
|
|
71
|
-
if (status.isLoaded) {
|
|
72
|
-
if (status.didJustFinish) {
|
|
73
|
-
onPlaybackFinish?.();
|
|
74
|
-
}
|
|
75
|
-
setIsPlaying(status.isPlaying);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const onFullscreenUpdate = (fullscreenUpdate: VideoFullscreenUpdate) => {
|
|
80
|
-
switch (fullscreenUpdate) {
|
|
81
|
-
case VideoFullscreenUpdate.PLAYER_DID_PRESENT:
|
|
82
|
-
case VideoFullscreenUpdate.PLAYER_WILL_PRESENT:
|
|
83
|
-
setIsFullscreen(true);
|
|
84
|
-
break;
|
|
85
|
-
case VideoFullscreenUpdate.PLAYER_DID_DISMISS:
|
|
86
|
-
case VideoFullscreenUpdate.PLAYER_WILL_DISMISS:
|
|
87
|
-
setIsFullscreen(false);
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const toggleFullscreen = React.useCallback(async () => {
|
|
93
|
-
if (isFullscreen) {
|
|
94
|
-
await videoMediaObject?.dismissFullscreenPlayer();
|
|
95
|
-
} else {
|
|
96
|
-
await videoMediaObject?.presentFullscreenPlayer();
|
|
97
|
-
}
|
|
98
|
-
}, [isFullscreen, videoMediaObject]);
|
|
99
|
-
|
|
100
|
-
React.useImperativeHandle(
|
|
101
|
-
ref,
|
|
102
|
-
() => ({
|
|
103
|
-
toggleFullscreen,
|
|
104
|
-
seekToPosition:
|
|
105
|
-
mediaPlaybackWrapperRef.current?.seekToPosition || (() => {}),
|
|
106
|
-
togglePlayback:
|
|
107
|
-
mediaPlaybackWrapperRef.current?.togglePlayback || (() => {}),
|
|
108
|
-
}),
|
|
109
|
-
// Include 'isPlaying' as dependency because 'togglePlayback' changes when it changes
|
|
110
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
111
|
-
[toggleFullscreen, isPlaying]
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
<MediaPlaybackWrapper
|
|
116
|
-
media={videoMediaObject as Playback | undefined}
|
|
117
|
-
isPlaying={isPlaying}
|
|
118
|
-
ref={mediaPlaybackWrapperRef}
|
|
119
|
-
>
|
|
120
|
-
<VideoPlayerComponent
|
|
121
|
-
// https://docs.expo.dev/versions/latest/sdk/av/#example-video to see why ref is handled this way
|
|
122
|
-
ref={(component) => setVideoMediaObject(component)}
|
|
123
|
-
style={style}
|
|
124
|
-
videoStyle={sizeStyles}
|
|
125
|
-
resizeMode={mappedResizeMode}
|
|
126
|
-
posterStyle={[sizeStyles, { resizeMode: posterResizeMode }]}
|
|
127
|
-
onPlaybackStatusUpdate={onPlaybackStatusUpdate}
|
|
128
|
-
onFullscreenUpdate={(e) => onFullscreenUpdate(e.fullscreenUpdate)}
|
|
129
|
-
{...rest}
|
|
130
|
-
/>
|
|
131
|
-
</MediaPlaybackWrapper>
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
export default VideoPlayer;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|