use the window hostname on web for twitch embeds (#2311)
parent
cd7a25fd42
commit
7e3e6caa10
|
@ -1,3 +1,5 @@
|
||||||
|
import {Platform} from 'react-native'
|
||||||
|
|
||||||
export type EmbedPlayerParams =
|
export type EmbedPlayerParams =
|
||||||
| {type: 'youtube_video'; videoId: string; playerUri: string}
|
| {type: 'youtube_video'; videoId: string; playerUri: string}
|
||||||
| {type: 'twitch_live'; channelId: string; playerUri: string}
|
| {type: 'twitch_live'; channelId: string; playerUri: string}
|
||||||
|
@ -48,12 +50,15 @@ export function parseEmbedPlayerFromUrl(
|
||||||
|
|
||||||
// twitch
|
// twitch
|
||||||
if (urlp.hostname === 'twitch.tv' || urlp.hostname === 'www.twitch.tv') {
|
if (urlp.hostname === 'twitch.tv' || urlp.hostname === 'www.twitch.tv') {
|
||||||
|
const parent =
|
||||||
|
Platform.OS === 'web' ? window.location.hostname : 'localhost'
|
||||||
|
|
||||||
const parts = urlp.pathname.split('/')
|
const parts = urlp.pathname.split('/')
|
||||||
if (parts.length === 2 && parts[1]) {
|
if (parts.length === 2 && parts[1]) {
|
||||||
return {
|
return {
|
||||||
type: 'twitch_live',
|
type: 'twitch_live',
|
||||||
channelId: parts[1],
|
channelId: parts[1],
|
||||||
playerUri: `https://player.twitch.tv/?volume=0.5&!muted&autoplay&channel=${parts[1]}&parent=localhost`,
|
playerUri: `https://player.twitch.tv/?volume=0.5&!muted&autoplay&channel=${parts[1]}&parent=${parent}`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue