react-native-youtube-bridge
Version:
🎥 Easy-to-use YouTube player for React Native with cross-platform support
37 lines (36 loc) • 1.09 kB
JavaScript
;
import { forwardRef, useImperativeHandle } from 'react';
import { useWindowDimensions } from 'react-native';
import YoutubePlayerWrapper from "./YoutubePlayerWrapper.js";
import useYouTubePlayer from "./hooks/useYoutubePlayer.js";
import useYouTubeVideoId from "./hooks/useYoutubeVideoId.js";
import { jsx as _jsx } from "react/jsx-runtime";
const YoutubePlayer = /*#__PURE__*/forwardRef((props, ref) => {
const videoId = useYouTubeVideoId(props.source);
const {
containerRef,
controls
} = useYouTubePlayer({
...props,
videoId
});
const {
width: screenWidth
} = useWindowDimensions();
useImperativeHandle(ref, () => controls, [controls]);
return /*#__PURE__*/_jsx(YoutubePlayerWrapper, {
width: props.width ?? screenWidth,
height: props.height ?? 200,
style: props.style,
children: /*#__PURE__*/_jsx("div", {
ref: containerRef,
style: {
width: '100%',
height: '100%',
...props.iframeStyle
}
})
});
});
export default YoutubePlayer;
//# sourceMappingURL=YoutubePlayer.web.js.map