feat(#2542): added airplay

keep-around/b214ac7012ef42593bee62c207888a2593bc5a38
Rakov Roman 3 years ago
parent 5b209af193
commit 2dd00b05d3
  1. 20
      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()
}

Loading…
Cancel
Save