php - 如何在 PHP 中代理 HLS m3u8
问题描述
我正在尝试代理 HLS 并更改用户代理,一切正常且没有错误,当访问 URL 时,文件将以 .m3u8 扩展名下载,但问题是无法播放,视频播放器不是问题,因为多次测试流正在工作。
这是我的代码
public function proxify($args = NULL) {
$useragent = $this->request->get("ua");
$url = $this->request->get("url");
if($useragent != '' && $url != '') {
$ch = curl_init();
$headers = array(
'User-Agent: ' . $useragent,
);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$request = curl_exec($ch);
header('Content-Type: video/mp2t');
header('Content-Disposition: attachment; filename="' . basename($url) . '"');
echo $request;
} else {
die('No URL Request found');
exit();
}
}
是什么问题,为什么不能播放?,检查网络选项卡的响应代码是 200
谢谢,赞赏
解决方案
推荐阅读
- wpf - 附加的“属性已由”我的通用 BaseAttachedProperty 类导致设计时异常
- javascript - 找到父 td 标签并禁用点击
- javascript - 如何将信息从 WPF 应用程序传递到 HTML 页面
- python - matrix_in_spiral_order(matrix) 的空间和时间复杂度
- php - Mysqli_fetch_array 中的 PHP While 循环中断
- minizinc - MiniZinc:无统计输出
- python-3.x - Python3:使用字符串表示发送电子邮件
- excel - 如何使用 MS Outlook 模板 (.oft) 发送电子邮件,并结合插入电子邮件正文的变量值(通过 Excel 或其他方式)
- android - 如何延迟已经在可运行文件中的 Kotlin (Android Studio) 中的 if-else 执行?
- java - 如何删除 TextChangedListener?