Skip to content

Instantly share code, notes, and snippets.

@trek
Created June 20, 2011 14:31
Show Gist options
  • Save trek/1035715 to your computer and use it in GitHub Desktop.
Save trek/1035715 to your computer and use it in GitHub Desktop.
SC.Audio = SC.View.extend({
classNames: ['sc-audio'],
attributeBindings: ['src', 'autoplay', 'type', 'preload', 'loop', 'controls'],
controls: false,
autoplay: false,
preload: true,
loop: false,
tagName: 'audio',
type: "audio/mpeg",
message: 'Your browser does not support the audio element.',
isPlaying: false,
_updateElementPlayState: function(){
var playing = this.get('isPlaying');
playing ? this.$().trigger('play') : this.$().trigger('pause')
}.observes('isPlaying'),
defaultTemplate: function() {
var msg = this.get('message');
return SC.Handlebars.compile('%@'.fmt(msg));
}.property()
});
{{view SC.Audio autoplay="true" srcBinding="parentView.audioUrl" isPlayingBinding="Nikola.currentSongController.isPlaying"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment