UNPKG

react-native-video-player

Version:
98 lines (97 loc) 3.85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Controls = void 0; var _react = require("react"); var _Duration = require("./Duration.js"); var _Seekbar = require("./Seekbar.js"); var _PlayButton = require("./PlayButton.js"); var _Mute = require("./Mute.js"); var _Fullscreen = require("./Fullscreen.js"); var _ControlsAnimatedWrapper = require("./ControlsAnimatedWrapper.js"); var _jsxRuntime = require("react/jsx-runtime"); const Controls = exports.Controls = /*#__PURE__*/(0, _react.forwardRef)(({ customStyles, onPlayPress, isPlaying, showDuration, onToggleFullScreen, duration, disableFullscreen, onMutePress, isMuted, animationDuration, controlsTimeoutId, isControlsVisible, ...seekbarProps }, ref) => { const durationRef = (0, _react.useRef)(null); const seekbarRef = (0, _react.useRef)(null); const animationRef = (0, _react.useRef)(null); (0, _react.useImperativeHandle)(ref, () => ({ onProgress: progress => { durationRef.current?.onProgress(progress); seekbarRef.current?.onProgress(progress); }, runControlsAnimation: (toValue, callback) => { animationRef.current?.runControlsAnimation(toValue, callback); } })); if (!isControlsVisible) { return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Seekbar.Seekbar, { fullWidth: true, ref: seekbarRef, ...seekbarProps, onSeeking: progress => durationRef.current?.onProgress(progress), isPlaying: isPlaying, controlsTimeoutId: controlsTimeoutId, duration: duration, seekBarBackgroundCustomStyles: customStyles?.seekBarBackground, seekBarCustomStyles: customStyles?.seekBar, seekBarFullWidthCustomStyles: customStyles?.seekBarFullWidth, seekBarKnobCustomStyles: customStyles?.seekBarKnob, seekBarKnobSeekingCustomStyles: customStyles?.seekBarKnobSeeking, seekBarProgressCustomStyles: customStyles?.seekBarProgress }); } return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ControlsAnimatedWrapper.AnimatedWrapper, { ref: animationRef, animationDuration: animationDuration, customStylesControls: customStyles?.controls, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PlayButton.PlayButton, { controlButtonCustomStyles: customStyles?.controlButton, playControlCustomStyles: customStyles?.playControl, isPlaying: isPlaying, onPlayPress: onPlayPress }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Seekbar.Seekbar, { fullWidth: !isControlsVisible, ref: seekbarRef, ...seekbarProps, onSeeking: progress => durationRef.current?.onProgress(progress), isPlaying: isPlaying, controlsTimeoutId: controlsTimeoutId, duration: duration, seekBarBackgroundCustomStyles: customStyles?.seekBarBackground, seekBarCustomStyles: customStyles?.seekBar, seekBarFullWidthCustomStyles: customStyles?.seekBarFullWidth, seekBarKnobCustomStyles: customStyles?.seekBarKnob, seekBarKnobSeekingCustomStyles: customStyles?.seekBarKnobSeeking, seekBarProgressCustomStyles: customStyles?.seekBarProgress }), showDuration && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Duration.DurationText, { ref: durationRef, duration: duration, durationTextCustomStyles: customStyles?.durationText }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Mute.Mute, { controlButtonCustomStyles: customStyles?.controlButton, controlIconCustomStyles: customStyles?.controlIcon, isMuted: isMuted, onMutePress: onMutePress }), !disableFullscreen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Fullscreen.Fullscreen, { onToggleFullScreen: onToggleFullScreen, controlButtonCustomStyles: customStyles?.controlButton, controlIconCustomStyles: customStyles?.controlIcon })] }); }); //# sourceMappingURL=Controls.js.map