突然没有加载Vimeo上托管的视频。 序列化部分后失败。无法理解,因为这突然开始发生。
try
{
Match vimeoMatch = VimeoVideoRegex.Match(VideoId);
if (vimeoMatch.Success)
VideoId = vimeoMatch.Groups[1].Value;
var videoInfoUrl = $"https://player.vimeo.com/video/{VideoId}/config";
using (var client = new HttpClient())
{
var videoPageContent = client.GetStringAsync(videoInfoUrl).Result;
var videoPageBytes = Encoding.UTF8.GetBytes(videoPageContent);
using (var stream = new MemoryStream(videoPageBytes))
{
var serializer = new DataContractJsonSerializer(typeof(VimeoVideo));
var metaData = (VimeoVideo)serializer.ReadObject(stream);
var files = metaData.request.files.progressive;
// Exact match
var url = files.OrderByDescending(s => s.width).Select(s => s.url).FirstOrDefault();
Debug.WriteLine($"Stream URL: {url}");
return VideoSource.FromUri(url);
}
}
}