private void Source_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { var item = FileCacheDictionary.GetPathFromId(DownloadingSource.Id); string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Delight", "External Sources Cache", item.Value.Item1); GlobalViewModel.MainWindowViewModel.MediaItems.Add(new VideoMedia() { Identifier = item.Key, Time = MediaTools.GetMediaDuration(path), Path = path, Thumbnail = new Uri(DownloadingSource.ThumbnailUri), FromYoutube = true, DownloadID = DownloadingSource.Id, Id = DownloadingSource.Id, }); }
public static StageComponent ConvertToComponent(BaseSource source) { if (source is ExternalVideoSource externalVideoSource) { return(new VideoMedia() { FromYoutube = false, Id = source.Id, Path = externalVideoSource.FullPath, Time = MediaTools.GetMediaDuration(externalVideoSource.FullPath), Thumbnail = ((BitmapImage)MediaTools.GetMediaThumbnail(externalVideoSource.FullPath)).UriSource, Identifier = externalVideoSource.Title, }); } else if (source is YoutubeSource youtubeSource) { source.Download(0); var item = FileCacheDictionary.GetPathFromId(source.Id); string path = Path.Combine(DelightAppPath, "External Sources Cache", item.Value.Item1); return(new VideoMedia() { Identifier = item.Key, Time = MediaTools.GetMediaDuration(path), Path = path, Thumbnail = new Uri(source.ThumbnailUri), FromYoutube = true, DownloadID = source.Id, Id = source.Id, }); } else if (source is LightSource lightSource) { return(new LightComponent(BoardSerializer.LoadFromString(lightSource.MovingData))); } return(null); }