@theoplayer/react-native-ui
Version:
A React Native UI for @theoplayer/react-native
30 lines • 1.07 kB
JavaScript
import { ActionButton } from './actionbutton/ActionButton';
import React, { useCallback, useContext } from 'react';
import { PlayerContext } from '../util/PlayerContext';
import { VolumeOffSvg } from './svg/VolumeOffSvg';
import { VolumeUpSvg } from './svg/VolumeUpSvg';
import { useMuted } from '../../hooks/useMuted';
import { TestIDs } from '../../utils/TestIDs';
import { jsx as _jsx } from "react/jsx-runtime";
export function MuteButton(props) {
const {
icon
} = props;
const {
player
} = useContext(PlayerContext);
const muted = useMuted();
const toggleMuted = useCallback(() => {
player.muted = !player.muted;
}, [player]);
const volumeUpSvg = icon?.volumeUp ?? /*#__PURE__*/_jsx(VolumeUpSvg, {});
const volumeOffSvg = icon?.volumeOff ?? /*#__PURE__*/_jsx(VolumeOffSvg, {});
return /*#__PURE__*/_jsx(ActionButton, {
style: props.style,
testID: props.testID ?? TestIDs.MUTE_BUTTON,
svg: muted ? volumeOffSvg : volumeUpSvg,
onPress: toggleMuted,
touchable: true
});
}
//# sourceMappingURL=MuteButton.js.map