Scrobble and length fix

This commit is contained in:
Gregory Eremin
2011-10-12 13:33:25 +04:00
parent 0ec0b14172
commit 99fc62cde9
3 changed files with 14 additions and 13 deletions
+10 -9
View File
@@ -83,6 +83,7 @@ class window.Player
$obj.addClass 'now'
_vk_music.search track.artist, track.name, track.duration, (audio) ->
_player.playSource audio.url
console.log(track)
if track.length == 0
len = parseInt(audio.duration, 10)
duration = Math.floor(len / 60)+':'+(len - Math.floor(len / 60) * 60)
@@ -117,17 +118,17 @@ class window.Player
nextTrack: (manual) ->
manual = manual?
cnt = $('.playlist li').length
if not this.onShuffle() # Shuffle off
if $('.playlist .now').next().length == 0 # Last track and repeat is on
if _player.onRepeat() or manual # Repeat or manual click
if not this.onShuffle() # Shuffle off
if $('.playlist .now').next().length == 0 # Last track and repeat is on
if _player.onRepeat() or manual # Repeat or manual click
return $('.playlist li').first().attr('id').split('i')[1]
else
false
else
return $('.playlist .now').next().attr('id').split('i')[1]
else if cnt == 1 # Single track in the playlist
else if cnt == 1 # Single track in the playlist
return $('.playlist li').first().attr('id').split('i')[1]
else # Shuffle on
else # Shuffle on
while true
rnd = Math.floor(Math.random() * (cnt + .999))
$li = $('.playlist li').eq rnd
@@ -137,14 +138,14 @@ class window.Player
prevTrack: ->
cnt = $('.playlist li').length
if not _player.onShuffle() # Shuffle off
if $('.playlist .now').prev().length == 0 # First track in the playlist
if not _player.onShuffle() # Shuffle off
if $('.playlist .now').prev().length == 0 # First track in the playlist
return $('.playlist li').last().attr('id').split('i')[1]
else
return $('.playlist .now').prev().attr('id').split('i')[1]
else if cnt == 1 # Single track in the playlist
else if cnt == 1 # Single track in the playlist
return $('.playlist li').first().attr('id').split('i')[1]
else # Shuffle on
else # Shuffle on
while true
rnd = Math.floor(Math.random() * (cnt + .999))
$li = $('.playlist li').eq rnd