cms/app-client/app/components/player-component.js
changeset 249 e4204b1a579a
parent 248 256272c33349
child 251 ac320de33ec7
equal deleted inserted replaced
248:256272c33349 249:e4204b1a579a
    31 
    31 
    32     itemLoaded: Ember.observer('player.model.media', function() {
    32     itemLoaded: Ember.observer('player.model.media', function() {
    33         this.get('popcorn').load();
    33         this.get('popcorn').load();
    34     }),
    34     }),
    35 
    35 
    36     progressObserver: Ember.observer('player.progress', function() {
       
    37         this.get('popcorn').currentTime(this.get('player').get('progress') / 1000);
       
    38     }),
       
    39 
       
    40     playingObserver: Ember.observer('player.playing', function() {
    36     playingObserver: Ember.observer('player.playing', function() {
    41         if(this.get('player').get('playing')) {
    37         if(this.get('player').get('playing')) {
    42             this.play();
    38             this.play();
    43         } else {
    39         } else {
    44             this.pause();
    40             this.pause();
    45         } 
    41         } 
    46     }),
    42     }),
    47 
    43 
    48     init: function() {
    44     init: function() {
       
    45         var self = this;
       
    46         this.get('player').on('progressupdate', function(progress) {
       
    47             self.get('popcorn').currentTime(progress / 1000);
       
    48         });
       
    49 
    49         this._super(...arguments);
    50         this._super(...arguments);
    50         this.get('player');
       
    51     },
    51     },
    52 
    52 
    53     didInsertElement: function() {
    53     didInsertElement: function() {
    54         this.set('popcorn', Popcorn('#popcorn-audio'));
    54         this.set('popcorn', Popcorn('#popcorn-audio'));
    55         this.get('popcorn').on('loadeddata', Ember.run.bind(this, this.get('onUpdate')));
    55         this.get('popcorn').on('loadeddata', Ember.run.bind(this, this.get('onUpdate')));
    66 
    66 
    67     onUpdate: function() {
    67     onUpdate: function() {
    68         var progress = this.get('popcorn').currentTime();
    68         var progress = this.get('popcorn').currentTime();
    69         var duration = this.get('popcorn').duration();
    69         var duration = this.get('popcorn').duration();
    70         this.$('.bar .value').width(progress * 100 / duration + '%');
    70         this.$('.bar .value').width(progress * 100 / duration + '%');
    71         this.get('player').set('progress', progress * 1000);
    71         this.get('player').setProgress(progress * 1000);
    72         this.set('head', progress);
    72         this.set('head', progress);
    73         this.set('remaining', duration - progress);
    73         this.set('remaining', duration - progress);
    74     },
    74     },
    75 
    75 
    76     play: function() {
    76     play: function() {