public static async Task<Stream> GetStreamRangeAsync(Uri uri, Range range)
 {
     using (var httpClient = new HttpClient())
     {
         if (range != null)
         {
             if (range.From.HasValue) httpClient.AddRange((long)range.From.Value, (long)range.To.Value);
             else if (range.To.HasValue) httpClient.AddRange((long)range.To.Value);
         }
         return (await httpClient.GetResponse(uri)).Stream;
     }
 }
 public static async Task<Stream> GetStreamRangeAsync(Uri uri, Range range)
 {
     var request = (HttpWebRequest)WebRequestCreator.ClientHttp.Create(uri);
     request.Method = "GET";
     if (range != null)
     {
         if (range.From.HasValue)
         {
             request.AddRange((long)range.From.Value, (long)range.To.Value);
         }
         else if (range.To.HasValue)
         {
             request.AddRange((long)range.To.Value);
         }
     }
     using (var response = await request.GetResponseAsync())
     {
         return GetStream(response);
     }
 }
Exemplo n.º 3
0
        static Range LoadRange(XElement element)
        {
            var result = new Range();

            result.StartTime = element.Attribute("starttime").GetNullableDuration();
            result.Duration = element.Attribute("duration").GetNullableDuration();

            return result;
        }