Created
November 3, 2011 14:57
-
-
Save joubertnel/1336701 to your computer and use it in GitHub Desktop.
HTML5 video in SproutCore
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
SC.Video = SC.View.extend({ | |
classNames: ['sc-video'], | |
tagName: 'video', | |
attributeBindings: ['src', 'width', 'height', 'controls', 'type', 'currentTime', 'initialTime'], | |
currentTime: 0, | |
/// Setup | |
didInsertElement: function() { | |
var self = this; | |
var events = ['timeupdate']; | |
events.forEach(function(event) { | |
var callback = self[event]; | |
if (callback) { | |
self.$().bind('timeupdate', function(event) { callback(event, self); }); | |
} | |
}); | |
}, | |
/// Event handlers | |
timeupdate: function(event, view) { | |
var currentTime = event.srcElement.currentTime; | |
view.set('currentTime', currentTime); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment