嵌入库.VLC在winform中的应用



这个问题是关于我之前的问题在。net Core的WInform应用程序中嵌入VLC播放器。core . initialize()给出异常

我想运行播放器一段时间,在这段时间视频应该是重复的。当前的代码是这样的…

Core.Initialize();
var libvlc = new LibVLC();
// Make VideoView control
VideoView vv = new VideoView();
vv.MediaPlayer = new MediaPlayer(libvlc);
vv.Dock = DockStyle.Fill;
// Add it to the form
Controls.Add(vv);
var uri = new Uri(@"C:vid.3gp");
// Use command line options as Options for media playback (https://wiki.videolan.org/VLC_command-line_help/)
var media = new Media(libvlc, uri, ":input-repeat=65535");
vv.MediaPlayer.Play(media);
//Set fullscreen
this.FormBorderStyle = FormBorderStyle.None;
this.Size = Screen.PrimaryScreen.Bounds.Size;
this.Location = Screen.PrimaryScreen.Bounds.Location;

如何在一段时间后关闭播放器。目前,即使我关闭了播放器的窗体视频一直在后台播放,直到我关闭整个应用程序。

只是告知这个winform应用程序是在。netcore3.1中创建的。

致意。

创建MediaPlayer作为类字段,并调用它来启动/暂停/停止它。

private LibVLC _libVlc;
private MediaPlayer _mediaPlayer;
...
// Call this method in your constructor/initializer
private void StartMediaPlayer(string videoUrl)
{
using var media = new Media(_libVlc, new Uri(videoUrl), ":input-repeat=65535");
_mediaPlayer = new MediaPlayer(_libVlc)
{
Media = media
};
_mediaPlayer.Play();
}
// Method to stop media player
private void button1_Click(object sender, EventArgs e)
{
_mediaPlayer.Stop();
}

相关内容

  • 没有找到相关文章

最新更新