Beispiel #1
0
/** 
 * Gets the HTML for the 'next track' of the jukebox.
 *
 * @author Ben Dodson
 * @since 8/22/05
 **/
function ajaxJukeboxNextTrack()
{
    global $include_path;
    writeLogData("messages", "Jukebox: Creating next track element");
    include_once $include_path . "jukebox/class.php";
    $jb = new jzJukebox();
    $fullList = $jb->getCurrentPlaylist();
    if ($fullList != array()) {
        $nextTrack = $fullList[getCurPlayingTrack() + 1];
        $fullname = $nextTrack;
        if (stristr($nextTrack, "/")) {
            $nArr = explode("/", $nextTrack);
            $nextTrack = $nArr[count($nArr) - 1];
        }
        $nextTrack = str_replace(".mp3", "", $nextTrack);
        if (strlen($nextTrack) > 20) {
            $nextTrack = substr($nextTrack, 0, 20) . "...";
        }
    }
    echo '<a href="javascript:void();" title="' . $fullname . '">' . $nextTrack . "</a>";
}
Beispiel #2
0
 /**
  * returns the currently playing track number
  * 
  * @author Ross Carlson
  * @version 2/9/05
  * @since 2/9/05
  * @param return Returns the currently playling track number
  */
 function getCurrentPlayingTrack()
 {
     return getCurPlayingTrack();
 }
Beispiel #3
0
/**
 * Passes a playlist to the jukebox player
 * 
 * @author Ross Carlson
 * @version 2/9/05
 * @since 2/9/05
 * @param $playlist The playlist that we are passing
 */
