简体   繁体   English

Vlc.DotNet 如何在 Wpf 中打开视频并显示第一帧?

[英]Vlc.DotNet how open video and show first frame in Wpf?

I use Vlc.DotNet.Wpf , and I need the player to load the video and display only the first frame, so that the control gets a proper size and the user can see what the video is talking about, how can this be done?我使用Vlc.DotNet.Wpf ,我需要播放器加载视频并仅显示第一帧,以便控件获得适当的大小并且用户可以看到视频在说什么,这怎么做?

if I call _vlcPlayer.SourceProvider.MediaPlayer.SetMedia(stream) nothing happend, and if I call _vlcPlayer.SourceProvider.MediaPlayer.Play(stream) the video running more than one frame.如果我调用_vlcPlayer.SourceProvider.MediaPlayer.SetMedia(stream)什么也没发生,如果我调用_vlcPlayer.SourceProvider.MediaPlayer.Play(stream)视频运行超过一帧。

I tried _vlcPlayer.SourceProvider.MediaPlayer.Time = 1 nothing happend.我试过_vlcPlayer.SourceProvider.MediaPlayer.Time = 1什么也没发生。

How can this be done?如何才能做到这一点?

You could parse the media and find its width and height from the first video track.您可以解析媒体并从第一个视频轨道中找到它的宽度和高度。

You could use the snapshot API to get a jpeg snapshot of the video that you could display.您可以使用快照 API 来获取您可以显示的视频的 jpeg 快照。 (That API will change in libvlc4) (即 API 会在 libvlc4 中改变)

You could also use play, and pause the video immediately after you get the Playing event (don't forget to switch threads).您也可以使用播放,并在收到 Playing 事件后立即暂停视频(不要忘记切换线程)。

Alternatively to cube45's answer, I believe there is a libvlc option just for that除了 cube45 的回答之外,我相信有一个 libvlc 选项可以解决这个问题

--start-paused, --no-start-paused 
                                 Start paused
                                 (default disabled)
          Pause each item in the playlist on the first frame.

https://wiki.videolan.org/VLC_command-line_help https://wiki.videolan.org/VLC_command-line_help

I got it to work with this code:我让它与这段代码一起工作:

vlcVideoPlayer.VlcMediaplayerOptions = new string[]{"--start-paused"};
vlcVideoPlayer.Play(new Uri("Video Link/Directory"));
vlcVideoPlayer.Time = 1;

Hope it works for you.希望对你有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM