Skip to content

Instantly share code, notes, and snippets.

@joubertnel
Created November 3, 2011 14:57
Show Gist options
  • Save joubertnel/1336701 to your computer and use it in GitHub Desktop.
Save joubertnel/1336701 to your computer and use it in GitHub Desktop.
HTML5 video in SproutCore
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