Display first frame without continue playing the file
Problem to solve
I need to open a video file and display its first frame but without any further playing. Currently if you open a media, it automatically plays the file. And you cannot seek without having called Play() method at least once. Forgive me if this can already be done in some way but I had no success with trying the following ways:
//Video just plays, no pause at all.
using var media = new Media(_libVlc, file);
MediaPlayer.Play(media);
MediaPlayer.Pause();
//SeekTo has no effect at all, even if with any other value than zero.
using var media = new Media(_libVlc, file);
MediaPlayer.Media = media;
MediaPlayer.SeekTo(TimeSpan.Zero);
//Same result as number 2, no effect. Video is paused but first frame is not displayed.
using var media = new Media(_libVlc, file);
MediaPlayer.Play(media);
private void MediaPlayer_Playing(object sender, EventArgs e)
{
MediaPlayer.Pause();
}
//This one only cause bugs. VLCSharp will hang up the application after a while.
using var media = new Media(_libVlc, file);
MediaPlayer.Play(media);
private void MediaPlayer_Playing(object sender, EventArgs e)
{
MediaPlayer.Pause();
MediaPlayer.SeekTo(TimeSpan.Zero);
}
//This one works but its not the first frame where it paused
using var media = new Media(_libVlc, file);
MediaPlayer.Play(media);
private void MediaPlayer_TimeChanged(object sender, MediaPlayerTimeChangedEventArgs e)
{
MediaPlayer.Pause();
}
FYI: In case it matters I am using the WPF control.
Intended users
Developers
Proposal
Maybe just another overload?
MediaPlayer.Play(media, pauseOnFirstFrame: true);
Or a new method?
MediaPlayer.OpenPaused(media);
Or, doubtful, but maybe this is a bug and SeekTo should work without calling Play() first?
Documentation
None