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