【发布时间】:2018-07-30 21:26:01
【问题描述】:
我有一个单用户应用程序,
在 Vimeo 的操场上,做视频/{id} 时,我得到一个大的 JSON 结果,其中包含:
"files": [
{
"quality": "hd",
"type": "video/mp4",
"width": 1920,
"height": 1080,
"link": "...link...",
"created_time": "2018-02-15T13:46:25+00:00",
"fps": 23.980000000000000426325641456060111522674560546875,
"size": 3113207678,
"md5": "b6beed65b699df870e481045178accc5",
"link_secure": "...link..."
},
{
"quality": "sd",
"type": "video/mp4",
"width": 640,
"height": 360,
"link": "...link...",
"created_time": "2018-02-15T13:46:05+00:00",
"fps": 23.980000000000000426325641456060111522674560546875,
"size": 536864946,
"md5": "af227a5526af15d2bce6ac951d6cf06b",
"link_secure": "...link..."
},
{
"quality": "sd",
"type": "video/mp4",
"width": 960,
"height": 540,
"link": "...link...",
"created_time": "2018-02-15T13:46:05+00:00",
"fps": 23.980000000000000426325641456060111522674560546875,
"size": 1242328160,
"md5": "1963f908509b14fd7a40dc46bfa6c519",
"link_secure": "...link..."
},
{
"quality": "hd",
"type": "video/mp4",
"width": 1280,
"height": 720,
"link": "...link...",
"created_time": "2018-02-15T13:46:05+00:00",
"fps": 23.980000000000000426325641456060111522674560546875,
"size": 1977386604,
"md5": "af38f067bd39f4f5bb71bad72f925337",
"link_secure": "...link..."
},
{
"quality": "hls",
"type": "video/mp4",
"link": "...link...",
"created_time": "2018-02-15T13:46:25+00:00",
"fps": 23.980000000000000426325641456060111522674560546875,
"size": 3113207678,
"md5": "b6beed65b699df870e481045178accc5",
"link_secure": "...link..."
}
(我编辑了网址)
但是在我的代码中执行相同的调用时,整个“文件”部分都丢失了(整个 json 结果看起来也不同):
这是我的代码,调用:
vc.Request("/videos/255898412", null, "GET");
请求方法:
public Dictionary<string, object> Request(
string url,
Dictionary<string, string> parameters,
string method,
bool jsonBody = true)
{
var headers = new WebHeaderCollection()
{
{ "Authorization", String.Format("Bearer {0}", AccessToken) }
};
method = method.ToUpper();
url = apiRoot + url;
string body = "";
string contentType = "application/x-www-form-urlencoded";
if (parameters != null && parameters.Count > 0)
{
if (method == "GET")
{
url += "?" + Helpers.KeyValueToString(parameters);
}
else if (method == "POST" || method == "PATCH" || method == "PUT" || method == "DELETE")
{
if (jsonBody)
{
contentType = "application/json";
body = jsonEncode(parameters);
}
else
{
body = Helpers.KeyValueToString(parameters);
}
}
}
return JsonConvert.DeserializeObject<Dictionary<string, object>>(Helpers.HTTPFetch(url, method, headers, body, contentType));
}
我的目标是获得 HLS 直接链接,并在我的播放器中播放它。 我怎样才能实现它?
谢谢
【问题讨论】: