Esempio n. 1
0
 /**
  * Get media javascript parameters.
  * @param \playable_item $item
  * @param string $force_type
  * @return string
  */
 public static function get_media_js_param($item, $force_type = '')
 {
     $js = array();
     foreach (array('title', 'author') as $member) {
         if ($member == "author") {
             $kmember = "artist";
         } else {
             $kmember = $member;
         }
         $js[$kmember] = $item->{$member};
     }
     $url = $item->url;
     $types = self::get_types($item, $force_type);
     $media = null;
     $urlinfo = Stream_URL::parse($url);
     $url = $urlinfo['base_url'];
     if ($urlinfo['id'] && Core::is_media($urlinfo['type'])) {
         $media = new $urlinfo['type']($urlinfo['id']);
     } else {
         if ($urlinfo['id'] && $urlinfo['type'] == 'song_preview') {
             $media = new Song_Preview($urlinfo['id']);
         } else {
             if (isset($urlinfo['demo_id'])) {
                 $democratic = new Democratic($urlinfo['demo_id']);
                 if ($democratic->id) {
                     $song_id = $democratic->get_next_object();
                     if ($song_id) {
                         $media = new Song($song_id);
                     }
                 }
             }
         }
     }
     if ($media != null) {
         $media->format();
         if ($urlinfo['type'] == 'song') {
             $js['artist_id'] = $media->artist;
             $js['album_id'] = $media->album;
             $js['replaygain_track_gain'] = $media->replaygain_track_gain;
             $js['replaygain_track_peak'] = $media->replaygain_track_peak;
             $js['replaygain_album_gain'] = $media->replaygain_album_gain;
             $js['replaygain_album_peak'] = $media->replaygain_album_peak;
         }
         $js['media_id'] = $media->id;
         if ($media->type != $types['real']) {
             $url .= '&transcode_to=' . $types['real'];
         }
         //$url .= "&content_length=required";
     }
     $js['filetype'] = $types['player'];
     $js['url'] = $url;
     if ($urlinfo['type'] == 'song') {
         $js['poster'] = $item->image_url;
     }
     debug_event("webplayer.class.php", "Return get_media_js_param {" . json_encode($js) . "}", 5);
     return json_encode($js);
 }
Esempio n. 2
0
    }
    $playlist->generate_playlist($playlist_type, false);
    exit;
}
/**
 * If we've got a tmp playlist then get the
 * current song, and do any other crazyness
 * we need to
 */
if ($demo_id) {
    $democratic = new Democratic($demo_id);
    $democratic->set_parent();
    // If there is a cooldown we need to make sure this song isn't a repeat
    if (!$democratic->cooldown) {
        /* This takes into account votes etc and removes the */
        $oid = $democratic->get_next_object();
    } else {
        // Pull history
        $song_cool_check = 0;
        $oid = $democratic->get_next_object($song_cool_check);
        $oids = $democratic->get_cool_songs();
        while (in_array($oid, $oids)) {
            $song_cool_check++;
            $oid = $democratic->get_next_object($song_cool_check);
            if ($song_cool_check >= '5') {
                break;
            }
        }
        // while we've got the 'new' song in old the array
    }
    // end if we've got a cooldown