import { faExternalLinkAlt } from "@fortawesome/free-solid-svg-icons"; import React from "react"; import { Button } from "react-bootstrap"; import { useIntl } from "react-intl"; import { Icon } from "src/components/Shared/Icon"; import { objectTitle } from "src/core/files"; import { SceneDataFragment } from "src/core/generated-graphql"; export interface IExternalPlayerButtonProps { scene: SceneDataFragment; } export const ExternalPlayerButton: React.FC = ({ scene, }) => { const isAndroid = /(android)/i.test(navigator.userAgent); const isAppleDevice = /(ipod|iphone|ipad)/i.test(navigator.userAgent); const intl = useIntl(); const { paths } = scene; if (!paths || !paths.stream || (!isAndroid && !isAppleDevice)) return ; const { stream } = paths; const title = objectTitle(scene); let url; const streamURL = new URL(stream); if (isAndroid) { const scheme = streamURL.protocol.slice(0, -1); streamURL.hash = `Intent;action=android.intent.action.VIEW;scheme=${scheme};type=video/mp4;S.title=${encodeURI( title )};end`; streamURL.protocol = "intent"; url = streamURL.toString(); } else if (isAppleDevice) { streamURL.host = "x-callback-url"; streamURL.port = ""; streamURL.pathname = "stream"; streamURL.search = `url=${encodeURIComponent(stream)}`; streamURL.protocol = "vlc-x-callback"; url = streamURL.toString(); } return ( ); }; export default ExternalPlayerButton;