define(["ember","text!./audio-tmpl.hbs","audio5"],function(a,b,c){return a.View.extend({template:a.Handlebars.compile(b),src:"",sound:null,_position:"00:00",position:function(){return this.get("sound")?this.get("sound").position:"00:00"}.property("_position","playing"),_duration:0,duration:function(){if(!this.get("sound"))return"00:00";var a=this.get("sound").duration,b=Math.floor(a/60),c=Math.floor(a%60);return(10>b?"0":"")+b+":"+(10>c?"0":"")+c}.property("sound","playing","_duration"),playing:null,disabled:function(){return!this.get("src")}.property(),domReady:function(){var a=this;this.set("playing",!1);var b=new c({ready:function(){this.on("timeupdate",function(b,c){a.get("isDestroyed")||a.get("isDestroying")||(console.log(b,c),a.setProperties({_position:b}))}),this.on("canplay",function(){a.get("isDestroyed")||a.get("isDestroying")||(console.log("canplay!"),console.log(a.get("sound").duration))}),this.on("loadedmetadata",function(){a.get("isDestroyed")||a.get("isDestroying")||(console.log("loadedmetadata!"),console.log(a.get("sound").duration))}),this.on("progress",function(b){a.get("isDestroyed")||a.get("isDestroying")||(console.log("progress: "+b),a.set("_duration",a.get("sound").duration))}),this.on("ended",function(){console.log("ended"),a.set("playing",!1),a.set("_position",a.get("duration"))}),a.get("src")&&this.load(a.get("src"));var b=this;a.$().on("click",".play",function(){a.set("playing",!0),b.play()}).on("click",".pause",function(){a.set("playing",!1),b.pause()})}});this.set("sound",b)}.on("didInsertElement"),willDestroy:function(){console.log("willDestroy"),this.get("sound")&&this.get("sound").destory&&this.get("sound").destory()}.on("willDestroyElement")})});