Created
September 17, 2012 19:13
-
-
Save davidpelaez/3739200 to your computer and use it in GitHub Desktop.
Backbone view in Coffescript to interact with vimeo iframe player
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CviveApplicant.Views.VimeoVideoView extends Backbone.View | |
template: Handlebars.templates["applicant_templates/vimeo_player"] | |
initialize:-> | |
console.log "init VimeoVideoView" | |
render:-> | |
console.log "render VimeoVideoView" | |
$(@el).html @template({video: @id}) | |
console.log "#vimeo_video_#{@id}" | |
iframe=$("#vimeo_video_#{@id}")[0] | |
@player=$f(iframe) | |
@player.addEvent('ready', @playerIsReady) | |
playerIsReady:(id)=> | |
console.log "#{id} vimeo player is ready" | |
#The methods in these events must be addressed by their complete name, as the backbone | |
#notation doesn't work with froogaloop. | |
@player.addEvent('finish', VimeoVideoView.prototype.finish) | |
finish:(id)=> | |
#!!!! This doesnt fire in windows, mos probably because execution never gets there | |
#!!!! because of the Unable to post message to player.vimeo.com... error | |
console.log "vimeo player has finished" | |
vent.trigger("finished",this.id) | |
hide:=> | |
console.log "vimeo player hide" | |
$(@el).hide() | |
pause:=> | |
console.log "vimeo player pause" | |
@player.api("pause") | |
window.fff=@player | |
@player.api('paused', (value, player_id) -> | |
console.log('paused : ' + value + ":"+ player_id) | |
if(value==false) | |
@pause) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment