public MainWindow() { this.StartServer(); Trace.TraceInformation("[Player startup] Preparing main window to display..."); InitializeComponent(); Menu.Opacity = 0; this.viewModel = new MainWindowViewModel(this) { Playlist = this.Playlist }; this.DataContext = viewModel; this.PreparePlaybackController(); this.Icon = TomiSoft.MP3Player.Properties.Resources.AbstractAlbumArt.ToImageSource(); //Attaching a null-playback instance to display default informations. Trace.TraceInformation("[Player startup] Attaching a NULL-playback manager"); this.AttachPlayer( PlaybackFactory.NullPlayback(100) ); //Load BASS with its all plugins. Trace.TraceInformation("[Player startup] Initializing BASS library..."); if (!BassManager.Load()) { Trace.TraceError("[Player startup] Fatal error occured. Terminating application..."); PlayerUtils.ErrorMessageBox(App.Name, "Nem sikerült betölteni a BASS-t."); Environment.Exit(1); } //Initialize BASS output device. Trace.TraceInformation("[Player startup] Initializing audio output device"); if (!BassManager.InitializeOutputDevice()) { Trace.TraceError("[Player startup] Fatal error occured. Terminating application..."); PlayerUtils.ErrorMessageBox(App.Name, "Nem sikerült beállítani a hangkimenetet."); Environment.Exit(1); } this.Loaded += RegisterHotKeys; this.Playlist.SelectedSongChanged += Playlist_SelectedSongChanged; this.Closed += WindowClosed; PlaybackFactory.MediaOpenProgressChanged += (Percentage, StatusString) => { this.viewModel.Lyrics = StatusString; }; Trace.TraceInformation("[Player startup] Startup successful."); this.ProcessCommandLine(); }
/// <summary> /// Sends the file list to the server then closes the application. /// </summary> private static void SendFileListToServer() { try { using (PlayerClient Client = new PlayerClient(App.Config.ServerPort)) { string[] args = Environment.GetCommandLineArgs(); if (args.Length > 1) { Client.Playback.OpenMedia(args.GetPartOfArray(1, args.Length - 1)); } } } catch (Exception e) { PlayerUtils.ErrorMessageBox(App.Name, e.Message); } }
/// <summary> /// This method is executed when the user wants to play a media from an URI source. /// </summary> /// <param name="sender">The sender object's instance</param> /// <param name="e">Event parameters</param> private async void UriOpen_Click(object sender, MouseButtonEventArgs e) { this.viewModel.MenuVisible = false; #region Check requirements if (!YoutubePlayback.ToolsAvailable) { MessageBoxResult DownloadQuestion = MessageBox.Show( messageBoxText: "Első alkalommal le kell tölteni az ffmpeg.exe, az ffprobe.exe és a youtube-dl.exe programokat. Szeretnéd most letölteni?", caption: "Kellene még néhány dolog...", button: MessageBoxButton.YesNo, icon: MessageBoxImage.Question ); if (DownloadQuestion == MessageBoxResult.Yes) { ProgressBarDialog ProgressBar = new ProgressBarDialog("YouTube eszközök letöltése", "Fél perc és kész vagyunk..."); ProgressBar.Show(); await YoutubePlayback.DownloadSoftwareAsync(); ProgressBar.Close(); } else { return; } } #endregion TextInputDialog Dialog = new TextInputDialog("YouTube média letöltése", "Írd ide a videó címét, amit meg szeretnél nyitni:"); Dialog.Owner = this; bool?Result = Dialog.ShowDialog(); if (Result.HasValue && Result.Value == true) { if (!YoutubeUri.IsValidYoutubeUri(Dialog.UserInput)) { PlayerUtils.ErrorMessageBox(App.Name, "Úgy tűnik, hibás linket adtál meg."); return; } await this.OpenFilesAsync(new string[] { Dialog.UserInput }); } }