Minor vlc fix

This commit is contained in:
niksedk 2021-08-15 09:41:14 +02:00
parent 16461bf9f4
commit 10290015c6

View File

@ -284,7 +284,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
try
{
if (Configuration.IsRunningOnWindows && string.IsNullOrEmpty(GetVlcPath("libvlc.dll")))
{
{
return false;
}
@ -393,7 +393,18 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
_libvlc_media_player_next_frame(_mediaPlayer);
}
public int VlcState => _libvlc_media_player_get_state(_mediaPlayer);
public int VlcState
{
get
{
if (_mediaPlayer == IntPtr.Zero)
{
return 0;
}
return _libvlc_media_player_get_state(_mediaPlayer);
}
}
public override void Play()
{
@ -409,7 +420,12 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
}
_libvlc_media_player_set_pause(_mediaPlayer, 1);
WaitUntilReady();
if (_mediaPlayer == IntPtr.Zero)
{
return;
}
_libvlc_media_player_set_pause(_mediaPlayer, 1);
}
@ -421,6 +437,11 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
{
System.Threading.Thread.Sleep(10);
Application.DoEvents();
if (_mediaPlayer == IntPtr.Zero)
{
return;
}
state = VlcState;
i++;
}
@ -436,6 +457,11 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
{
get
{
if (_mediaPlayer == IntPtr.Zero)
{
return true;
}
const int paused = 4;
int state = _libvlc_media_player_get_state(_mediaPlayer);
return state == paused;
@ -446,6 +472,11 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
{
get
{
if (_mediaPlayer == IntPtr.Zero)
{
return false;
}
const int playing = 3;
int state = _libvlc_media_player_get_state(_mediaPlayer);
return state == playing;