| author | Chloe Laisne <chloe.laisne@gmail.com> |
| Tue, 28 Jun 2016 22:11:38 +0200 | |
| changeset 210 | 08ad36c693b1 |
| parent 209 | 35cb7200bb0a |
| child 211 | 7451203a1321 |
| permissions | -rw-r--r-- |
|
86
15ded106ef1a
add a player component to handle sound play/pause
nowmad@23.1.168.192.in-addr.arpa
parents:
diff
changeset
|
1 |
import Ember from 'ember'; |
|
15ded106ef1a
add a player component to handle sound play/pause
nowmad@23.1.168.192.in-addr.arpa
parents:
diff
changeset
|
2 |
|
|
15ded106ef1a
add a player component to handle sound play/pause
nowmad@23.1.168.192.in-addr.arpa
parents:
diff
changeset
|
3 |
export default Ember.Component.extend({ |
|
191
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
4 |
classNames: ['player-component'], |
|
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
192
diff
changeset
|
5 |
|
|
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
192
diff
changeset
|
6 |
player: Ember.inject.service(), |
|
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
192
diff
changeset
|
7 |
|
|
191
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
8 |
currentTime: "00:00", |
|
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
9 |
duration: "00:00", |
|
86
15ded106ef1a
add a player component to handle sound play/pause
nowmad@23.1.168.192.in-addr.arpa
parents:
diff
changeset
|
10 |
|
| 210 | 11 |
item: Ember.computed('player.item', function() { |
12 |
return this.get('player').get('item'); |
|
13 |
}), |
|
14 |
||
|
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
192
diff
changeset
|
15 |
documentLoaded: Ember.observer('player.item', function() { |
|
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
192
diff
changeset
|
16 |
var mediaList = this.get('player').get('item').get('mediaList'); |
|
191
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
17 |
if ((typeof(mediaList) !== 'undefined') && (mediaList.length > 0)) { |
|
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
18 |
if (this.audio.src){ |
|
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
19 |
this.pause(); |
|
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
20 |
this.updateProgress(0); |
|
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
21 |
} |
|
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
22 |
var mp3 = mediaList.findBy('format', 'audio/mpeg'); |
|
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
23 |
this.audio.src = mp3.url; |
|
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
24 |
this.audio.load(); |
|
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
25 |
this.set("currentTime", "00:00"); |
|
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
192
diff
changeset
|
26 |
//console.log(mp3.url); |
|
191
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
27 |
} |
|
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
28 |
}), |
|
86
15ded106ef1a
add a player component to handle sound play/pause
nowmad@23.1.168.192.in-addr.arpa
parents:
diff
changeset
|
29 |
|
|
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
192
diff
changeset
|
30 |
init: function() { |
|
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
192
diff
changeset
|
31 |
this._super(...arguments); |
|
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
192
diff
changeset
|
32 |
this.get('player'); |
|
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
192
diff
changeset
|
33 |
}, |
|
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
192
diff
changeset
|
34 |
|
|
191
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
35 |
didInsertElement: function() { |
|
87
24fef043ea0b
add control to go next/previous sound
nowmad@nowmads-macbook-pro.local
parents:
86
diff
changeset
|
36 |
}, |
|
191
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
37 |
|
|
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
38 |
actions: { |
|
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
39 |
|
| 210 | 40 |
play: function() { |
|
191
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
41 |
|
|
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
42 |
} |
|
db5711fbbb6c
Player component linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
94
diff
changeset
|
43 |
|
|
86
15ded106ef1a
add a player component to handle sound play/pause
nowmad@23.1.168.192.in-addr.arpa
parents:
diff
changeset
|
44 |
} |
|
15ded106ef1a
add a player component to handle sound play/pause
nowmad@23.1.168.192.in-addr.arpa
parents:
diff
changeset
|
45 |
}); |