Creating new TwitchPlayer instance
TwitchPlayer
allows you to embed only player, without chat:
const player = new TwitchPlayer(
'twitch-player',
options: {
width: '1280',
height: '720',
video: '2064229582',
parent: ['anivire.xyz']
});
width
: Width of the embedded window, in pixels. Can be expressed as a percentage, by passing a string like 50%
. Recommended minimum: 400
,
height
: Height of the embedded window, in pixels. Can be expressed as a percentage, by passing a string like 100%
. Recommended minimum: 300
,
parent?
: Only required if your site is embedded on any domain(s) other than the one that instantiates the Twitch embed.Example parent parameter: ["streamernews.example.com", "embed.example.com"]
,
channel?
: Channel name (for a live stream). If channel is specified along with video and/or collection, only channel is used. To change the channel or video later, use setChannel
, setVideo
, or setCollection
,
video?
: Video ID. If both video and collection are specified, the specified collection starts playing from the specified video. If the video is not in the collection, collection is ignored and the specified video is played. To change the channel or video later, use setChannel
, setVideo
, or setCollection
,
collection?
: Collection ID. If both video and collection are specified, the specified collection starts playing from the specified video. If the video is not in the collection, collection is ignored and the specified video is played. To change the channel or video later, use setChannel
, setVideo
, or setCollection
,
autoplay?
: If true
, the video starts playing automatically, without the user clicking play. The exception is mobile devices, on which video cannot be played without user interaction. Default: true
,
muted?
: Specifies whether the initial state of the video is muted. Default: false
,
time?
: Only valid for Video on Demand content. Time in the video where playback starts. Specifies hours, minutes, and seconds. Default: 0h0m0s (the start of the video),
allowfullscreen?
: A boolean attribute set by inclusion. In other words, including the attribute enables fullscreen viewing while excluding the attribute ensures fullscreen viewing is not allowed,
layout?
: Determines the screen layout. Valid values: video-with-chat
: default if channel is provided, and only supported for live content. Shows both video and chat side-by-side. At narrow sizes, chat renders under the video player. video
: default if channel is not provided. Shows only the video player (omits chat),
theme?
: The Twitch embed color theme to use. Valid values: light
or dark
. Default: dark
,