cms/app-client/app/components/player-component.js
changeset 87 24fef043ea0b
parent 86 15ded106ef1a
child 91 acfeddc7821d
equal deleted inserted replaced
86:15ded106ef1a 87:24fef043ea0b
    18     var _this = this;
    18     var _this = this;
    19 
    19 
    20     this.audio = new Audio("http://stop.com.pk/file/music_folder/700.mp3");
    20     this.audio = new Audio("http://stop.com.pk/file/music_folder/700.mp3");
    21 
    21 
    22     this.button = {
    22     this.button = {
    23       play: $('#action_play'),
    23       play: this.$('#action_play'),
    24       progress: $('.progress')
    24       progress: this.$('.progress')
    25     };
    25     };
    26 
    26 
    27 		$(document).on('touchmove', function(e){
    27 		this.$(document).on('touchmove', function(e){
    28 			e.preventDefault();
    28 			e.preventDefault();
    29 		});
    29 		});
    30 
    30 
    31 		// seeker
    31 		// seeker
    32 		this.button.progress.on('mousedown', function(e){
    32 		this.button.progress.on('mousedown', function(e){
    43 
    43 
    44 		// update bar onchange
    44 		// update bar onchange
    45 		this.audio.addEventListener('timeupdate',function (){
    45 		this.audio.addEventListener('timeupdate',function (){
    46 			var curtime = _this.audio.currentTime,
    46 			var curtime = _this.audio.currentTime,
    47 				percent = (curtime/_this.audio.duration)*100,
    47 				percent = (curtime/_this.audio.duration)*100,
    48 				rounded = Math.round(percent*1000)/1000,
       
    49 				deg = 360/100*percent,
    48 				deg = 360/100*percent,
    50         minutes = Math.floor( curtime / 60),
    49         minutes = Math.floor( curtime / 60),
    51         seconds =  Math.floor(curtime) % 60;
    50         seconds =  Math.floor(curtime) % 60;
    52       _this.set('currentTime', ('0' + minutes).slice(-2)+':'+('0' + seconds).slice(-2));
    51       _this.set('currentTime', ('0' + minutes).slice(-2)+':'+('0' + seconds).slice(-2));
    53 			_this.updateProgress(deg);
    52 			_this.updateProgress(deg);
    64   changeTime: function(percent){
    63   changeTime: function(percent){
    65     var t = (this.audio.duration*percent)/100;
    64     var t = (this.audio.duration*percent)/100;
    66     this.audio.currentTime = t;
    65     this.audio.currentTime = t;
    67   },
    66   },
    68   updateProgress: function(deg){
    67   updateProgress: function(deg){
    69     var $slice = $('.slice');
    68     var $slice = this.$('.slice');
    70 
    69 
    71     if (deg > 180 && !$slice.is('.gt50')) {
    70     if (deg > 180 && !$slice.is('.gt50')) {
    72       $slice.addClass('gt50');
    71       $slice.addClass('gt50');
    73       $slice.append('<div class="pie fill"></div>');
    72       $slice.append('<div class="pie fill"></div>');
    74     } else if (deg < 180 && $slice.is('.gt50')) {
    73     } else if (deg < 180 && $slice.is('.gt50')) {
   108       if (this.button.play.is('.playing')) {
   107       if (this.button.play.is('.playing')) {
   109         this.pause();
   108         this.pause();
   110       } else {
   109       } else {
   111         this.play();
   110         this.play();
   112       }
   111       }
       
   112     },
       
   113     prevNextSong(change){
       
   114       this.sendAction("action", change);
   113     }
   115     }
   114   }
   116   }
   115 });
   117 });