Example #1
0
    debug_event('play', 'Starting stream of ' . $media->file . ' with size ' . $media->size, 5);
}
if (!isset($_REQUEST['segment'])) {
    if ($media->time) {
        header('X-Content-Duration: ' . $media->time);
    }
    // Stats registering must be done before play. Do not move it.
    // It can be slow because of scrobbler plugins (lastfm, ...)
    if ($start > 0) {
        debug_event('play', 'Content-Range doesn\'t start from 0, stats should already be registered previously; not collecting stats', 5);
    } else {
        if (!$share_id) {
            if ($_SERVER['REQUEST_METHOD'] != 'HEAD') {
                debug_event('play', 'Registering stream stats for {' . $media->get_stream_name() . '}...', 5);
                $sessionkey = $sid ?: Stream::get_session();
                $agent = Session::agent($sessionkey);
                $location = Session::get_geolocation($sessionkey);
                $GLOBALS['user']->update_stats($type, $media->id, $agent, $location, isset($_REQUEST['noscrobble']));
            }
        }
    }
}
if ($transcode || $demo_id) {
    header('Accept-Ranges: none');
} else {
    header('Accept-Ranges: bytes');
}
$mime = $media->mime;
if ($transcode && isset($transcoder)) {
    $mime = $media->type_to_mime($transcoder['format']);
    // Non-blocking stream doesn't work in Windows (php bug since 2005 and still here in 2015...)