function playlist($playlist)
{
    global $include_path, $jbArr, $media_dirs, $jzSERVICES;
    if (isset($jbArr[$_SESSION['jb_id']]['prefix']) && $jbArr[$_SESSION['jb_id']]['prefix'] == "http") {
        $content = "";
        foreach ($playlist->getList() as $track) {
            $content .= $track->getFileName("user") . "\n";
        }
        $playlist = $content;
    } else {
        $playlist = $jzSERVICES->createPlaylist($playlist, "jukebox");
    }
    $myMpd = _mpdConnection();
    // Now let's get our current playlist and current position
    $curList = getCurPlaylist(true);
    $curTrack = getCurPlayingTrack();
    switch ($_SESSION['jb-addtype']) {
        case "end":
        case "current":
            $restart_playback = false;
            break;
        default:
            $restart_playback = true;
    }
    // Ok, now we need to figure out where to add the stuff
    if ($_SESSION['jb-addtype'] == "current") {
        // Ok, let's split our first playlist in 2 so we can add in the middle
        //$begArr = array_slice($curList,0,$curTrack+1);
        if (is_array($curList)) {
            $begArr = array();
            $endArr = array_slice($curList, $curTrack + 1);
        } else {
            $begArr = array();
            $endArr = array();
        }
    } else {
        if ($_SESSION['jb-addtype'] == "begin") {
            $begArr = array();
            $endArr = $curList;
        } else {
            if ($_SESSION['jb-addtype'] == "end") {
                $begArr = array();
                $endArr = array();
            } else {
                if ($_SESSION['jb-addtype'] == "replace") {
                    $begArr = array();
                    $endArr = array();
                }
            }
        }
    }
    if ($restart_playback === true) {
        $myMpd->Stop();
        $myMpd->PLClear();
    } else {
        if ($_SESSION['jb-addtype'] == "current") {
            // Remove everything at the end of the playlist, since we are going to readd it all.
            for ($i = sizeof($curList); $i > $curTrack; $i--) {
                $myMpd->PLRemove($i);
            }
        }
    }
    // Now let's send the new playlist to the player
    for ($i = 0; $i < count($begArr); $i++) {
        // Now let's add this
        if ($begArr[$i] != '') {
            $myMpd->PLAdd($begArr[$i]);
        }
    }
    // Ok, Now let's add the new stuff
    $pArray = explode("\n", $playlist);
    for ($i = 0; $i < count($pArray); $i++) {
        if ($pArray[$i] != "") {
            // Now let's clean up the paths so we can add the media
            $mArr = explode("|", $media_dirs);
            $track = trim($pArray[$i]);
            for ($e = 0; $e < count($mArr); $e++) {
                if (false !== strpos($track, $mArr[$e])) {
                    $track = trim(str_replace($mArr[$e] . "/", "", $track));
                    if ($track[0] == '/') {
                        $track = substr($track, 1);
                    }
                }
            }
            $myMpd->PLAdd($track);
        }
    }
    // Now let's finish this out
    for ($i = 0; $i < count($endArr); $i++) {
        // Now let's add this
        if ($endArr[$i] != '') {
            $myMpd->PLAdd($endArr[$i]);
        }
    }
    // Now let's jump to where we need to play
    switch ($_SESSION['jb-addtype']) {
        case "current":
            if ($curTrack == 0) {
                $curTrack = -1;
            }
            $_POST['jbjumpto'] = $curTrack + 1;
            break;
        case "end":
            $_POST['jbjumpto'] = $curTrack;
            break;
        case "replace":
        case "begin":
            $_POST['jbjumpto'] = 0;
            break;
    }
    if ($restart_playback) {
        control("jumpto");
    }
    control("play");
    if (defined('NO_AJAX_JUKEBOX')) {
        ?>
		<script>
			history.back();
		</script>
		<?php 
    }
    exit;
}
Beispiel #4
0
    $fullname = $curTrack;
    $curTrack = $display->returnShortName($curTrack, 25);
    ?>
						<?php 
    echo word("Now Playing:") . ' <a href="javascript:;" title="' . $fullname . '">' . $curTrack . "</a><br>";
    ?>
						<!--
						<span ID="CurTicker" STYLE="overflow:hidden; width:275px;"  onmouseover="CurTicker_PAUSED=true" onmouseout="CurTicker_PAUSED=false">
							
						</span>
						-->
						<?php 
    if ($func['nexttrack']) {
        $fullList = $jb->getCurrentPlaylist();
        if ($fullList != array()) {
            $nextTrack = $fullList[getCurPlayingTrack() + 1];
            $fullname = $nextTrack;
            if (stristr($nextTrack, "/")) {
                $nArr = explode("/", $nextTrack);
                $nextTrack = $nArr[count($nArr) - 1];
            }
            $nextTrack = str_replace(".mp3", "", $nextTrack);
            $nextTrack = $display->returnShortName($nextTrack, 30);
        }
        ?>
								<?php 
        echo word("Next Track:") . ' <a href="javascript:;" title="' . $fullname . '">' . $nextTrack . "</a><br>";
        ?>
								<!--
								<DIV ID="NextTicker" STYLE="overflow:hidden; width:275px;"  onmouseover="NextTicker_PAUSED=true" onmouseout="NextTicker_PAUSED=false">
									
Beispiel #5
0
    /**
     * Draws the play controller for the Jukezora interface
     * 
     * @author Ross Carlson
     * @version 01/21/05
     * @since 01/21/05
     */
    function jukeboxBlock()
    {
        global $this_page, $media_dirs, $jbArr, $root_dir, $include_path;
        $display = new jzDisplay();
        include_once $include_path . "jukebox/class.php";
        if (!isset($_SESSION['jb_playwhere'])) {
            $_SESSION['jb_playwhere'] = "stream";
        }
        $jb_playwhere = $_SESSION['jb_playwhere'];
        ?>
			<table width="100%" cellpadding="2" cellspacing="0" border="0" class="jz_block_td" height="100%">
				<tr>
					<td width="50%" valign="top" height="100%">
						<nobr>
						<?php 
        // Now let's create our Jukebox class and connect to it to make sure it works
        $jb = new jzJukebox();
        if (!$jb->connect()) {
            echo "We had a problem connecting to the player, sorry this is a fatal error!<br><br>";
            echo "Player Settings:<br>";
            for ($i = 0; $i < count($jbArr); $i++) {
                if ($jbArr[$i]['description'] == $_SESSION['jb_playwhere']) {
                    foreach ($jbArr[$i] as $setting => $value) {
                        echo $setting . " - " . $value . "<br>";
                    }
                }
            }
            echo "<br>Please check these with your player's settings";
            echo "<br>";
            ?>
								Playback to:<br>
								<?php 
            $arr = array();
            $arr['action'] = "jukebox";
            $arr['subaction'] = "jukebox-command";
            $arr['command'] = "playwhere";
            ?>
								<form action="<?php 
            echo urlize($arr);
            ?>
" method="post">
									<select name="jbplaywhere" class="jz_select" style="width:142;" onChange="submit()">
										<option <?php 
            if ($jb_playwhere == "stream") {
                echo " selected ";
            }
            ?>
value="stream">Stream</option>
										<?php 
            // Now let's get a list of all the jukeboxes that are installed
            for ($i = 0; $i < count($jbArr); $i++) {
                echo '<option ';
                if ($jb_playwhere == $jbArr[$i]['description']) {
                    echo " selected ";
                }
                echo 'value="' . $jbArr[$i]['description'] . '">' . $jbArr[$i]['description'] . '</option>';
            }
            ?>
									</select>
								</form>
								<?php 
            return;
        }
        // Let's figure out where they are playing
        if (isset($_SESSION['jb_playwhere'])) {
            $jb_playwhere = $_SESSION['jb_playwhere'];
        } else {
            $jb_playwhere = "";
        }
        $remain = $jb->getCurrentTrackRemaining() + 1;
        $jz_jbstatus = $jb->getPlayerStatus();
        if ($jz_jbstatus != "playing") {
            $remain = 0;
        }
        if ($remain == 1) {
            $remain = 0;
        }
        if ($jb_playwhere != "stream") {
            // Ok, now we need to make sure we can do things
            $func = $jb->jbAbilities();
            if ($func['playbutton']) {
                $display->displayJukeboxButton("play");
            }
            if ($func['pausebutton']) {
                $display->displayJukeboxButton("pause");
            }
            if ($func['stopbutton']) {
                $display->displayJukeboxButton("stop");
            }
            if ($func['shufflebutton']) {
                $display->displayJukeboxButton("random_play");
            }
            echo "<br>";
            if ($func['nextbutton']) {
                $display->displayJukeboxButton("previous");
            }
            if ($func['prevbutton']) {
                $display->displayJukeboxButton("next");
            }
            if ($func['clearbutton']) {
                $display->displayJukeboxButton("clear");
            }
            ?>
							<br>
							<?php 
            if ($func['status']) {
                ?>
								Status: 
								<?php 
                echo ucwords($jz_jbstatus);
                ?>
								<br>
							<?php 
            }
            ?>
							<?php 
            if ($func['stats']) {
                $jb->returnJBStats();
                echo '<br>';
            }
            ?>
						
							
							<?php 
            if ($func['progress']) {
                ?>
								Progress:
								<span id="timer"></span>
								<script> 
								<!--// 
								var loadedcolor='green' ;            // PROGRESS BAR COLOR
								var unloadedcolor='lightgrey';      // BGCOLOR OF UNLOADED AREA
								var barheight=10;                   // HEIGHT OF PROGRESS BAR IN PIXELS
								var barwidth=120;                   // WIDTH OF THE BAR IN PIXELS
								var bordercolor='black';            // COLOR OF THE BORDER
								var waitTime=<?php 
                echo $remain;
                ?>
;                   // NUMBER OF SECONDS FOR PROGRESSBAR
								--> 
								</script>
								<script language="javascript" src="<?php 
                echo $root_dir;
                ?>
/jukebox/pbar.js"></script>
								<?php 
                if ($jz_jbstatus == 'playing') {
                    ?>
								<script> 
								<!--// 
								var seconds = <?php 
                    echo $jb->getCurrentTrackLocation();
                    ?>
;
								var time = '';
								t = document.getElementById("timer");					
								function converTime(sec){
									ctr=0;
									while (sec >= 60){
										sec = sec - 60;
										ctr++;
									}
									if (ctr<0){ctr=0}
									if (sec<0){sec=0}
									if (sec < 10){
										sec = "0" + sec;
									}
								
									return ctr + ":" + sec;
								}
								
								function display(){ 
									seconds++
									
									t.innerHTML = converTime(seconds) + "/" + "<?php 
                    echo convertSecMins($jb->getCurrentTrackLength());
                    ?>
";
									ctr=0;
									setTimeout("display()",1000) 
								} 
								display() 
								--> 
								</script> 
								<?php 
                }
                ?>
							<?php 
            }
            ?>
							<?php 
            if ($func['volume']) {
                ?>
								<?php 
                $arr = array();
                $arr['action'] = "jukebox";
                $arr['subaction'] = "jukebox-command";
                $arr['command'] = "volume";
                $arr['frame'] = $_GET['frame'];
                ?>
								<form action="<?php 
                echo urlize($arr);
                ?>
" method="post">
									<input type="hidden" name="action" value="jukebox">
									<input type="hidden" name="subaction" value="jukebox-command">
									<input type="hidden" name="command" value="volume">
									<input type="hidden" name="frame" value="top">
									<select name="jbvol" class="jz_select" style="width:120px;" onChange="submit()">
										<?php 
                $vol = "";
                if (isset($_SESSION['jz_jbvol-' . $_SESSION['jb_id']])) {
                    $vol = $_SESSION['jz_jbvol-' . $_SESSION['jb_id']];
                }
                $c = 100;
                while ($c > 0) {
                    echo '<option ';
                    if ($c == $vol) {
                        echo ' selected ';
                    }
                    echo 'value="' . $c . '">Volume ' . $c . '%</option>';
                    $c = $c - 10;
                }
                ?>
										<option value="0">Mute</option>
									</select>
								</form>
								<br>
							<?php 
            }
            ?>
						<?php 
            // This closes our if to see if we are streaming or not
        }
        ?>
						Playback to:<br>
						<?php 
        $arr = array();
        $arr['action'] = "jukebox";
        $arr['subaction'] = "jukebox-command";
        $arr['command'] = "playwhere";
        $arr['frame'] = $_GET['frame'];
        ?>
						<form action="<?php 
        echo urlize($arr);
        ?>
" method="post">
							<input type="hidden" name="action" value="jukebox">
							<input type="hidden" name="subaction" value="jukebox-command">
							<input type="hidden" name="command" value="playwhere">
							<input type="hidden" name="frame" value="top">
							<select name="jbplaywhere" class="jz_select" style="width:120px;" onChange="submit()">
								<option <?php 
        if ($jb_playwhere == "stream") {
            echo " selected ";
        }
        ?>
value="stream">Stream</option>
								<?php 
        // Now let's get a list of all the jukeboxes that are installed
        for ($i = 0; $i < count($jbArr); $i++) {
            echo '<option ';
            if ($jb_playwhere == $jbArr[$i]['description']) {
                echo " selected ";
            }
            echo 'value="' . $jbArr[$i]['description'] . '">' . $jbArr[$i]['description'] . '</option>';
        }
        ?>
							</select>
						</form>
						<?php 
        if ($jb_playwhere != "stream" and $func['addtype']) {
            ?>
						<br>
						Add type:<br>
						<?php 
            // Now let's set the add type IF it hasn't been set
            if (!isset($_SESSION['jb-addtype'])) {
                $_SESSION['jb-addtype'] = "current";
            }
            ?>
						<?php 
            $arr = array();
            $arr['action'] = "jukebox";
            $arr['subaction'] = "jukebox-command";
            $arr['command'] = "addwhere";
            $arr['frame'] = $_GET['frame'];
            ?>
						<form action="<?php 
            echo urlize($arr);
            ?>
" method="post">
						<input type="hidden" name="action" value="jukebox">
						<input type="hidden" name="subaction" value="jukebox-command">
						<input type="hidden" name="command" value="addwhere">
						<select name="addplat" class="jz_select" style="width:142;" onChange="submit()">
							<option <?php 
            if ($_SESSION['jb-addtype'] == "current") {
                echo " selected ";
            }
            ?>
 value="current">At Current</option>
							<option <?php 
            if ($_SESSION['jb-addtype'] == "end") {
                echo " selected ";
            }
            ?>
value="end">At End</option>
							<option <?php 
            if ($_SESSION['jb-addtype'] == "begin") {
                echo " selected ";
            }
            ?>
value="begin">At Beginning</option>
                                                        <option <?php 
            if ($_SESSION['jb-addtype'] == "replace") {
                echo " selected ";
            }
            ?>
value="replace">Replace</option>
						</select>
					        </form>
						</nobr>
						<?php 
        }
        ?>
					</td>
					<td width="50%" valign="top">
						<?php 
        // Let's make sure they aren't streaming
        if ($jb_playwhere == "stream") {
            return;
        }
        ?>
						<?php 
        if ($func['nowplaying']) {
            ?>
							<nobr><?php 
            echo word("Now Playing:");
            ?>
<br> 
							<?php 
            $curTrack = $jb->getCurrentTrackName();
            if (strlen($curTrack) > 20) {
                $curTrack = substr($curTrack, 0, 20) . "...";
            }
            echo '&nbsp;' . $curTrack . "</nobr>";
            ?>
							<br>
						<?php 
        }
        ?>
						<?php 
        if ($func['nexttrack']) {
            ?>
							<nobr><?php 
            echo word("Next Track:");
            ?>
 <br>
							<?php 
            // Now let's figure out the next track and clean it up
            $fullList = $jb->getCurrentPlaylist();
            if (getCurPlayingTrack() + 1 < sizeof($fullList)) {
                $nextTrack = $fullList[getCurPlayingTrack() + 1];
            } else {
                $nextTrack = '-';
            }
            if (stristr($nextTrack, "/")) {
                $nArr = explode("/", $nextTrack);
                $nextTrack = $nArr[count($nArr) - 1];
            }
            $nextTrack = str_replace(".mp3", "", $nextTrack);
            if (strlen($nextTrack) > 20) {
                $nextTrack = substr($nextTrack, 0, 20) . "...";
            }
            echo '&nbsp;' . $nextTrack . "</nobr>";
            ?>
							<br><br>
						<?php 
        }
        ?>
						
						<?php 
        if ($func['fullplaylist']) {
            ?>
							Complete Playlist
							<br>
							<?php 
            // Now let's get the full playlist back
            $curTrackNum = $jb->getCurrentPlayingTrack();
            ?>
							<?php 
            $arr = array();
            $arr['action'] = "jukebox";
            $arr['subaction'] = "jukebox-command";
            $arr['command'] = "jumpto";
            ?>
							<form action="<?php 
            echo urlize($arr);
            ?>
" method="post">
								<input type="hidden" name="action" value="jukebox">
								<input type="hidden" name="subaction" value="jukebox-command">
								<input type="hidden" name="command" value="jumpto">
								<input type="hidden" name="frame" value="top">
								<select name="jbjumpto" class="jz_select" size="5" style="width:165px;"<?php 
            if ($func['jump']) {
                echo 'onChange="submit()"';
            }
            ?>
>
									<?php 
            for ($i = 0; $i < count($fullList); $i++) {
                echo '<option value="' . $i . '"';
                if ($curTrackNum == $i) {
                    echo " selected ";
                }
                echo '>' . $fullList[$i] . '</option>';
            }
            ?>
								</select>
							</form>
						<?php 
        }
        ?>
					</td>
				</tr>
			</table>
			<?php 
    }
Beispiel #6
0
/**
 * Passes a command to the jukebox player
 * 
 * @author Ross Carlson
 * @version 2/9/05
 * @since 2/9/05
 * @param $command The command that we passed to the player
 */
function control($command, $goBack = true)
{
    global $jbArr;
    // Now let's execute the command
    switch ($command) {
        case "play":
            file_get_contents("http://" . $jbArr[$_SESSION['jb_id']]['server'] . "/apicmd.asp?cmd=play");
            break;
        case "stop":
            unset($_SESSION['jb_at_playlist']);
            file_get_contents("http://" . $jbArr[$_SESSION['jb_id']]['server'] . "/apicmd.asp?cmd=stop");
            break;
        case "pause":
            file_get_contents("http://" . $jbArr[$_SESSION['jb_id']]['server'] . "/apicmd.asp?cmd=pause");
            break;
        case "previous":
            file_get_contents("http://" . $jbArr[$_SESSION['jb_id']]['server'] . "/apicmd.asp?cmd=prev");
            break;
        case "next":
            file_get_contents("http://" . $jbArr[$_SESSION['jb_id']]['server'] . "/apicmd.asp?cmd=next");
            break;
        case "volume":
            // Now we have to set the value based on 0-255
            $vol = $_POST['jbvol'];
            file_get_contents("http://" . $jbArr[$_SESSION['jb_id']]['server'] . "/apicmd.asp?cmd=volume&arg=" . $vol);
            break;
        case "playwhere":
            // Ok, let's set where they are playing
            $_SESSION['jb_playwhere'] = $_POST['jbplaywhere'];
            // Now let's figure out it's ID
            for ($i = 0; $i < count($jbArr); $i++) {
                if ($jbArr[$i]['description'] == $_SESSION['jb_playwhere']) {
                    $_SESSION['jb_id'] = $i;
                }
            }
            break;
        case "jumpto":
            // Ok, first we need to know what track number we are on
            $cur = getCurPlayingTrack();
            // Now where to jump to
            $pos = $_POST['jbjumpto'];
            // Now how many is that?
            $num = $pos - $cur;
            // Now let's jump that many
            if ($num > 0) {
                $c = 0;
                while ($c < $num) {
                    file_get_contents("http://" . $jbArr[$_SESSION['jb_id']]['server'] . "/apicmd.asp?cmd=next");
                    usleep(500);
                    $c++;
                }
            } else {
                $c = 0;
                while ($c > $num - 1) {
                    file_get_contents("http://" . $jbArr[$_SESSION['jb_id']]['server'] . "/apicmd.asp?cmd=prev");
                    usleep(500);
                    $c = $c - 1;
                }
            }
            break;
        case "clear":
            file_get_contents("http://" . $jbArr[$_SESSION['jb_id']]['server'] . "/apicmd.asp?cmd=stop");
            file_get_contents("http://" . $jbArr[$_SESSION['jb_id']]['server'] . "/apicmd.asp?cmd=clear");
            unset($_SESSION['jb_at_playlist']);
            break;
        case "random_play":
            file_get_contents("http://" . $jbArr[$_SESSION['jb_id']]['server'] . "/apicmd.asp?cmd=random");
            break;
    }
    usleep(50);
    if ($goBack) {
        ?>
			<script>
				history.back();
			</script>
			<?php 
    }
}
Beispiel #7
0
/**
* Passes a playlist to the jukebox player
* 
* @author Ben Dodson
* @version 9/15/07
* @since 9/15/07
* @param $playlist The playlist that we are passing
*/
function playlist($playlist)
{
    global $include_path, $jbArr, $jzSERVICES;
    if (isset($jbArr[$_SESSION['jb_id']]['prefix']) && $jbArr[$_SESSION['jb_id']]['prefix'] == "http") {
        $content = "";
        foreach ($playlist->getList() as $track) {
            $content .= $track->getFileName("user") . "\n";
        }
        $playlist = $content;
    } else {
        $playlist = $jzSERVICES->createPlaylist($playlist, "jukebox");
        $arr = explode("\n", $playlist);
        $arr2 = array();
        foreach ($arr as $a) {
            if (false === stristr($a, "://")) {
                $arr2[] = $a;
            } else {
                $arr2[] = $a;
            }
        }
        $playlist = implode("\n", $arr2);
    }
    writeLogData("messages", "VLC: Creating a playlist");
    // First we need to get the current playlist so we can figure out where to add
    $xml = getPlaylistXML();
    $res = $xml->xpath('//leaf');
    $curList = array();
    $curIDList = array();
    while (list(, $node) = each($res)) {
        if (isset($node['uri']) && $node['uri'] != "") {
            $curList[] = $node['uri'];
            $curIDList[] = $node['id'];
        }
    }
    // Let's get where we are in the current list
    writeLogData("messages", "VLC: Getting the current playing track number");
    $curTrack = getCurPlayingTrack();
    switch ($_SESSION['jb-addtype']) {
        case "end":
        case "current":
            $restart_playback = false;
            break;
        default:
            $restart_playback = true;
    }
    // Ok, now we need to figure out where to add the stuff
    if ($_SESSION['jb-addtype'] == "current") {
        // Ok, let's split our first playlist in 2 so we can add in the middle
        //$begArr = array_slice($curList,0,$curTrack+1);
        if (is_array($curList)) {
            $begArr = array();
            $endArr = array_slice($curList, $curTrack + 1);
        } else {
            $begArr = array();
            $endArr = array();
        }
    } else {
        if ($_SESSION['jb-addtype'] == "begin") {
            $begArr = array();
            $endArr = $curList;
        } else {
            if ($_SESSION['jb-addtype'] == "end") {
                $begArr = array();
                $endArr = array();
            } else {
                if ($_SESSION['jb-addtype'] == "replace") {
                    $begArr = array();
                    $endArr = array();
                }
            }
        }
    }
    if ($restart_playback === true) {
        writeLogData("messages", "VLC: Clearing the current playlist");
        control("clear", false);
    } else {
        if ($_SESSION['jb-addtype'] == "current") {
            // Remove everything at the end of the playlist, since we are going to readd it all.
            $arr = array("command" => "pl_delete");
            for ($i = sizeof($curList); $i > $curTrack; $i--) {
                $arr['id'] = $curIDList[$i];
                VLCRequest($arr);
            }
        }
    }
    writeLogData("messages", "VLC: Sending the new playlist to the player");
    // Now let's send the new playlist to the player
    for ($i = 0; $i < count($begArr); $i++) {
        // Now let's add this
        if ($begArr[$i] != "") {
            $arr = array("command" => "in_enqueue");
            $arr['input'] = $begArr[$i];
            VLCRequest($arr);
        }
    }
    // Ok, Now let's add the new stuff
    $pArray = explode("\n", $playlist);
    for ($i = 0; $i < count($pArray); $i++) {
        if ($pArray[$i] != "") {
            $arr = array("command" => "in_enqueue");
            $arr['input'] = $pArray[$i];
            VLCRequest($arr);
        }
    }
    // Now let's finish this out
    for ($i = 0; $i < count($endArr); $i++) {
        // Now let's add this
        if ($endArr[$i] != "") {
            $arr = array("command" => "in_enqueue");
            $arr['input'] = $endArr[$i];
            VLCRequest($arr);
        }
    }
    // Now let's jump to where we need to play
    switch ($_SESSION['jb-addtype']) {
        case "current":
            if ($curTrack == 0) {
                $curTrack = -1;
            }
            $_POST['jbjumpto'] = $curTrack + 1;
            break;
        case "end":
            $_POST['jbjumpto'] = $curTrack;
            break;
        case "replace":
        case "begin":
            $_POST['jbjumpto'] = 0;
            break;
    }
    if ($restart_playback) {
        //control("stop");
        //control("jumpto");
        control("pause");
        // play/pause
    }
    if (defined('NO_AJAX_JUKEBOX')) {
        ?>
		<script>
			history.back();
		</script>
		<?php 
    }
    exit;
}
Beispiel #8
0
/**
 * Returns the currently playing tracks path so we can get the node
 * 
 * @author Ross Carlson
 * @version 2/9/05
 * @since 2/9/05
 * @param return Returns the currently playling track's path
 */
function getCurTrackPath()
{
    global $jbArr;
    $serv1 = new SCXML();
    $serv1->set_host($jbArr[$_SESSION['jb_id']]['server']);
    $serv1->set_port($jbArr[$_SESSION['jb_id']]['port']);
    $serv1->set_password($jbArr[$_SESSION['jb_id']]['password']);
    $serv1->retrieveXML();
    $song_title = $serv1->fetchMatchingTag("SONGTITLE");
    $trackNum = getCurPlayingTrack();
    $pArray = getCurPlaylist();
    if (!isNothing($song_title)) {
        for ($i = 0; $i < count($pArray); $i++) {
            // Are we on it?
            if (stristr($pArray[$i], $song_title)) {
                $retVal = $pArray[$i];
            }
        }
    }
    return $retVal;
}
Beispiel #9
0
/**
 * Passes a playlist to the jukebox player
 * 
 * @author Ross Carlson
 * @version 2/9/05
 * @since 2/9/05
 * @param $playlist The playlist that we are passing
 */
function playlist($playlist)
{
    global $include_path, $jbArr, $jzSERVICES;
    if (isset($jbArr[$_SESSION['jb_id']]['prefix']) && $jbArr[$_SESSION['jb_id']]['prefix'] == "http") {
        $content = "";
        foreach ($playlist->getList() as $track) {
            $content .= $track->getFileName("user") . "\n";
        }
        $playlist = $content;
    } else {
        $playlist = $jzSERVICES->createPlaylist($playlist, "jukebox");
        $arr = explode("\n", $playlist);
        $arr2 = array();
        foreach ($arr as $a) {
            if (false === stristr($a, "://")) {
                $arr2[] = str_replace("/", "\\", $a);
            } else {
                $arr2[] = $a;
            }
        }
        $playlist = implode("\n", $arr2);
    }
    writeLogData("messages", "Winamp3: Creating a playlist");
    // First we need to get the current playlist so we can figure out where to add
    $clist = explode(";;;", @file_get_contents("http://" . $jbArr[$_SESSION['jb_id']]['server'] . ":" . $jbArr[$_SESSION['jb_id']]['port'] . "/getplaylisttitle?p=" . $jbArr[$_SESSION['jb_id']]['password'] . "&delim=;;;"));
    foreach ($clist as $item) {
        if ($item != "") {
            $curList[] = $item;
        }
    }
    // Let's get where we are in the current list
    writeLogData("messages", "Winamp3: Getting the current playing track number");
    $curTrack = getCurPlayingTrack();
    switch ($_SESSION['jb-addtype']) {
        case "end":
        case "current":
            $restart_playback = false;
            break;
        default:
            $restart_playback = true;
    }
    // Ok, now we need to figure out where to add the stuff
    if ($_SESSION['jb-addtype'] == "current") {
        // Ok, let's split our first playlist in 2 so we can add in the middle
        //$begArr = array_slice($curList,0,$curTrack+1);
        if (is_array($curList)) {
            $begArr = array();
            $endArr = array_slice($curList, $curTrack + 1);
        } else {
            $begArr = array();
            $endArr = array();
        }
    } else {
        if ($_SESSION['jb-addtype'] == "begin") {
            $begArr = array();
            $endArr = $curList;
        } else {
            if ($_SESSION['jb-addtype'] == "end") {
                $begArr = array();
                $endArr = array();
            } else {
                if ($_SESSION['jb-addtype'] == "replace") {
                    $begArr = array();
                    $endArr = array();
                }
            }
        }
    }
    if ($restart_playback === true) {
        writeLogData("messages", "Winamp3: Clearing the current playlist");
        control("clear", false);
    } else {
        if ($_SESSION['jb-addtype'] == "current") {
            // Remove everything at the end of the playlist, since we are going to readd it all.
            for ($i = sizeof($curList); $i > $curTrack; $i--) {
                $arr = array();
                $arr['index'] = $i;
                httpqRequest("deletepos", $arr);
            }
        }
    }
    writeLogData("messages", "Winamp3: Sending the new playlist to the player");
    // Now let's send the new playlist to the player
    for ($i = 0; $i < count($begArr); $i++) {
        // Now let's add this
        if ($begArr[$i] != "") {
            $arr = array();
            $arr['file'] = $begArr[$i];
            httpqRequest("playfile", $arr);
        }
    }
    // Ok, Now let's add the new stuff
    $pArray = explode("\n", $playlist);
    for ($i = 0; $i < count($pArray); $i++) {
        if ($pArray[$i] != "") {
            $arr = array();
            $arr['file'] = $pArray[$i];
            httpqRequest("playfile", $arr);
        }
    }
    // Now let's finish this out
    for ($i = 0; $i < count($endArr); $i++) {
        // Now let's add this
        if ($endArr[$i] != "") {
            $arr = array();
            $arr['file'] = $endArr[$i];
            httpqRequest("playfile", $arr);
        }
    }
    // Now let's jump to where we need to play
    switch ($_SESSION['jb-addtype']) {
        case "current":
            if ($curTrack == 0) {
                $curTrack = -1;
            }
            $_POST['jbjumpto'] = $curTrack + 1;
            break;
        case "end":
            $_POST['jbjumpto'] = $curTrack;
            break;
        case "replace":
        case "begin":
            $_POST['jbjumpto'] = 0;
            break;
    }
    if ($restart_playback) {
        control("jumpto");
        control("play");
    }
    if (defined('NO_AJAX_JUKEBOX')) {
        ?>
		<script>
			history.back();
		</script>
		<?php 
    }
    exit;
}
Beispiel #10
0
/**
 * Passes a playlist to the jukebox player
 * 
 * @author Ross Carlson
 * @version 4/9/05
 * @since 4/9/05
 * @param $playlist The playlist that we are passing
 */
function playlist($playlist)
{
    global $include_path, $jbArr, $media_dirs, $jzSERVICES;
    $playlist = $jzSERVICES->createPlaylist($playlist, "jukebox");
    // let's connect to the player
    $jukebox = new slim($jbArr[$_SESSION['jb_id']]['server'], $jbArr[$_SESSION['jb_id']]['port']);
    // Let's get where we are in the current list
    $curTrack = getCurPlayingTrack();
    // Now let's get the full current playlist
    $curList = getCurPlaylist(true);
    // Ok, now we need to figure out where to add the stuff
    if ($_SESSION['jb-addtype'] == "current") {
        // Ok, let's split our first playlist in 2 so we can add in the middle
        $begArr = @array_slice($curList, 0, $curTrack + 1);
        $endArr = @array_slice($curList, $curTrack + 1);
    } else {
        if ($_SESSION['jb-addtype'] == "begin") {
            $begArr = "";
            $endArr = array();
        } else {
            if ($_SESSION['jb-addtype'] == "end") {
                $begArr = $curList;
                $endArr = array();
            } else {
                if ($_SESSION['jb-addtype'] == "replace") {
                    $begArr = array();
                    $endArr = array();
                } else {
                    if ($_SESSION['jb-addtype'] == "replace") {
                        $begArr = array();
                        $endArr = array();
                    }
                }
            }
        }
    }
    // Now let's build the new playlist
    $prev = false;
    $curPlaylist = explode("\n", $playlist);
    if (is_array($begArr) and is_array($endArr)) {
        $newList = array_merge($begArr, $curPlaylist, $endArr);
    } else {
        $prev = true;
        $newList = explode("\n", $playlist);
    }
    $playlist = "";
    foreach ($newList as $item) {
        if ($item != "") {
            $playlist .= str_replace("/", "\\", $item) . "\n";
        }
    }
    // Let's stop the jukebox
    control("stop", false);
    // let's figure out the filename
    $fname = "__" . str_replace(":", "_", $jukebox->info['mac'] . ".m3u");
    $pl = false;
    // now let's find where it is
    $mDirs = explode("|", $media_dirs);
    foreach ($mDirs as $dir) {
        if (is_file($dir . "/" . $fname)) {
            $pl = $dir . "/" . $fname;
        }
    }
    $handle = fopen($pl, "w");
    fwrite($handle, $playlist);
    fclose($handle);
    // Now let's play it
    $jukebox->execute("playlist insert " . $fname);
    control("play");
    ?>
		<script>
			history.back();
		</script>
		<?php 
    exit;
}