Created
August 21, 2015 19:51
-
-
Save ntodd/b85dfec6ea5e8d1af303 to your computer and use it in GitHub Desktop.
Video Player Test
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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: 'video-controls video-layer'.w(), | |
hidden: false, | |
actions: { | |
togglePlayback: function() { | |
this.sendAction('togglePlayback'); | |
} | |
}, | |
mouseLeave: function() { | |
this.set('hidden', true); | |
}, | |
mouseEnter: function() { | |
this.set('hidden', false); | |
} | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: 'video', | |
attributeBindings: 'src controls width height poster'.w(), | |
src: 'http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4', | |
poster: 'https://peach.blender.org/wp-content/uploads/bbb-splash.png', | |
controls: true, | |
didInsertElement: function() { | |
let self = this; | |
let observedEvents = `canplay ended error loadeddata loadstart | |
pause play playing progress seeked seeking stalled timeupdate waiting`.w(); | |
observedEvents.forEach(function(eventName) { | |
self.$().on(eventName, Ember.run.bind(self, self.updatePlayer, eventName)); | |
}); | |
}, | |
updatePlayer: function(eventName) { | |
this.sendAction('videoDidUpdate', this, eventName); | |
}, | |
playbackStateChanged: Ember.observer('isPaused', function() { | |
let el = this.get('element'); | |
(this.get('isPaused') === true) ? el.pause() : el.play(); | |
}) | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
actions: { | |
videoDidUpdate(videoElement, event) { | |
let video = videoElement.get('element'); | |
console.log(`Event triggered: ${event}`); | |
}, | |
togglePlayback() { | |
this.toggleProperty('isPaused'); | |
} | |
} | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName:'Ember Twiddle' | |
}); |
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
{ | |
"version": "0.4.8", | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.8/ember.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.9/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.8/ember-template-compiler.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment