コード例 #1
0
        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);
        }