Replace new EventArgs() with EventArgs.Empty

The commits replace all instances of `new EventArgs()` with `EventArgs.Empty` in different video player classes. This change improves performance by reducing unnecessary object instantiation and aligns with the best practices of C# coding.

Signed-off-by: Ivandro Jao <ivandrofly@gmail.com>
This commit is contained in:
Ivandro Jao 2024-06-27 18:50:30 +01:00
parent 0b4aa9b65e
commit 153e2dfd20
4 changed files with 8 additions and 8 deletions

View File

@ -676,7 +676,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
{ {
// ignore // ignore
} }
OnVideoLoaded?.Invoke(_mediaPlayer, new EventArgs()); OnVideoLoaded?.Invoke(_mediaPlayer, EventArgs.Empty);
} }
public static string GetVlcPath(string fileName) public static string GetVlcPath(string fileName)
@ -1065,7 +1065,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
Stop(); Stop();
Play(); Play();
Pause(); Pause();
OnVideoEnded?.Invoke(_mediaPlayer, new EventArgs()); OnVideoEnded?.Invoke(_mediaPlayer, EventArgs.Empty);
} }
} }

View File

@ -144,7 +144,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
NativeMethods.libvlc_media_player_pause(_mediaPlayer); NativeMethods.libvlc_media_player_pause(_mediaPlayer);
_videoLoadedTimer.Stop(); _videoLoadedTimer.Stop();
OnVideoLoaded?.Invoke(_mediaPlayer, new EventArgs()); OnVideoLoaded?.Invoke(_mediaPlayer, EventArgs.Empty);
} }
public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded)
@ -195,7 +195,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
Stop(); Stop();
Play(); Play();
Pause(); Pause();
OnVideoEnded.Invoke(_mediaPlayer, new EventArgs()); OnVideoEnded.Invoke(_mediaPlayer, EventArgs.Empty);
} }
} }

View File

@ -186,7 +186,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers.MpcHC
} }
Resize(_initialWidth, _initialHeight); Resize(_initialWidth, _initialHeight);
OnVideoLoaded?.Invoke(this, new EventArgs()); OnVideoLoaded?.Invoke(this, EventArgs.Empty);
SendMpcMessage(MpcHcCommand.SetSubtitleTrack, "-1"); SendMpcMessage(MpcHcCommand.SetSubtitleTrack, "-1");
@ -209,7 +209,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers.MpcHC
} }
break; break;
case MpcHcCommand.NotifyEndOfStream: case MpcHcCommand.NotifyEndOfStream:
OnVideoEnded?.Invoke(this, new EventArgs()); OnVideoEnded?.Invoke(this, EventArgs.Empty);
break; break;
case MpcHcCommand.CurrentPosition: case MpcHcCommand.CurrentPosition:

View File

@ -249,7 +249,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
{ {
try try
{ {
OnVideoLoaded.Invoke(_quartzFilgraphManager, new EventArgs()); OnVideoLoaded.Invoke(_quartzFilgraphManager, EventArgs.Empty);
} }
catch catch
{ {
@ -266,7 +266,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
_isPaused = true; _isPaused = true;
if (OnVideoEnded != null && _quartzFilgraphManager != null) if (OnVideoEnded != null && _quartzFilgraphManager != null)
{ {
OnVideoEnded.Invoke(_quartzFilgraphManager, new EventArgs()); OnVideoEnded.Invoke(_quartzFilgraphManager, EventArgs.Empty);
} }
} }
} }