32 return duration; |
32 return duration; |
33 } |
33 } |
34 }), |
34 }), |
35 |
35 |
36 media: Ember.computed('mediaArray', function() { |
36 media: Ember.computed('mediaArray', function() { |
37 var array = []; |
37 var arrayMedia = []; |
38 var master = null; |
38 var master = null; |
39 _.forEach(this.get('mediaArray'), function(media) { |
39 _.forEach(this.get('mediaArray'), function(media) { |
40 var index = array.findIndex(element => element.format === media.format); |
40 var index = arrayMedia.findIndex(element => element.format === media.format); |
41 if(media.master) { |
41 if(media.master) { |
42 master = media; |
42 master = media; |
43 } |
43 } |
44 if(index === -1 && !media.master) { |
44 if(index === -1 && !media.master) { |
45 array.push(media); |
45 arrayMedia.push(media); |
46 } |
46 } |
47 }); |
47 }); |
48 array.sort((m1, m2) => { |
48 arrayMedia.sort((m1, m2) => { |
49 |
49 |
50 const f1 = m1.format; |
50 const f1 = m1.format; |
51 const f2 = m2.format; |
51 const f2 = m2.format; |
52 const w1 = this.get('constants').MEDIA_TYPE_WEIGHT[f1] || 0; |
52 const w1 = this.get('constants').MEDIA_TYPE_WEIGHT[f1] || 0; |
53 const w2 = this.get('constants').MEDIA_TYPE_WEIGHT[f2] || 0; |
53 const w2 = this.get('constants').MEDIA_TYPE_WEIGHT[f2] || 0; |
54 |
54 |
55 return w1-w2; |
55 return w1-w2; |
56 }); |
56 }); |
57 if(array.length === 0 && master) { |
57 if(arrayMedia.length === 0 && master) { |
58 array.push(master); |
58 arrayMedia.push(master); |
59 } |
59 } |
60 return array; |
60 return arrayMedia; |
61 }), |
61 }), |
62 |
62 |
63 video: Ember.computed('media', function() { |
63 video: Ember.computed('media', function() { |
64 return this.get('media').findIndex(element => element.format.match(new RegExp('^video/'))) > -1; |
64 return this.get('media').findIndex(element => element.format.match(new RegExp('^video/'))) > -1; |
65 }), |
65 }), |
66 |
66 |
67 duration: Ember.computed('duration_ms', function() { |
67 duration: Ember.computed( 'duration_ms', function() { |
68 return this.get('duration_ms')/1000; |
68 return this.get('duration_ms')/1000; |
69 }), |
69 }), |
70 |
70 |
71 publishers_disp: Ember.computed('publisher', 'publishers', function() { |
71 publishers_disp: Ember.computed('publisher', 'publishers', function() { |
72 return this.get('publisher')?this.get('publisher'):this.get('publishers').join(', '); |
72 return this.get('publisher')?this.get('publisher'):this.get('publishers').join(', '); |