flutter_ijkplayer icon indicating copy to clipboard operation
flutter_ijkplayer copied to clipboard

[Need help]在ijkoption中添加headers,其中替换了host,不能

Open 316011989 opened this issue 5 years ago • 1 comments

大佬你好 我们公司的m3u8播放链接不想暴漏域名,使用了cdn的ip地址进行播放,并在headers中添加host 现在问题是不能正常播放,因为没有正确的host,播放地址会返回403 下方是具体代码

//尝试添加header到option(host添加到header不可用)
playUrl="http://58.215.151.57/dianshiju/105420/sz01/sz01_720.m3u8?stTime=1591083278&token=6002d5387b145dbbaea9bf4bef922e7f";
var platform = [TargetPlatform.android, TargetPlatform.iOS];

// var options = [IjkOption(IjkOptionCategory.format, "host", header["host"])]; var options = [IjkOption(IjkOptionCategory.format, "headers", header)]; mediaController.setIjkPlayerOptions(platform, options); await mediaController.setNetworkDataSource(playUrl, autoPlay: true);

我感觉IjkOption使用了headers和host两种方式,都不能真实的把host添加到headers中,导致此问题,请问有没有解决办法

316011989 avatar Jun 02 '20 07:06 316011989

他里面提供了方法

controller.setNetworkDataSource(url, autoPlay: true, headers: {'host': ' 127.0.0.1'})

但是注意的是,header的value值前面必须添加一个空格才可以 在ijkplayer里面也是相同的解决方案 https://github.com/bilibili/ijkplayer/pull/4946 https://github.com/bilibili/ijkplayer/issues/3693 https://github.com/bilibili/ijkplayer/issues/2648

Wisdozzh avatar Sep 27 '22 01:09 Wisdozzh