我正在尝试使用服务帐户从Google云端硬盘流式传输视频。我一切正常,但是视频控件(暂停/快进/快退/搜索/等)不起作用。
我曾尝试使用几个代理解决方案,但所有这些都在浏览器中给我403错误。有关我尝试过的示例,请参见ProxyKit。
下面的代码确实在浏览器中播放视频,我只需要弄清楚如何使控件正常工作即可。我怀疑我需要检查标题并将正确的标题传递给请求到Google云端硬盘。
[HttpGet("{id}")]
public async Task<IActionResult> GetAsync([FromRoute] string id, [FromQuery] int? quality)
{
HttpResponseMessage result = null;
using (var httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Authorization = await this._TokenManager.GetGoogleDriveAuthHeaderAsync();
result = await httpClient.GetAsync($"https://drive.google.com/get_video_info?docid={id}");
var actualResult = await result.Content.ReadAsStringAsync();
var videoInfo = this._VideoInfoParser.Parse(actualResult);
// Default to 360p for now
var q = videoInfo.maps.Where(m => m.quality == "medium").FirstOrDefault();
return new FileStreamResult(await httpClient.GetStreamAsync(q.url), "video/mp4");
}
}