1 window.TwitchPlayer = class TwitchPlayer extends Player
3 if not (this instanceof TwitchPlayer)
4 return new TwitchPlayer(data)
6 @setMediaProperties(data)
7 waitUntilDefined(window, 'Twitch', =>
8 waitUntilDefined(Twitch, 'Player', =>
23 @twitch = new Twitch.Player('ytapiplayer', options)
24 @twitch.addEventListener(Twitch.Player.READY, =>
26 @twitch.setQuality(@mapQuality(USEROPTS.default_quality))
27 @twitch.addEventListener(Twitch.Player.PLAY, =>
32 @twitch.addEventListener(Twitch.Player.PAUSE, =>
37 @twitch.addEventListener(Twitch.Player.ENDED, =>
39 socket.emit('playNext')
44 @setMediaProperties(data)
48 @twitch.setVideo(data.id)
51 @twitch.setChannel(data.id)
77 cb(@twitch.getCurrentTime())
81 setVolume: (volume) ->
83 @twitch.setVolume(volume)
85 @twitch.setMuted(false)
94 cb(@twitch.getVolume())
98 mapQuality: (quality) ->
99 switch String(quality)
100 when '1080' then 'chunked'
101 when '720' then 'high'
102 when '480' then 'medium'
103 when '360' then 'low'
104 when '240' then 'mobile'
105 when 'best' then 'chunked'