35 |
35 |
36 progressObserver: Ember.observer('player.progress', function() { |
36 progressObserver: Ember.observer('player.progress', function() { |
37 this.get('popcorn').currentTime(this.get('player').get('progress') / 1000); |
37 this.get('popcorn').currentTime(this.get('player').get('progress') / 1000); |
38 }), |
38 }), |
39 |
39 |
|
40 playingObserver: Ember.observer('player.playing', function() { |
|
41 if(this.get('player').get('playing')) { |
|
42 this.play(); |
|
43 } else { |
|
44 this.pause(); |
|
45 } |
|
46 }), |
|
47 |
40 init: function() { |
48 init: function() { |
41 this._super(...arguments); |
49 this._super(...arguments); |
42 this.get('player'); |
50 this.get('player'); |
43 }, |
51 }, |
44 |
52 |
45 didInsertElement: function() { |
53 didInsertElement: function() { |
46 this.set('popcorn', Popcorn('#popcorn-audio')); |
54 this.set('popcorn', Popcorn('#popcorn-audio')); |
47 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'))); |
48 this.get('popcorn').on('timeupdate', Ember.run.bind(this, this.get('onUpdate'))); |
56 this.get('popcorn').on('timeupdate', Ember.run.bind(this, this.get('onUpdate'))); |
49 this.get('popcorn').on('play', Ember.run.bind(this, this.get('onPlay'))); |
|
50 this.get('popcorn').on('pause', Ember.run.bind(this, this.get('onPause'))); |
|
51 |
57 |
52 this.get('player').on('reset', Ember.run.bind(this, function(id) { |
58 this.get('player').on('reset', Ember.run.bind(this, function(id) { |
53 if(this.get('player').get('item') !== id) { |
59 if(this.get('player').get('item') !== id) { |
54 this.get('popcorn').on('loadeddata', Ember.run.bind(this, this.get('play'))); |
60 this.get('popcorn').on('loadeddata', Ember.run.bind(this, this.get('play'))); |
55 } else { |
61 } else { |
65 this.get('player').set('progress', progress * 1000); |
71 this.get('player').set('progress', progress * 1000); |
66 this.set('head', progress); |
72 this.set('head', progress); |
67 this.set('remaining', duration - progress); |
73 this.set('remaining', duration - progress); |
68 }, |
74 }, |
69 |
75 |
70 onPlay: function() { |
|
71 this.get('player').set('playing', true); |
|
72 }, |
|
73 |
|
74 onPause: function() { |
|
75 this.get('player').set('playing', false); |
|
76 }, |
|
77 |
|
78 play: function() { |
76 play: function() { |
79 this.get('popcorn').play(); |
77 this.get('popcorn').play(); |
80 }, |
78 }, |
81 |
79 |
82 pause: function() { |
80 pause: function() { |