getMediaStreamResponse method

Future<Response> getMediaStreamResponse({
  1. required String filePath,
  2. BaiduMediaRequestType type = BaiduMediaRequestType.M3U8_AUTO_1080,
})

获取音视频流的响应。

filePath 为网盘文件的路径。 type 为音视频流的类型,查看BaiduMediaRequestType

具体参数说明查看 官方文档

Implementation

Future<http.Response> getMediaStreamResponse({
  required String filePath,
  BaiduMediaRequestType type = BaiduMediaRequestType.M3U8_AUTO_1080,
}) async {
  final path = 'rest/2.0/xpan/file';
  final param = <String, String>{
    'method': 'streaming',
    'path': filePath,
    'access_token': accessToken,
    'type': type.value,
  };

  final header = <String, String>{
    'User-Agent': 'xpanvideo;netdisk;iPhone13;ios-iphone;15.1;ts',
    'host': 'pan.baidu.com',
  };

  return _getResponse(
    path,
    params: param,
    headers: header,
  );
}