用 C# 检查 m3u8 web url

Check m3u8 web url with C#

我正在程序中执行一个小功能,我想检查 m3u8 link 是否正常工作。但是,我无法正确执行此操作,因为某些 link 不工作,但它们返回的状态代码等于 OK。这里有我的代码:

var textBox     = (TextBox)this.FindName("urlToCheck");
var request     = (HttpWebRequest)WebRequest.Create(textBox.Text.Trim());
request.Method  = "HEAD";

try
{
    var response = (HttpWebResponse)request.GetResponse();
    var success  = response.StatusCode == HttpStatusCode.OK;

    if (success) MessageBox.Show("Apparently the link is working");
    else MessageBox.Show("Apparently the link is not working");
}
catch (Exception)
{
    MessageBox.Show("Tthe link is not working");
}

如何检测正在工作的 links 中是否有真实流?我不确定该怎么做,如何检测一个工作的 URL 流和一个不工作的流。现在对我来说唯一的方法是使用 VLC 播放器。

非常感谢您的帮助。

此致

最后我通过检查 link 的状态代码和内容长度修复了它:

var success = response.StatusCode == HttpStatusCode.OK && response.ContentLength > 0;