2015-05-02 16:45:35 +00:00
|
|
|
window.VimeoPlayer = class VimeoPlayer extends Player
|
|
|
|
constructor: (data) ->
|
|
|
|
if not (this instanceof VimeoPlayer)
|
|
|
|
return new VimeoPlayer(data)
|
|
|
|
|
|
|
|
@load(data)
|
|
|
|
|
|
|
|
load: (data) ->
|
|
|
|
@setMediaProperties(data)
|
|
|
|
|
2017-10-29 06:10:15 +00:00
|
|
|
waitUntilDefined(window, 'Vimeo', =>
|
2015-05-02 16:45:35 +00:00
|
|
|
video = $('<iframe/>')
|
|
|
|
removeOld(video)
|
|
|
|
video.attr(
|
2017-10-29 06:10:15 +00:00
|
|
|
src: "https://player.vimeo.com/video/#{data.id}"
|
2015-05-02 16:45:35 +00:00
|
|
|
webkitallowfullscreen: true
|
|
|
|
mozallowfullscreen: true
|
|
|
|
allowfullscreen: true
|
|
|
|
)
|
|
|
|
|
|
|
|
if USEROPTS.wmode_transparent
|
|
|
|
video.attr('wmode', 'transparent')
|
|
|
|
|
2017-10-29 06:10:15 +00:00
|
|
|
@vimeo = new Vimeo.Player(video[0])
|
2015-05-02 16:45:35 +00:00
|
|
|
|
2017-10-29 06:10:15 +00:00
|
|
|
@vimeo.on('ended', =>
|
|
|
|
if CLIENT.leader
|
|
|
|
socket.emit('playNext')
|
|
|
|
)
|
2015-05-02 16:45:35 +00:00
|
|
|
|
2017-10-29 06:10:15 +00:00
|
|
|
@vimeo.on('pause', =>
|
|
|
|
@paused = true
|
|
|
|
if CLIENT.leader
|
|
|
|
sendVideoUpdate()
|
|
|
|
)
|
2015-05-02 16:45:35 +00:00
|
|
|
|
2017-10-29 06:10:15 +00:00
|
|
|
@vimeo.on('play', =>
|
|
|
|
@paused = false
|
|
|
|
if CLIENT.leader
|
|
|
|
sendVideoUpdate()
|
2015-05-02 16:45:35 +00:00
|
|
|
)
|
2017-10-29 06:10:15 +00:00
|
|
|
|
|
|
|
@play()
|
|
|
|
@setVolume(VOLUME)
|
2015-05-02 16:45:35 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
play: ->
|
|
|
|
@paused = false
|
|
|
|
if @vimeo
|
2017-10-29 06:10:15 +00:00
|
|
|
@vimeo.play().catch((error) ->
|
|
|
|
console.error('vimeo::play():', error)
|
|
|
|
)
|
2015-05-02 16:45:35 +00:00
|
|
|
|
|
|
|
pause: ->
|
|
|
|
@paused = true
|
|
|
|
if @vimeo
|
2017-10-29 06:10:15 +00:00
|
|
|
@vimeo.pause().catch((error) ->
|
|
|
|
console.error('vimeo::pause():', error)
|
|
|
|
)
|
2015-05-02 16:45:35 +00:00
|
|
|
|
|
|
|
seekTo: (time) ->
|
|
|
|
if @vimeo
|
2017-10-29 06:10:15 +00:00
|
|
|
@vimeo.setCurrentTime(time).catch((error) ->
|
|
|
|
console.error('vimeo::setCurrentTime():', error)
|
|
|
|
)
|
2015-05-02 16:45:35 +00:00
|
|
|
|
|
|
|
setVolume: (volume) ->
|
|
|
|
if @vimeo
|
2017-10-29 06:10:15 +00:00
|
|
|
@vimeo.setVolume(volume).catch((error) ->
|
|
|
|
console.error('vimeo::setVolume():', error)
|
|
|
|
)
|
2015-05-02 16:45:35 +00:00
|
|
|
|
|
|
|
getTime: (cb) ->
|
|
|
|
if @vimeo
|
2017-10-29 06:10:15 +00:00
|
|
|
@vimeo.getCurrentTime().then((time) ->
|
2015-05-02 16:45:35 +00:00
|
|
|
cb(parseFloat(time))
|
2017-10-29 06:10:15 +00:00
|
|
|
).catch((error) ->
|
|
|
|
console.error('vimeo::getCurrentTime():', error)
|
2015-05-02 16:45:35 +00:00
|
|
|
)
|
|
|
|
else
|
|
|
|
cb(0)
|
|
|
|
|
|
|
|
getVolume: (cb) ->
|
|
|
|
if @vimeo
|
2017-10-29 06:10:15 +00:00
|
|
|
@vimeo.getVolume().then((volume) ->
|
|
|
|
cb(parseFloat(volume))
|
|
|
|
).catch((error) ->
|
|
|
|
console.error('vimeo::getVolume():', error)
|
|
|
|
)
|
2015-05-02 16:45:35 +00:00
|
|
|
else
|
|
|
|
cb(VOLUME)
|