コード例 #1
0
ファイル: mpd.php プロジェクト: seanfbrown/jinzora
/**
 * Returns the current playing track
 * 
 * @author Ross Carlson
 * @version 2/9/05
 * @since 2/9/05
 * @return Returns the name of the current playing track
 */
function getCurTrackName()
{
    global $jbArr;
    $myMpd = _mpdConnection();
    if ($myMpd->current_track_id == -1) {
        return false;
    }
    if (isset($jbArr[$_SESSION['jb_id']]['prefix']) && $jbArr[$_SESSION['jb_id']]['prefix'] == "http") {
        $id = getTrackIdFromURL($myMpd->playlist[$myMpd->current_track_id]['file']);
        if (false !== $id) {
            $track = new jzMediaTrack($id, 'id');
            $meta = $track->getMeta();
            return $meta['artist'] . ' - ' . $meta['title'];
        } else {
            return 'Unknown';
        }
    } else {
        return $myMpd->playlist[$myMpd->current_track_id]['Artist'] . " - " . $myMpd->playlist[$myMpd->current_track_id]['Title'];
    }
}
コード例 #2
0
ファイル: wmptrack.php プロジェクト: seanfbrown/jinzora
if (!defined(JZ_SECURE_ACCESS)) {
    die('Security breach detected.');
}
/**
* Displays the track details for the currently playing track in WMP
*
* @author Ross Carlson
* @since 8.3.06
* @version 8.3.06
**/
global $this_site, $root_dir, $jzSERVICES, $web_root;
// Let's setup our display object
$display = new jzDisplay();
// Let's create the track object
$track = new jzMediaTrack($_GET['jz_path']);
$meta = $track->getMeta();
// Now let's get the album and artist
$album = $track->getNaturalParent("album");
$artist = $album->getNaturalParent("artist");
$desc = $album->getDescription();
while (substr($desc, 0, 4) == "<br>" or substr($desc, 0, 6) == "<br />") {
    if (substr($desc, 0, 4) == "<br>") {
        $desc = substr($desc, 5);
    }
    if (substr($desc, 0, 6) == "<br />") {
        $desc = substr($desc, 7);
    }
}
// Now let's get the art
$art = $album->getMainArt("200x200");
if ($art != "") {
コード例 #3
0
ファイル: shoutcast.php プロジェクト: seanfbrown/jinzora
/**
 * Gets the length of the current track
 * 
 * @author Ross Carlson
 * @version 2/9/05
 * @since 2/9/05
 * @param return returns the amount of time remaining in seconds
 */
function getCurTrackLength()
{
    global $jbArr, $media_dirs;
    // Ok, now we need to get the length of this track by reading it's meta data
    $path = getCurTrackPath();
    $mArr = explode("|", $media_dirs);
    for ($i = 0; $i < count($mArr); $i++) {
        $path = str_replace($mArr[$i] . "/", "", $path);
    }
    $track = new jzMediaTrack($path);
    $meta = $track->getMeta();
    return $meta['length'];
}
コード例 #4
0
ファイル: vlc.php プロジェクト: seanfbrown/jinzora
/**
 * Gets the track title from
 * its ID.
 */
function idToName($id)
{
    $track = new jzMediaTrack($id, 'id');
    $meta = $track->getMeta();
    $title = '';
    if (!isNothing($meta['artist'])) {
        $title .= $meta['artist'];
    }
    if (!isNothing($meta['title'])) {
        if (!isNothing($title)) {
            $title .= ' - ';
        }
        $title .= $meta['title'];
    }
    if (isNothing($title)) {
        $title = $track->getName();
    }
    return $title;
}
コード例 #5
0
ファイル: class-backend.php プロジェクト: seanfbrown/jinzora
 /**
  * Unsets the 'currently playing' info for the user.
  * If $user is false, removes all tracks.
  * If $sid is false, removes all tracks for $user.
  *
  * @author Ben Dodson
  * @since 1/23/05
  * @version 1/23/05
  **/
 function unsetPlaying($user = false, $sid = false)
 {
     $filename = $this->getDataDir() . "/now-playing.dat";
     if (file_exists($filename)) {
         $array = unserialize(file_get_contents($filename));
     } else {
         $array = array();
     }
     // First let's make sure we didn't do this too fast
     // If we're using some players they just buffer too fast
     // And we think the file is done when it's not
     if (isset($array[$user][$sid]['path'])) {
         $track = new jzMediaTrack($array[$user][$sid]['path']);
         $meta = $track->getMeta();
     } else {
         $meta = array();
         $meta['length'] = 60;
     }
     if ($user === false) {
         $array = array();
     } else {
         if ($sid === false) {
             unset($array[$user]);
         } else {
             if (time() + $meta['length'] - 30 < time()) {
                 unset($array[$user][$sid]);
             }
         }
     }
     $handle = fopen($filename, "w");
     fwrite($handle, serialize($array));
     fclose($handle);
 }
コード例 #6
0
ファイル: trackinfo.php プロジェクト: seanfbrown/jinzora
    $returnvalue = "";
    if (exec($command, $output, $returnvalue)) {
        ?>
					<SCRIPT LANGUAGE=JAVASCRIPT><!--\
						s = document.getElementById("status");
						s.innerHTML = '<nobr><?php 
        echo word("Status: updating tags...");
        ?>
</nobr>';
						-->
					</SCRIPT>
					<?php 
        flushdisplay();
        // Now we need to get the meta data from the orginal file so we can write it to the new file
        $tMeta = new jzMediaTrack($track->getPath("String"));
        $meta = $tMeta->getMeta();
        // Now let's write this
        $jzSERVICES->setTagData($newPath, $meta);
        ?>
					<SCRIPT LANGUAGE=JAVASCRIPT><!--\
						p = document.getElementById("path");
						o = document.getElementById("oldname");
						n = document.getElementById("newname");
						s = document.getElementById("status");
						p.innerHTML = '<?php 
        echo word("Complete!");
        ?>
';
						o.innerHTML = '&nbsp;';
						n.innerHTML = '&nbsp;';
						s.innerHTML = '&nbsp;';
コード例 #7
0
ファイル: api.php プロジェクト: jinzora/jinzora3
/**
 * 
 * Echos out the XML header information
 *
 * @author Ross Carlson
 * @since 3/31/05
 * 
 **/
function getCurrentTrack()
{
    global $jzUSER, $this_site, $root_dir;
    // What kind of output?
    if (isset($_REQUEST['type'])) {
        $type = $_REQUEST['type'];
    } else {
        $type = "xml";
    }
    // Now let's set the width
    if (isset($_REQUEST['imagesize'])) {
        $imagesize = $_REQUEST['imagesize'] . "x" . $_REQUEST['imagesize'];
    } else {
        $imagesize = "150x150";
    }
    // Now let's see when to stop
    if (isset($_REQUEST['count'])) {
        $total = $_REQUEST['count'];
    } else {
        $total = 1;
    }
    // Let's start the page
    if ($type == "xml") {
        echoXMLHeader();
    }
    // Now let's get the data
    $be = new jzBackend();
    $ar = $be->getPlaying();
    $display = new jzDisplay();
    $fullList = "";
    $found = false;
    foreach ($ar as $user => $tracks) {
        $name = $jzUSER->getSetting("full_name");
        if ($name == "") {
            $name = $jzUSER->lookupName($user);
            // that's the user name
        }
        $i = 0;
        foreach ($tracks as $time => $song) {
            // Now let's make sure this is the right user
            if ($name == $jzUSER->getName()) {
                // Now let's make sure we don't list this twice
                if (stristr($fullList, $song['path'] . "-" . $name . "\n")) {
                    continue;
                }
                $fullList .= $song['path'] . "-" . $name . "\n";
                // Now let's create the objects we need
                $node = new jzMediaNode($song['path']);
                $track = new jzMediaTrack($song['path']);
                $album = $node->getParent();
                $artist = $album->getParent();
                $meta = $track->getMeta();
                // Now, now let's echo out the data
                switch ($type) {
                    case "xml":
                        echo "  <item>\n";
                        echo "    <title>" . $this_site . xmlUrlClean($meta['title']) . "</title>\n";
                        echo "    <album>\n";
                        echo "      <name>" . $this_site . xmlUrlClean($album->getName()) . "</name>\n";
                        echo "      <image>" . $this_site . xmlUrlClean($display->returnImage($album->getMainArt(false, true, "audio", true), $album->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true)) . "</image>\n";
                        echo "    </album>\n";
                        echo "    <artist>\n";
                        echo "      <name>" . $this_site . xmlUrlClean($artist->getName()) . "</name>\n";
                        echo "      <image>" . $this_site . xmlUrlClean($display->returnImage($artist->getMainArt(false, true, "audio", true), $artist->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true)) . "</image>\n";
                        echo "    </artist>\n";
                        echo "  </item>\n";
                        break;
                    case "html":
                        if (isset($_REQUEST['align'])) {
                            if ($_REQUEST['align'] == "center") {
                                echo "<center>";
                            }
                        }
                        echo $meta['title'] . "<br>";
                        echo $album->getName() . "<br>";
                        echo $this_site . $display->returnImage($album->getMainArt(false, true, "audio", true), $album->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true) . "<br>";
                        echo $artist->getName() . "<br>";
                        echo $display->returnImage($artist->getMainArt(false, true, "audio", true), $artist->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true) . "<br>";
                        break;
                    case "mt":
                        $art = $album->getMainArt($imagesize, true, "audio", true);
                        if ($art) {
                            // Now let's try to get the link from the amazon meta data service
                            if ($_REQUEST['amazon_id'] != "") {
                                $jzService = new jzServices();
                                $jzService->loadService("metadata", "amazon");
                                $id = $jzService->getAlbumMetadata($album, false, "id");
                                echo '<a target="_blank" href="http://www.amazon.com/exec/obidos/tg/detail/-/' . $id . '/' . $_REQUEST['amazon_id'] . '/">';
                            }
                            $display->image($art, $album->getName(), 150, false, "limit");
                            if ($_REQUEST['amazon_id'] != "") {
                                echo '</a>';
                            }
                            echo "<br>";
                        }
                        echo $meta['title'] . "<br>";
                        if ($_REQUEST['amazon_id'] != "") {
                            $jzService = new jzServices();
                            $jzService->loadService("metadata", "amazon");
                            $id = $jzService->getAlbumMetadata($album, false, "id");
                            echo '<a target="_blank" href="http://www.amazon.com/exec/obidos/tg/detail/-/' . $id . '/' . $_REQUEST['amazon_id'] . '/">' . $album->getName() . "</a><br>";
                        } else {
                            echo $album->getName() . "<br>";
                        }
                        echo $artist->getName() . "<br>";
                        break;
                }
                $found = true;
                // Now should we stop?
                $i++;
                if ($i >= $total) {
                    break;
                }
            }
        }
    }
    if (!$found) {
        // Ok, we didn't find anything so let's get the last thing they played...
        $be = new jzBackend();
        $history = explode("\n", $be->loadData("playhistory-" . $jzUSER->getID()));
        $track = new jzMediatrack($history[count($history) - 1]);
        $album = $track->getParent();
        $artist = $album->getParent();
        $meta = $track->getMeta();
        // Now, now let's echo out the data
        switch ($type) {
            case "xml":
                echo "  <item>\n";
                echo "    <title>" . $this_site . xmlUrlClean($meta['title']) . "</title>\n";
                echo "    <album>\n";
                echo "      <name>" . $this_site . xmlUrlClean($album->getName()) . "</name>\n";
                echo "      <image>" . $this_site . xmlUrlClean($display->returnImage($album->getMainArt(false, true, "audio", true), $album->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true)) . "</image>\n";
                echo "    </album>\n";
                echo "    <artist>\n";
                echo "      <name>" . $this_site . xmlUrlClean($artist->getName()) . "</name>\n";
                echo "      <image>" . $this_site . xmlUrlClean($display->returnImage($artist->getMainArt(false, true, "audio", true), $artist->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true)) . "</image>\n";
                echo "    </artist>\n";
                echo "  </item>\n";
                break;
            case "html":
                if (isset($_REQUEST['align'])) {
                    if ($_REQUEST['align'] == "center") {
                        echo "<center>";
                    }
                }
                echo $meta['title'] . "<br>";
                echo $album->getName() . "<br>";
                echo $this_site . $display->returnImage($album->getMainArt(false, true, "audio", true), $album->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true) . "<br>";
                echo $artist->getName() . "<br>";
                echo $display->returnImage($artist->getMainArt(false, true, "audio", true), $artist->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true) . "<br>";
                break;
            case "mt":
                if (isset($_REQUEST['align'])) {
                    if ($_REQUEST['align'] == "center") {
                        echo "<center>";
                    }
                }
                $art = $album->getMainArt($imagesize, true, "audio", true);
                if ($art) {
                    // Now let's try to get the link from the amazon meta data service
                    if ($_REQUEST['amazon_id'] != "") {
                        $jzService = new jzServices();
                        $jzService->loadService("metadata", "amazon");
                        $id = $jzService->getAlbumMetadata($album, false, "id");
                        echo '<a target="_blank" href="http://www.amazon.com/exec/obidos/tg/detail/-/' . $id . '/' . $_REQUEST['amazon_id'] . '/">';
                    }
                    $display->image($art, $album->getName(), 150, false, "limit");
                    if ($_REQUEST['amazon_id'] != "") {
                        echo '</a>';
                    }
                    echo "<br>";
                }
                echo $meta['title'] . "<br>";
                if ($_REQUEST['amazon_id'] != "") {
                    $jzService = new jzServices();
                    $jzService->loadService("metadata", "amazon");
                    $id = $jzService->getAlbumMetadata($album, false, "id");
                    echo '<a target="_blank" href="http://www.amazon.com/exec/obidos/tg/detail/-/' . $id . '/' . $_REQUEST['amazon_id'] . '/">' . $album->getName() . "</a><br>";
                } else {
                    echo $album->getName() . "<br>";
                }
                echo $artist->getName() . "<br>";
                break;
        }
    }
    // Now let's close out
    switch ($type) {
        case "xml":
            echoXMLFooter();
            break;
        case "html":
            echo '<a target="_blank" title="Jinzora :: Free Your Media!" href="http://www.jinzora.com"><img src="http://www.jinzora.com/downloads/button-stream.gif" border="0"></a>';
            break;
        case "mt":
            echo '<a target="_blank" title="Jinzora :: Free Your Media!" href="http://www.jinzora.com"><img src="http://www.jinzora.com/downloads/button-stream.gif" border="0"></a>';
            break;
    }
    if (isset($_REQUEST['align'])) {
        if ($_REQUEST['align'] == "center") {
            echo "</center>";
        }
    }
}
コード例 #8
0
ファイル: quickbox.php プロジェクト: seanfbrown/jinzora
/**
 * Returns the current playing track
 * 
 * @author Ben Dodson
 * @version 12/04/08
 * @since 12/04/08
 * @return Returns the name of the current playing track
 */
function getCurTrackName()
{
    $box = Quickbox::load();
    if (sizeof($box['playlist']) > 0 && isset($box['pos'])) {
        $entry = $box['playlist'][$box['pos']];
    }
    if (false !== ($id = getTrackIdFromURL($entry))) {
        $track = new jzMediaTrack($id, 'id');
        $meta = $track->getMeta();
        return $meta['artist'] . ' - ' . $meta['title'];
    } else {
        return word('Unknown');
    }
}
コード例 #9
0
ファイル: winamp3.php プロジェクト: seanfbrown/jinzora
/**
 * Returns the currently playing playlist
 * 
 * @author Ross Carlson
 * @version 2/9/05
 * @since 2/9/05
 * @param return Returns the currently playling playlist
 */
function getCurPlaylist()
{
    global $jbArr;
    $val = array();
    if (isset($jbArr[$_SESSION['jb_id']]['prefix']) && $jbArr[$_SESSION['jb_id']]['prefix'] == "http") {
        $arr = httpqRequest('getplaylistfile', array('delim' => ';;;'));
        $arr = explode(';;;', $arr);
        foreach ($arr as $i => $url) {
            if (false != ($id = getTrackIdFromURL($url))) {
                $track = new jzMediaTrack($id, 'id');
                $meta = $track->getMeta();
                $title = '';
                if (!isNothing($meta['artist'])) {
                    $title .= $meta['artist'];
                }
                if (!isNothing($meta['title'])) {
                    if (!isNothing($title)) {
                        $title .= ' - ';
                    }
                    $title .= $meta['title'];
                }
                if (isNothing($title)) {
                    $title = $track->getName();
                }
                $val[] = $title;
            } else {
                // $val[] = $url; // faster
                $val[] = httpqRequest('getplaylisttitle', array('index' => $i));
                // better
            }
        }
    } else {
        $val = explode(";;;", @file_get_contents("http://" . $jbArr[$_SESSION['jb_id']]['server'] . ":" . $jbArr[$_SESSION['jb_id']]['port'] . "/getplaylisttitle?p=" . $jbArr[$_SESSION['jb_id']]['password'] . "&delim=;;;"));
    }
    writeLogData("messages", "Winamp3: Returning the current playlist");
    return $val;
}