簡體   English   中英

如何檢測是否存在icecast / shoutcast流?

[英]How to detect if a icecast / shoutcast stream exists or not?

網站上有5個流。 我需要檢測這些流是否存在。 如果沒有,則可以播放一些音頻文件。

我正在使用html5來播放流,流網址看起來像這樣:

http://locus.creacast.com:9001/StBaume_grotte.ogg

我嘗試了不同的東西,但它似乎沒有用。 從未檢測到流。

解決方案1:在這里,我只是試圖檢查文件是否存在。

if (file_exists($stream_1)) {
             $debug_output_stream_1 = "Le fichier $stream_1 existe.";
             $erreur_404_Stream_1 = true;  
        } else {
             $debug_output_stream_1 =  "Le fichier $stream_1 n'existe pas.";
             $erreur_404_Stream_1 = false;  
        }

解決方案2:我嘗試檢測404錯誤

 $file_headers_1 = @get_headers($stream_1);
        if($file_headers_1[0] == 'HTTP/1.1 404 Not Found') {
            $debug_output_stream_1 = "StBaume_sommet.ogg : L'URL n'existe pas.";
            $erreur_404_Stream_1 = true;  
        }
        else {
            $debug_output_stream_1 = "StBaume_sommet.ogg : L'URL existe.";
            $erreur_404_Stream_1 = false;
        }

你知道如何檢查流是否存在?

您正在檢查整個狀態行,包括HTTP版本HTTP/1.1 大多數服務器返回HTTP/1.0 您只需要檢查狀態代碼。

if (strpos($file_headers_1[0], '200 OK') === false) {
    // error occurred
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM