0

Below is my code to embed lib.vlc in my winform application. I want to play it for say 5 minutes and then close automatically. How is it possible?

private void PlayerForm_Load(object sender, EventArgs e)
{
    Core.Initialize();
    _libVLC = new LibVLC();
    _videoView.MediaPlayer = new MediaPlayer(_libVLC);
    _videoView.Dock = DockStyle.Fill;
    // Add it to the form
    Controls.Add(_videoView);
    var uri = new Uri(videolink);
    var media = new Media(_libVLC, uri, ":input-repeat=65535");
    _videoView.MediaPlayer.Media = media;
    _videoView.MediaPlayer.Play();

    //Set fullscreen
    this.FormBorderStyle = FormBorderStyle.None;
    this.Size = screen.Bounds.Size;
    this.Location = screen.Bounds.Location;
}

want that player to load for 5 minutes and then close automatically.

ArminAH
  • 113
  • 10
  • You could create a timer that runs for an elapsed time of 5 minutes then it will remove stop the VLC player and remove the control from the `Controls` collection. How to setup timer for X minutes: https://stackoverflow.com/a/13019471/13108684 – ConnorTJ Oct 20 '21 at 12:00
  • Another option; There is a `--run-time` option for the Media object. Then when the media is no longer playing, simply exit. – Rolf of Saxony Oct 26 '21 at 07:50

0 Answers0