private async void GenerateThumbnail(PinballTable table) { Process proc = new Process(); proc.StartInfo.FileName = $@"{Properties.Settings.Default.PATH_FFMPEG}\bin\ffmpeg.exe"; proc.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; if (table.PlayfieldExists) { proc.StartInfo.Arguments = $"-y -i \"{table.Playfield.LocalPath}\" -vframes 1 -f image2 \"{table.PlayfieldImage.LocalPath}\""; proc.Start(); await Task.Run(() => proc.WaitForExit()); } if (table.BackglassExists) { proc.StartInfo.Arguments = $"-y -i \"{table.Backglass.LocalPath}\" -vframes 1 -f image2 \"{table.BackglassImage.LocalPath}\""; proc.Start(); await Task.Run(() => proc.WaitForExit()); } if (table.DMDExists) { proc.StartInfo.Arguments = $"-y -i \"{table.DMD.LocalPath}\" -vframes 1 -f image2 \"{table.DMDImage.LocalPath}\""; proc.Start(); await Task.Run(() => proc.WaitForExit()); } table.RunAudit(); //update visuals }
private async void ImportMedia(PinballTable table, ImportMediaType type, bool convert = false) { if (table != null) { if (table.GetType().Equals(typeof(PinballTable))) { var tempTable = table; //Store a temp version OnMediaImportStarted(tempTable); //Raise Event To Stop Videos var sourceFilePath = ImportGetSourceFilePath(table, GetFileType(type)); var destinationFilePath = ImportGetDestinationFilePath(table, type); //Exit if nothing selected if (!File.Exists(sourceFilePath)) { OnMediaImportFinished(tempTable); return; } //Convert if video if (convert && GetFileType(type) == ImportFileType.Video) { await Task.Run(() => ImportConvertFile(sourceFilePath, destinationFilePath, type)); } else { await Task.Run(() => ImportFile(sourceFilePath, destinationFilePath)); } OnMediaImportFinished(tempTable); //Raise Event To Start New Videos } } }
private string ImportGetSourceFilePath(PinballTable table, ImportFileType type) { switch (type) { case ImportFileType.Video: return(FileUtility.OpenFileDatalogMP4()); case ImportFileType.Audio: return(FileUtility.OpenFileDatalogMP3()); case ImportFileType.Image: return(FileUtility.OpenFileDatalogPNG()); } return(null); }
private string ImportGetDestinationFilePath(PinballTable table, ImportMediaType type) { switch (type) { case ImportMediaType.Playfield: return(table.Playfield.LocalPath); case ImportMediaType.Backglass: return(table.Backglass.LocalPath); case ImportMediaType.Dmd: return(table.DMD.LocalPath); case ImportMediaType.Wheel: return(table.Wheel.LocalPath); case ImportMediaType.LaunchAudio: return(table.LMusic.LocalPath); case ImportMediaType.TableAudio: return(table.LMusic.LocalPath); } return(null); }
protected virtual void OnMediaImportFinished(PinballTable table) { MediaImportFinished?.Invoke(this, table); }