2012-12-19 44 views
5

我有一個帶有「Whats Playing」信息欄的修改過的jPlayer。將滾動條連接到jQuery中的元素

信息欄顯示從PHP文件回顯信息。

我需要附加一個滾輪到該播放器欄上的信息,但我似乎不能釘它。

滾動條位於單獨的js文件中。

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); 
};​ 

PHP的信息:

<?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>'; 
?> 

回答

1

您是否嘗試過在瀏覽器控制檯尋找輸出?

我剛剛嘗試過這一點,它似乎爲我工作正常,當我從您的加載uri刪除第一個斜槓。

請注意,您可以簡單地從setInterval調用getCurrentTrack函數,而不是重新聲明它。

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

另外要指出的是,你並不需要你的函數聲明之後分號。欲瞭解更多信息,請參閱Why should I use a semicolon after every function in javascript?的回答

希望這對我有幫助,讓我知道你是怎麼做的。

+0

Thanx for reply。我修改腳本到另一個,但我不能得到的信息顯示在滾動...滾動工作良好,雖然.. - > http://stackoverflow.com/questions/13938174/draw-stats-from-php -file/13938552#comment19220208_13938552如果您知道的話,仍然無法解決此問題。 – TonalDev