2508250927
This commit is contained in:
parent
c263c6e93e
commit
7b02f47441
@ -58,7 +58,7 @@ namespace DualScreenDemo
|
||||
private Button replayButton;
|
||||
public Button pauseButton;
|
||||
public Button playButton;
|
||||
private Button muteButton;
|
||||
public Button muteButton;
|
||||
private Button maleKeyButton;
|
||||
private Button femaleKeyButton;
|
||||
private Button standardKeyButton;
|
||||
|
@ -66,26 +66,22 @@ namespace DualScreenDemo.Services
|
||||
_mediaPlayer.Stop();
|
||||
_media?.Dispose();
|
||||
_media = new Media(_libVLC, filePath, FromType.FromPath);
|
||||
addMediaOption(_media, audioTrackIndex);
|
||||
_mediaPlayer.Media = _media;
|
||||
// _mediaPlayer.Play(_media);
|
||||
_mediaPlayer.Media = addMediaOption(_media, audioTrackIndex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Program.WriteLog(ex.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addMediaOption(Media media, int audioTrackIndex)
|
||||
private Media addMediaOption(Media media, int audioTrackIndex)
|
||||
{
|
||||
media.AddOption(":avcodec-hw=dxva2");
|
||||
media.AddOption($":drop-late-frames");
|
||||
media.AddOption(":audio-output=directsound");
|
||||
media.AddOption($":audio-track={audioTrackIndex}");
|
||||
// media.AddOption(":start-time=1");
|
||||
// media.AddOption(":rate=30");
|
||||
return media;
|
||||
}
|
||||
|
||||
public void Play() => _mediaPlayer.Play();
|
||||
@ -131,9 +127,7 @@ namespace DualScreenDemo.Services
|
||||
public int GetVolume() => _mediaPlayer.Volume;
|
||||
public bool Mute(bool isMuted)
|
||||
{
|
||||
Console.WriteLine($"_mediaPlayer.Mute:in {_mediaPlayer.Mute}");
|
||||
_mediaPlayer.Mute = isMuted;
|
||||
Console.WriteLine($"_mediaPlayer.Mute:out {_mediaPlayer.Mute}");
|
||||
return _mediaPlayer.Mute;
|
||||
}
|
||||
|
||||
|
@ -330,6 +330,7 @@ namespace DualScreenDemo
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Program.WriteLog(ex.ToString());
|
||||
tcs.SetException(ex);
|
||||
}
|
||||
});
|
||||
@ -337,20 +338,37 @@ namespace DualScreenDemo
|
||||
}
|
||||
|
||||
private Task InitializeAndPlayMedia(SongData song)
|
||||
{
|
||||
try
|
||||
{
|
||||
string pathToPlay = song.getFile();
|
||||
_mediaService0.LoadMedia(pathToPlay, 0);
|
||||
_mediaService1.LoadMedia(pathToPlay, song.isPublicSong ? 0 : 1);
|
||||
Play();
|
||||
Thread.Sleep(100);
|
||||
|
||||
|
||||
// Thread.Sleep(100);
|
||||
PrimaryForm.Instance.muteButton.PerformClick();
|
||||
PrimaryForm.Instance.muteButton.PerformClick();
|
||||
// 音量處理
|
||||
Mute(isMuted);
|
||||
SetVolume(100 + song.getBasic().getDbChange());
|
||||
if (isSyncToPrimaryMonitor) SyncToPrimaryMonitor();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Program.WriteLog(ex.ToString());
|
||||
Stop();
|
||||
_mediaService0.Dispose();
|
||||
_mediaService1.Dispose();
|
||||
_mediaService0 = new MediaService();
|
||||
_mediaService1 = new MediaService();
|
||||
this.Invoke(VideoPlayerForm_Shown);
|
||||
InitializeAndPlayMedia(song);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void InitializeOverlayForm(Screen secondaryScreen)
|
||||
{
|
||||
@ -475,7 +493,6 @@ namespace DualScreenDemo
|
||||
{
|
||||
_ToggleVocalRemoval(isVocalRemoved);
|
||||
}
|
||||
// _mediaService1.Mute(isMuted);
|
||||
return isMuted;
|
||||
}
|
||||
public void SetVolume(int volume)
|
||||
@ -497,25 +514,8 @@ namespace DualScreenDemo
|
||||
private bool _ToggleVocalRemoval(bool isVocal)
|
||||
{
|
||||
|
||||
if (isVocal)
|
||||
{
|
||||
Console.WriteLine("_ToggleVocalRemoval 0:" + isVocal);
|
||||
Console.WriteLine("_ToggleVocalRemoval 00:" + _mediaService0.Player.Mute);
|
||||
Console.WriteLine("_ToggleVocalRemoval 01:" + _mediaService1.Player.Mute);
|
||||
_mediaService0.Mute(true);
|
||||
_mediaService1.Mute(false);
|
||||
Console.WriteLine("_ToggleVocalRemoval: 00:" + _mediaService0.Player.Mute);
|
||||
Console.WriteLine("_ToggleVocalRemoval: 01" + _mediaService1.Player.Mute);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("_ToggleVocalRemoval 1:" + isVocal);
|
||||
_mediaService0.Mute(false);
|
||||
_mediaService1.Mute(true);
|
||||
}
|
||||
|
||||
Console.WriteLine("00:"+_mediaService0.Player.Mute);
|
||||
Console.WriteLine("01:" + _mediaService1.Player.Mute);
|
||||
_mediaService0.Mute(isVocal);
|
||||
_mediaService1.Mute(!isVocal);
|
||||
return isVocal;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user