示例#1
0
        public void UpdateFiles()
        {
            MediaList.Clear();

            foreach (var filePath in Directory.GetFiles(SourcePath).Where(item => !item.Contains(".ini")))
            {
                var fileName  = filePath.Split('\\').LastOrDefault();
                var extension = filePath.Split('.').LastOrDefault();

                if (SupportedVideoExtensions.Contains(extension))
                {
                    var tempFolder        = Path.GetTempPath();
                    var tempThumbnailPath = string.Format("{0}{1}.jpg", tempFolder, fileName);

                    var ffMpeg = new NReco.VideoConverter.FFMpegConverter();

                    CreateThumbnailForVideo(filePath, tempThumbnailPath, ffMpeg);

                    ffMpeg.Stop();

                    if (extension.Contains("webm"))
                    {
                        var newFilePath = string.Format("{0}{1}.mp4", tempFolder, fileName);

                        if (!File.Exists(newFilePath))
                        {
                            var tempffMpeg = new NReco.VideoConverter.FFMpegConverter();

                            tempffMpeg.ConvertMedia(filePath, newFilePath, "mp4");

                            tempffMpeg.Stop();
                        }

                        AddMediaToList(extension, tempThumbnailPath, newFilePath);
                    }
                    else
                    {
                        AddMediaToList(extension, tempThumbnailPath, filePath);
                    }
                }
                else
                {
                    AddMediaToList(extension, filePath, filePath);
                }
            }
        }