2508221645
撥放器流程與參數調整 跑馬燈調整屬性參數減少閃爍
This commit is contained in:
parent
3d9e2ac2cd
commit
c263c6e93e
@ -69,13 +69,17 @@ namespace OverlayFormObj
|
|||||||
public OverlayForm()
|
public OverlayForm()
|
||||||
{
|
{
|
||||||
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
||||||
MainForm = this;
|
MainForm = this;
|
||||||
Instance = this;
|
Instance = this;
|
||||||
InitializeFormSettings();
|
InitializeFormSettings();
|
||||||
ConfigureTimers();
|
ConfigureTimers();
|
||||||
InitializeLabels();
|
InitializeLabels();
|
||||||
ConfigureSegmentTimer();
|
ConfigureSegmentTimer();
|
||||||
imageYPos = (screenHeight / 3) - 1024 / 6;
|
imageYPos = (screenHeight / 3) - 1024 / 6;
|
||||||
|
SetStyle(ControlStyles.UserPaint |
|
||||||
|
ControlStyles.AllPaintingInWmPaint |
|
||||||
|
ControlStyles.OptimizedDoubleBuffer, true);
|
||||||
|
UpdateStyles();
|
||||||
}
|
}
|
||||||
private void ConfigureSegmentTimer()
|
private void ConfigureSegmentTimer()
|
||||||
{
|
{
|
||||||
|
@ -14,13 +14,13 @@ namespace DualScreenDemo
|
|||||||
private static PrimaryForm primaryForm; // 儲存實例的參考
|
private static PrimaryForm primaryForm; // 儲存實例的參考
|
||||||
public static Room room = new Room();
|
public static Room room = new Room();
|
||||||
|
|
||||||
public static string verSion = "Server V2.9 202508151059";
|
public static string verSion = "Server V2.9 202508221643";
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
Console.WriteLine(verSion);
|
Console.WriteLine(verSion);
|
||||||
CheckScreens();
|
// CheckScreens();
|
||||||
if (Utils.Env.GetBool("IsCursor", true)) Cursor.Hide();
|
if (Utils.Env.GetBool("IsCursor", true)) Cursor.Hide();
|
||||||
AppDomain.CurrentDomain.ProcessExit += (s, e) => Cursor.Show();
|
AppDomain.CurrentDomain.ProcessExit += (s, e) => Cursor.Show();
|
||||||
//Console.WriteLine("正在與中控取得聯繫...");
|
//Console.WriteLine("正在與中控取得聯繫...");
|
||||||
@ -149,7 +149,7 @@ namespace DualScreenDemo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WriteLog(string message)
|
public static void WriteLog(string message)
|
||||||
{
|
{
|
||||||
// 指定日志文件的路径
|
// 指定日志文件的路径
|
||||||
string logFilePath = Path.Combine(Application.StartupPath, "txt", "mainlog.txt");
|
string logFilePath = Path.Combine(Application.StartupPath, "txt", "mainlog.txt");
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.IO;
|
||||||
using LibVLCSharp.Shared;
|
using LibVLCSharp.Shared;
|
||||||
|
|
||||||
namespace DualScreenDemo.Services
|
namespace DualScreenDemo.Services
|
||||||
@ -13,17 +14,18 @@ namespace DualScreenDemo.Services
|
|||||||
{
|
{
|
||||||
Core.Initialize();
|
Core.Initialize();
|
||||||
_libVLC = new LibVLC(
|
_libVLC = new LibVLC(
|
||||||
// "--verbose=2",
|
"--verbose=-1",
|
||||||
"--audio-time-stretch",
|
"--audio-time-stretch",
|
||||||
// "--vout=automatic",
|
"--vout=automatic",
|
||||||
"--h264-fps=30",
|
"--h264-fps=30",
|
||||||
"--aout=directsound",
|
"--aout=directsound",
|
||||||
"--network-caching=250",
|
"--network-caching=300",
|
||||||
"--file-caching=250",
|
"--file-caching=300",
|
||||||
"--audio-time-stretch"
|
"--audio-time-stretch"
|
||||||
);
|
);
|
||||||
|
|
||||||
_mediaPlayer = new MediaPlayer(_libVLC);
|
_mediaPlayer = new MediaPlayer(_libVLC);
|
||||||
|
_mediaPlayer.EnableHardwareDecoding = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Player Setup
|
#region Player Setup
|
||||||
@ -36,10 +38,10 @@ namespace DualScreenDemo.Services
|
|||||||
_mediaPlayer.Scale = 0;
|
_mediaPlayer.Scale = 0;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
|
Program.WriteLog(ex.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -47,22 +49,6 @@ namespace DualScreenDemo.Services
|
|||||||
public MediaPlayer Player => _mediaPlayer;
|
public MediaPlayer Player => _mediaPlayer;
|
||||||
public bool IsPlaying => _mediaPlayer.IsPlaying;
|
public bool IsPlaying => _mediaPlayer.IsPlaying;
|
||||||
|
|
||||||
// public bool IsAtEnd()
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// _mediaPlayer.EndReached += (sender, args) => { };
|
|
||||||
|
|
||||||
// var duration = _mediaPlayer.Media?.Duration ?? 0;
|
|
||||||
// var time = _mediaPlayer.Time;
|
|
||||||
// return duration > 0 && Math.Abs(duration - time) < 1000;
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// Console.WriteLine(ex.Message);
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public bool IsAtEnd()
|
public bool IsAtEnd()
|
||||||
{
|
{
|
||||||
@ -73,35 +59,35 @@ namespace DualScreenDemo.Services
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadMedia(string filePath, int audioTrackIndex = 0)
|
public void LoadMedia(string filePath,int audioTrackIndex = 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Console.WriteLine($"LoadMedia. in");
|
|
||||||
// _media?.ParseStop();
|
|
||||||
// Console.WriteLine($"LoadMedia. ParseStop");
|
|
||||||
_mediaPlayer.Stop();
|
_mediaPlayer.Stop();
|
||||||
// Console.WriteLine($"LoadMedia. Stop");
|
|
||||||
_media?.Dispose();
|
_media?.Dispose();
|
||||||
// Console.WriteLine($"LoadMedia. Dispose");
|
|
||||||
|
|
||||||
_media = new Media(_libVLC, filePath, FromType.FromPath);
|
_media = new Media(_libVLC, filePath, FromType.FromPath);
|
||||||
_media.AddOption(":avcodec-hw=dxva2");
|
addMediaOption(_media, audioTrackIndex);
|
||||||
_media.AddOption(":vout=gl");
|
|
||||||
_media.AddOption(":audio-output=directsound");
|
|
||||||
_media.AddOption($":audio-track={audioTrackIndex}");
|
|
||||||
// _media.AddOption(":start-time=0.5");
|
|
||||||
_mediaPlayer.Media = _media;
|
_mediaPlayer.Media = _media;
|
||||||
_mediaPlayer.Play(_media);
|
// _mediaPlayer.Play(_media);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
|
Program.WriteLog(ex.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void 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");
|
||||||
|
}
|
||||||
|
|
||||||
public void Play() => _mediaPlayer.Play();
|
public void Play() => _mediaPlayer.Play();
|
||||||
public void Pause() => _mediaPlayer.Pause();
|
public void Pause() => _mediaPlayer.Pause();
|
||||||
public void Stop() => _mediaPlayer.Stop();
|
public void Stop() => _mediaPlayer.Stop();
|
||||||
@ -143,7 +129,14 @@ namespace DualScreenDemo.Services
|
|||||||
#region Volume
|
#region Volume
|
||||||
public void SetVolume(int volume) => _mediaPlayer.Volume = volume;
|
public void SetVolume(int volume) => _mediaPlayer.Volume = volume;
|
||||||
public int GetVolume() => _mediaPlayer.Volume;
|
public int GetVolume() => _mediaPlayer.Volume;
|
||||||
public bool Mute(bool isMuted) => _mediaPlayer.Mute = isMuted;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Dispose
|
#region Dispose
|
||||||
|
@ -74,7 +74,6 @@ namespace DualScreenDemo
|
|||||||
public int previousVolume = 100;
|
public int previousVolume = 100;
|
||||||
public bool isPaused = false;
|
public bool isPaused = false;
|
||||||
private bool isSyncToPrimaryMonitor = false;
|
private bool isSyncToPrimaryMonitor = false;
|
||||||
|
|
||||||
public bool IsSyncToPrimaryMonitor
|
public bool IsSyncToPrimaryMonitor
|
||||||
{
|
{
|
||||||
get { return isSyncToPrimaryMonitor; }
|
get { return isSyncToPrimaryMonitor; }
|
||||||
@ -106,7 +105,7 @@ namespace DualScreenDemo
|
|||||||
this.StartPosition = FormStartPosition.Manual;
|
this.StartPosition = FormStartPosition.Manual;
|
||||||
this.Location = secondMonitor.Bounds.Location;
|
this.Location = secondMonitor.Bounds.Location;
|
||||||
this.Size = secondMonitor.Bounds.Size;
|
this.Size = secondMonitor.Bounds.Size;
|
||||||
// this.DoubleBuffered = true;
|
this.DoubleBuffered = true;
|
||||||
}
|
}
|
||||||
Screen screen = Screen.FromHandle(this.Handle);
|
Screen screen = Screen.FromHandle(this.Handle);
|
||||||
}
|
}
|
||||||
@ -342,20 +341,12 @@ namespace DualScreenDemo
|
|||||||
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);
|
||||||
if (song.isPublicSong)
|
Play();
|
||||||
{
|
Thread.Sleep(100);
|
||||||
isVocalRemoved = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
isVocalRemoved = false;
|
|
||||||
}
|
|
||||||
_ToggleVocalRemoval(isVocalRemoved);
|
|
||||||
|
|
||||||
|
|
||||||
// 音量處理
|
// 音量處理
|
||||||
//SetVolume(isMuted ? 0 : previousVolume);
|
Mute(isMuted);
|
||||||
if (isMuted) { Mute(true); }
|
|
||||||
SetVolume(100 + song.getBasic().getDbChange());
|
SetVolume(100 + song.getBasic().getDbChange());
|
||||||
if (isSyncToPrimaryMonitor) SyncToPrimaryMonitor();
|
if (isSyncToPrimaryMonitor) SyncToPrimaryMonitor();
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
@ -387,7 +378,7 @@ namespace DualScreenDemo
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_mediaService1.IsAtEnd())
|
if (_mediaService1.IsAtEnd()&&_mediaService0.IsAtEnd())
|
||||||
{
|
{
|
||||||
BeginInvoke(new Action(async () =>
|
BeginInvoke(new Action(async () =>
|
||||||
{
|
{
|
||||||
@ -484,7 +475,7 @@ namespace DualScreenDemo
|
|||||||
{
|
{
|
||||||
_ToggleVocalRemoval(isVocalRemoved);
|
_ToggleVocalRemoval(isVocalRemoved);
|
||||||
}
|
}
|
||||||
|
// _mediaService1.Mute(isMuted);
|
||||||
return isMuted;
|
return isMuted;
|
||||||
}
|
}
|
||||||
public void SetVolume(int volume)
|
public void SetVolume(int volume)
|
||||||
@ -495,7 +486,6 @@ namespace DualScreenDemo
|
|||||||
}
|
}
|
||||||
public int GetVolume()
|
public int GetVolume()
|
||||||
{
|
{
|
||||||
|
|
||||||
return _mediaService1.GetVolume();
|
return _mediaService1.GetVolume();
|
||||||
}
|
}
|
||||||
private bool isVocalRemoved = true;
|
private bool isVocalRemoved = true;
|
||||||
@ -506,8 +496,26 @@ namespace DualScreenDemo
|
|||||||
}
|
}
|
||||||
private bool _ToggleVocalRemoval(bool isVocal)
|
private bool _ToggleVocalRemoval(bool isVocal)
|
||||||
{
|
{
|
||||||
_mediaService0.Mute(isVocal);
|
|
||||||
_mediaService1.Mute(!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);
|
||||||
return isVocal;
|
return isVocal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user