author | Chloe Laisne <chloe.laisne@gmail.com> |
Mon, 04 Jul 2016 11:15:25 +0200 | |
changeset 217 | 989b9c36b849 |
parent 210 | 08ad36c693b1 |
child 220 | 2145b80776a3 |
permissions | -rw-r--r-- |
91 | 1 |
import DS from 'ember-data'; |
2 |
import Ember from 'ember'; |
|
94
62984937a062
- add params when modal appear so we can come back right on this document modal
nowmad@23.1.168.192.in-addr.arpa
parents:
91
diff
changeset
|
3 |
import _ from 'lodash/lodash'; |
91 | 4 |
|
217
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
5 |
export default DS.Model.extend({ |
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
6 |
|
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
7 |
uri: DS.attr('string'), |
210 | 8 |
issued: DS.attr('date'), |
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
9 |
title: DS.attr('string'), |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
10 |
language: DS.attr('string'), |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
11 |
publishers: DS.attr({ defaultValue: function() { return []; } }), |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
12 |
contributors: DS.attr({ defaultValue: function() { return []; } }), |
217
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
13 |
geoInfo: DS.attr({ defaultValue: function() { return {}; } }), |
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
14 |
mediaArray: DS.attr({ defaultValue: function() { return []; } }), |
91 | 15 |
|
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
16 |
mediaList: Ember.computed('mediaArray', function() { |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
17 |
var res = []; |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
18 |
var mp3 = null; |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
19 |
_.forEach(this.get('mediaArray'), function(m) { |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
20 |
if(m.format === 'audio/mpeg') { |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
21 |
mp3 = m; |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
22 |
} else if(m.format.startsWith('audio/')) { |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
23 |
res.push(m); |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
24 |
} |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
25 |
}); |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
26 |
if(mp3) { |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
27 |
res.unshift(mp3); |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
28 |
} |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
29 |
return res; |
217
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
30 |
}), |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
31 |
|
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
32 |
duration: Ember.computed('mediaArray', function() { |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
33 |
var self = this; |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
34 |
var duration = 0; |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
35 |
Object.keys(this.get('mediaArray')).forEach(function(key) { |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
36 |
if (!duration && self.get('mediaArray')[key].extent_ms) { |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
37 |
duration = self.get('mediaArray')[key].extent_ms; |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
38 |
}; |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
39 |
}); |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
40 |
return duration / 1000; |
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
41 |
}) |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
125
diff
changeset
|
42 |
|
91 | 43 |
}); |