diff --git a/src/features/AirPlay/index.tsx b/src/features/AirPlay/index.tsx index 9fc9e005..13d9459e 100644 --- a/src/features/AirPlay/index.tsx +++ b/src/features/AirPlay/index.tsx @@ -1,7 +1,13 @@ import { useEffect } from 'react' +import includes from 'lodash/includes' + import { usePageParams } from 'hooks/usePageParams' +import { API_ROOT } from 'config' + +import { readToken } from 'helpers' + import { AirplayButton, AirplayIcon } from './styled' type Props = { @@ -12,16 +18,11 @@ export const AirPlay = ({ videoRef }: Props) => { const { profileId: matchId, sportType } = usePageParams() useEffect(() => { - // попытки подсунуть airplay кнопке урл отличающийся от урла основного плеера - // const baseUrl = includes(videoRef?.current?.src, '.m3u8') - // eslint-disable-next-line max-len - // ? `${API_ROOT}/video/chromecast/stream/${sportType}/${matchId}.m3u8?access_token=${readToken()}` - // : videoRef?.current?.src + const baseUrl = includes(videoRef?.current?.src, '.m3u8') + ? `${API_ROOT}/video/chromecast/stream/${sportType}/${matchId}.m3u8?access_token=${readToken()}` + : videoRef?.current?.src! const video = videoRef.current! - // const video = document.createElement('video') - // video.src = baseUrl! - const airPlayBtn = document.getElementById('airPlay')! const changeAvailability = (event: any) => { @@ -36,6 +37,9 @@ export const AirPlay = ({ videoRef }: Props) => { } const onAirplayClick = () => { + video.src = baseUrl + video.load(); + (video as any).webkitShowPlaybackTargetPicker() }