soundcloud / soundcloud-custom-player

The SoundCloud custom javascript based player
http://soundcloud.com
705 stars 231 forks source link

custom next & previous buttons not working on firefox #62

Open rliriano opened 11 years ago

rliriano commented 11 years ago

This is the code im using for the buttons but are nor woking only on firefox

function getNextTrack(player) { var $player = $(player).closest('.sc-player'), $nextItem = $('.sc-trackslist li.active', $player).next('li'); if(!$nextItem.length){ $nextItem = $player.nextAll('div.sc-player:first').find('.sc-trackslist li:active'); } return $nextItem; };

function getPrevTrack(player) {
    var $player = $(player).closest('.sc-player'),
         $prevItem = $('.sc-trackslist li.active', $player).prev('li');
         if(!$prevItem.length){
              $prevItem = $player.prevAll('div.sc-player:first').find('.sc-trackslist li:last');
        }
        return $prevItem;
};

$(document).bind('onPlayerTrackFinish', function(event) { var $nextItem = getNextTrack(event.target); // init the next track but don't play :) $nextItem.click().click(); });

$('a.sc-next').live('click', function(event){ var $player = $(this).closest('.sc-player'), $nextItem = $('.sc-trackslist li.active', $player).next('li'); $nextItem.click(); console.log($nextItem); return false; });

$('a.sc-prev').live('click', function(event) { var $player = $(this).closest('.sc-player'), $prevItem = $('.sc-trackslist li.active', $player).prev('li'); $prevItem.click(); return false; });

cgfarmer4 commented 11 years ago

@rliriano probaby because .live() has been deprecated in jQuery since 1.7.

rliriano commented 11 years ago

@cgfarmer4 I was able to solve the proble, its the way firefox reads the audio/mpeg it was falling back to the flash version and it wasent firing this player.api_load(url); at around line 212, so I forced it by replacing it with $('.sc-player-engine-container').html(flashHtml(url)); so it creates the container for the flash engine