From 088435452bd7cdef1558ef9a21973c7ba41e8e26 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Wed, 29 Jun 2011 03:44:39 +0400 Subject: [PATCH] Fixed autoplay bug #84 --- app/coffeescripts/player.coffee | 4 +++- public/javascripts/coffee/player.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/coffeescripts/player.coffee b/app/coffeescripts/player.coffee index e3c144d..a614e38 100644 --- a/app/coffeescripts/player.coffee +++ b/app/coffeescripts/player.coffee @@ -69,6 +69,8 @@ class Player $('.playlist').html($('.playlist-tracks')).scrollbar $('.playlist-tracks').sortable axis: 'y', handle: '.dragbox' + console.log _player.hasTrack() + console.log initial_count if autoplay _player.setTrack($('.playlist-tracks li').last().attr('id').split('i')[1]) else if initial_count == 0 and not _player.hasTrack() @@ -99,7 +101,7 @@ class Player hasTrack: -> if $('#jplayer audio').length > 0 - return $('#jplayer audio').attr('src')? + return $('#jplayer audio').attr('src')? and $('#jplayer audio').attr('src') != '' else if $('#jplayer object').length > 0 $('#jplayer').jPlayer 'play' true diff --git a/public/javascripts/coffee/player.js b/public/javascripts/coffee/player.js index 3471a85..e728f5d 100644 --- a/public/javascripts/coffee/player.js +++ b/public/javascripts/coffee/player.js @@ -80,6 +80,8 @@ Player = (function() { axis: 'y', handle: '.dragbox' }); + console.log(_player.hasTrack()); + console.log(initial_count); if (autoplay) { _player.setTrack($('.playlist-tracks li').last().attr('id').split('i')[1]); } else if (initial_count === 0 && !_player.hasTrack()) { @@ -116,7 +118,7 @@ Player = (function() { }; Player.prototype.hasTrack = function() { if ($('#jplayer audio').length > 0) { - return $('#jplayer audio').attr('src') != null; + return ($('#jplayer audio').attr('src') != null) && $('#jplayer audio').attr('src') !== ''; } else if ($('#jplayer object').length > 0) { $('#jplayer').jPlayer('play'); true;