1.0.5 • Published 3 years ago

twitch-stream-embed v1.0.5

Weekly downloads
6
License
ISC
Repository
github
Last release
3 years ago

Twitch Stream Component logo

TwitchStream

TwitchStream is a Web Component for embedding a Twitch Stream onto any web site with just 2 lines of HTML.

Check out a Demo here

Installation

NPM

npm install twitch-stream-embed

CDN

<script type="module" src="https://unpkg.com/twitch-stream-embed"></script>

Usage

With NPM

import 'twitch-stream-embed';

<twitch-stream channel="ESL_SC2"></twitch-stream>;

With CDN

<script type="module" src="https://unpkg.com/twitch-stream-embed"></script>

<twitch-stream channel="ESL_SC2" chat muted></twitch-stream>

Attributes

NameTypeOptions
ChannelStringAny channel name on Twitch.tv
WidthString/NumberPercentage or a Number
HeightString/NumberPercentage or a Number
ThemeStringdark / light
MutedBooleanAdd the "muted" attribute to start stream muted
AutoplayBooleanAdd 'autoplay="false"' to disable autoplay
ChatBooleanAdd the "chat" attribute to show chat next to the stream
AllowfullscreenBooleanAdd 'allowfullscreen="false"' to disallow fullsreen viewing
ParentStringOnly required if your site is embedded on any domain(s) other than the one that instantiates the Twitch Embed e.g. "codesandbox.io"

API

NameParametersDescription
getPlayer()Returns the Player instance
play()Resume / Start the stream
pause()Pause the stream
getChannel()Get the name of the channel currently being streamed
setChannel(channel)channel: Name of the channelSet the active stream component to given channel
getQualities()Get the available video qualities for the stream
setQuality(quality)quality: String containing the quality identifier. e.g. "360p"Set the stream quality to given quality
getMuted()Get the muted status of the active stream
setMuted(isMuted)isMuted: Boolean, if the stream should be muted or notSet the muted status to given value (true/false)
getVolume()Get the current volume of the stream
setVolume(volume)volume: A float value between 0.0 and 1.0Set the current volume of the stream