@theoplayer/react-native-ui
Version:
A React Native UI for @theoplayer/react-native
26 lines (25 loc) • 1.11 kB
JavaScript
import React from 'react';
import { CastButton } from 'react-native-google-cast';
import { PlayerContext } from '../util/PlayerContext';
import { DEFAULT_ACTION_BUTTON_STYLE } from './actionbutton/ActionButton';
import { useChromecast } from '../../hooks/useChromecast';
import { TestIDs } from '../../utils/TestIDs';
import { jsx as _jsx } from "react/jsx-runtime";
export function isConnected(state) {
return state === 'connecting' || state === 'connected';
}
/**
* The native button to enable Chromecast for the `react-native-theoplayer` UI.
* This component uses the button from `react-native-google-cast` and is not supported on web.
*/
export function ChromecastButton(props) {
const castState = useChromecast();
return /*#__PURE__*/_jsx(PlayerContext.Consumer, {
children: context => /*#__PURE__*/_jsx(CastButton, {
style: props.style ?? DEFAULT_ACTION_BUTTON_STYLE,
testID: props.testID ?? TestIDs.CHROMECAST_BUTTON,
tintColor: isConnected(castState) ? context.style.colors.iconSelected : context.style.colors.icon
})
});
}
//# sourceMappingURL=ChromecastButton.js.map