cms/app-client/app/components/player-component.js
changeset 94 62984937a062
parent 91 acfeddc7821d
child 191 db5711fbbb6c
--- a/cms/app-client/app/components/player-component.js	Thu Jan 21 00:11:10 2016 +0100
+++ b/cms/app-client/app/components/player-component.js	Thu Jan 21 21:07:02 2016 +0100
@@ -4,20 +4,25 @@
   classNames: ['player-component'],
   currentTime: "00:00",
   duration: "00:00",
+  documentLoaded: Ember.observer('document.mediaArray', function() {
+    var mediaList = this.get('document').get("mediaList");
+    if ((typeof(mediaList) !== 'undefined') && (mediaList.length > 0)){
+      if (this.audio.src){
+        this.pause();
+        this.updateProgress(0);
+      }
+      var mp3 = mediaList.findBy('format', 'audio/mpeg');
+      this.audio.src = mp3.url;
+      this.audio.load();
+      this.set("currentTime", "00:00");
+    }
 
-  _documentChanged: Ember.observer('document', function() {
-    this.pause();
-    this.changeTime(0);
-    this.updateProgress(0);
-    this.audio.src = this.get("document").get("master");
-    this.audio.load();
-    this.set("currentTime", "00:00");
   }),
 
   didInsertElement: function(){
     var _this = this;
 
-    this.audio = new Audio("http://stop.com.pk/file/music_folder/700.mp3");
+    this.audio = new Audio();
 
     this.button = {
       play: this.$('#action_play'),