Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attach scroller to element in jQuery

I have a modified jPlayer with a "Whats Playing" info bar.

The info bar display echoed info from a PHP file.

I need to attach a scroller to the info on that player bar but i cant seem to nail it.

The scroller is on a separate js file.

http://www.maxvergelli.com/jquery-scroller/

jQuery:

getCurrentTrack();

$('.now_playing').SetScroller({
    velocity: 50,
    direction: 'horizontal',
    startfrom: 'right',
    loop: 'infinite',
    movetype: 'linear',
    onmouseover: 'pause',
    onmouseout: 'play',
    onstartup: 'play',
    cursor: 'pointer'
});

function getCurrentTrack() {
    $('.now_playing').load('/player/readerPlayer2.php');
    setInterval(function() {
        $('.now_playing').load('/player/readerPlayer2.php');
    }, 9000);
};​

The PHP info:

<?php
header("Expires: Tue, 03 Jul 2040 06:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

$xml = simplexml_load_file("http://**.**.**.**:8000/live.xspf"); 

foreach ($xml->trackList->track as $data) { 
    $radio = $data->location;
    $song  = $data->title;  
    $info = $data->listeners;   
}
echo '<div class="IceSong">'.$song.'</div>';
?>
like image 542
TonalDev Avatar asked Nov 12 '22 14:11

TonalDev


1 Answers

Have you tried looking for output in the browser console?

I've just tried this and it seems to work fine for me when I remove the first slash from your load uri.

Please note that you can simply call your getCurrentTrack function again from the setInterval, rather than redeclaring it.

    function getCurrentTrack() {
        $('.now_playing').load('player/readerPlayer2.php');
        setInterval(getCurrentTrack, 9000);
    }

Another thing to point out is that you don't require a semicolon after your function declaration. For more information, please see the answer to Why should I use a semicolon after every function in javascript?

Hope that's helpful, -let me know how you get on.

like image 101
supermasher Avatar answered Nov 15 '22 04:11

supermasher