diff --git a/PrimaryFormParts/PrimaryForm.cs b/PrimaryFormParts/PrimaryForm.cs index 0c9dcd4..16a51d2 100644 --- a/PrimaryFormParts/PrimaryForm.cs +++ b/PrimaryFormParts/PrimaryForm.cs @@ -524,7 +524,6 @@ namespace DualScreenDemo InitializeSoundEffectButtons(); InitializeSyncScreen(); - InitializeButtonsForSongIDSearch(); InitializeOtherControls(); pictureBox1.BringToFront(); diff --git a/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.NumberSearch.cs b/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.NumberSearch.cs index 48316dd..f847aa0 100644 --- a/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.NumberSearch.cs +++ b/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.NumberSearch.cs @@ -16,8 +16,10 @@ namespace DualScreenDemo private void InitializeButtonsForSongIDSearch() { + InitializeNumberSongIDButtons(pictureBoxSongIDSearch, NumberSongIDButton_Click); + InitializeInputBoxSongIDSearch(); - InitializeNumberSongIDButtons(pictureBoxSongIDSearch,NumberSongIDButton_Click); + InitializeSongIDButton(); } @@ -96,13 +98,13 @@ namespace DualScreenDemo // 創建語音按鈕並設置其屬性 numberSongIDButtonsForSongs[index] = new Button { - Name = $"numberWordCountButton_{numberWordCountSymbols[index]}", // 按鈕名稱設為語音符號名稱 + Name = $"numberSongIDButtonsForSongs_{numberWordCountSymbols[index]}", // 按鈕名稱設為語音符號名稱 }; ConfigureButton(numberSongIDButtonsForSongs[index], x, y, 72, 67, - new Bitmap(Path.Combine(serverPath, data["NumberWordCountButtonImages"][$"button{index}_normal"])), - new Bitmap(Path.Combine(serverPath, data["NumberWordCountButtonImages"][$"button{index}_mouseOver"])), - new Bitmap(Path.Combine(serverPath, data["NumberWordCountButtonImages"][$"button{index}_mouseDown"])), + new Bitmap(Path.Combine(serverPath, data["NumberSongIDButtonImages"][$"button{index}_normal"])), + new Bitmap(Path.Combine(serverPath, data["NumberSongIDButtonImages"][$"button{index}_mouseOver"])), + new Bitmap(Path.Combine(serverPath, data["NumberSongIDButtonImages"][$"button{index}_mouseDown"])), handler); // 設置按鈕的 Tag 屬性為對應的語音符號 @@ -139,11 +141,11 @@ namespace DualScreenDemo Name = "inputBoxSongIDSearch", ForeColor = Color.Black, // 設定文字顏色 Font = new Font("Times New Roman", 26, FontStyle.Regular), // 設定字體樣式 - ScrollBars = RichTextBoxScrollBars.None // 不顯示滾動條 + ScrollBars = RichTextBoxScrollBars.None, // 不顯示滾動條 }; // 調整和定位輸入框的位置及大小 - ResizeAndPositionControl(inputBoxSongIDSearch,10, 55, 400, 60); + ResizeAndPositionControl(inputBoxSongIDSearch, 10, 55, 400, 60); // 將輸入框加入到窗體的控件集合中 pictureBoxSongIDSearch.Controls.Add(inputBoxSongIDSearch); @@ -224,6 +226,7 @@ namespace DualScreenDemo if (inputBoxSongIDSearch.Visible) { inputBoxSongIDSearch.Text += button.Tag.ToString(); + Console.WriteLine(inputBoxSongIDSearch.Text); } } } @@ -245,16 +248,7 @@ namespace DualScreenDemo } private void CloseButtonClick(object sender, EventArgs e) { - pictureBoxSongIDSearch.Visible = false; - modifyButtonSongIDSearch.Visible = false; - clearButtonSongIDSearch.Visible = false; - closeButtonSongIDSearch.Visible = false; - enterButtonSongIDSearch.Visible = false; - inputBoxSongIDSearch.Visible = false; - for (int i = 0; i <= 9; i++) - { - numberSongIDButtonsForSongs[i].Visible = false; - } + CloseUI(pictureBoxSongIDSearch); // 隱藏 SongID 歌手圖片框 numberSearchSongButton.BackgroundImage = numberSearchSongNormalBackground; // 隱藏與 SongID 歌手相關的所有按鈕 diff --git a/Services/MediaService.cs b/Services/MediaService.cs index 3fcba09..52f2d91 100644 --- a/Services/MediaService.cs +++ b/Services/MediaService.cs @@ -10,12 +10,12 @@ namespace DualScreenDemo.Services private MediaPlayer _mediaPlayer; private Media? _media; private bool _disposed; - + public bool _zero; public MediaService() { Core.Initialize(); _libVLC = new LibVLC( - // "--reset-plugins-cache", //產生libvlc plugins設定cache,加快初次啟動速度,生成快取後註解關閉此設定。 + // "--reset-plugins-cache", //產生libvlc plugins設定cache,加快初次啟動速度,生成快取後註解關閉此設定。 "--verbose=-1", // enableDebugLogs: true, "--audio-time-stretch", @@ -80,14 +80,22 @@ namespace DualScreenDemo.Services { try { - _mediaPlayer.Stop(); + _mediaPlayer.Pause(); + _media?.Dispose(); _media = new Media(filePath, FromType.FromPath); - _mediaPlayer.Media = addMediaOption(_media, audioTrackIndex); - _mediaPlayer.Play(); + + _media.ParseAsync(_libVLC); + _media.ParsedChanged += (sender, args) => + { + if (args.ParsedStatus != MediaParsedStatus.Failed) + { + _mediaPlayer.Media = addMediaOption(_media, audioTrackIndex); + _mediaPlayer.Play(); + } + }; _mediaPlayer.Fullscreen = true; _mediaPlayer.Mute = false; - // _mediaPlayer.Stopped += (s, e) => Console.WriteLine("Player Stopped"); } catch (Exception ex) { @@ -107,6 +115,7 @@ namespace DualScreenDemo.Services // media.AddOption(":clock-jitter=0"); // media.AddOption(":clock-synchro=0"); media.AddOption($":audio-track={audioTrackIndex}"); + if(_zero)media.AddOption(":no-audio"); return media; } diff --git a/VideoPlayerForm.cs b/VideoPlayerForm.cs index eea7ce5..433b9cc 100644 --- a/VideoPlayerForm.cs +++ b/VideoPlayerForm.cs @@ -126,6 +126,7 @@ namespace DualScreenDemo this.Controls.Add(PrimaryForm.Instance.videoView1); PrimaryForm.Instance.videoView1.MediaPlayer = _mediaService1.Player; PrimaryForm.Instance.videoView0.MediaPlayer = _mediaService0.Player; + _mediaService0._zero = true; PlayNextSong(); } } @@ -347,11 +348,9 @@ namespace DualScreenDemo { string pathToPlay = song.getFile(); //同步畫面播放器載入media設置參數 - PrimaryForm.Instance.videoView0.Visible = false; _mediaService0.LoadMedia(pathToPlay, 0); - _mediaService0.Player.Media.AddOption(":no-audio"); + // _mediaService0.Player.Media.AddOption(":no-audio"); _mediaService0.Player.AspectRatio = "8:5"; - PrimaryForm.Instance.videoView0.Visible = true; //影片畫面播放器載入media設置聲道 _mediaService1.LoadMedia(pathToPlay, song.isPublicSong ? 0 : 1);