Exemple #1
0
 /// <summary>
 /// Download the thumbnail for the specified video (only if it isn't already in our cache)
 /// </summary>
 public void DownloadThumbnail(IVideo video)
 {
     if (!_thumbnails.Contains(video))
     {
         // if we can get a version of the thumbnail from the cache
         // then just save this version
         PluginHttpRequest pluginHttpRequest = new PluginHttpRequest(video.ThumbnailUrl, HttpRequestCacheLevel.CacheOnly);
         using (Stream cachedStream = pluginHttpRequest.GetResponse())
         {
             if (cachedStream != null)
             {
                 MemoryStream memoryStream = new MemoryStream();
                 StreamHelper.Transfer(cachedStream, memoryStream);
                 _thumbnails[video] = new VideoThumbnail(memoryStream);
             }
             // otherwise mark it as 'downloading' and enque the download
             else
             {
                 _thumbnails[video] = new DownloadingVideoThumbnail();
                 _workQueue.Enqueue(video);
             }
         }
     }
 }
 /// <summary>
 /// Download the thumbnail for the specified video (only if it isn't already in our cache)
 /// </summary>
 public void DownloadThumbnail(IVideo video)
 {
     if (!_thumbnails.Contains(video))
     {
         // if we can get a version of the thumbnail from the cache
         // then just save this version
         PluginHttpRequest pluginHttpRequest = new PluginHttpRequest(video.ThumbnailUrl, HttpRequestCacheLevel.CacheOnly);
         using (Stream cachedStream = pluginHttpRequest.GetResponse())
         {
             if (cachedStream != null)
             {
                 MemoryStream memoryStream = new MemoryStream();
                 StreamHelper.Transfer(cachedStream, memoryStream);
                 _thumbnails[video] = new VideoThumbnail(memoryStream);
             }
             // otherwise mark it as 'downloading' and enque the download
             else
             {
                 _thumbnails[video] = new DownloadingVideoThumbnail();
                 _workQueue.Enqueue(video);
             }
         }
     }
 }