我经历了很大的延迟,通常在视频开始播放前半分钟。我使用maven依赖库groupID: uk.co.caprica ,artifactId vlcj , version3.10.1 , vlc 3.0 .1 Vetinari 安装和mp4视频。日志挂起了一段时间:
15:40:40.222 [pool-4-thread-1] DEBUG u.c.c.v.p.DefaultMediaPlayer - 为新媒体举办活动
和 15:41:03.047 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - play()
代码示例:
JFrame frame = new JFrame("vlcj Tutorial");
JPanel p = new JPanel();
p.setLayout(new BorderLayout());
EmbeddedMediaPlayerComponent videoCanvas = new EmbeddedMediaPlayerComponent();
p.add(videoCanvas, BorderLayout.CENTER);
frame.add(p, BorderLayout.CENTER);
frame.setLocation(100, 100);
frame.setSize(1050, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
player = videoCanvas.getMediaPlayer();
player.prepareMedia("C:\\Users\\Kamil\\Documents\\video\\25.mp4");
player.parseMedia();
player.play();
15:40:40.211 [AWT-EventQueue-0] DEBUG u.c.c.v.p.e.DefaultEmbeddedMediaPlayer - enableOverlay(enable = true)
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - prepareMedia(MRL = C:\用户\卡米尔\文件\视频\ 25.mp4,mediaOptions = [])
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.MediaResourceLocator - encodeMrl(MRL = C:\用户\卡米尔\文件\视频\ 25.mp4)
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.MediaResourceLocator - MRL不包含任何Unicode字符
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.MediaResourceLocator - 结果= C:\用户\卡米尔\文件\视频\ 25.mp4
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - prepareMedia(媒体= SimpleMedia [MRL = C:\用户\卡米尔\文件\视频\ 25.mp4,mediaOptions = [Ljava.lang.String; @ 47722435])
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - setMedia(媒体= SimpleMedia [MRL = C:\用户\卡米尔\文件\视频\ 25.mp4,mediaOptions = [Ljava.lang.String; @ 47722435])
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - deregisterMediaEventListener()
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 事件= libvlc_MediaMetaChanged
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 事件= libvlc_MediaSubItemAdded
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 事件= libvlc_MediaDurationChanged
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 事件= libvlc_MediaParsedChanged
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 事件= libvlc_MediaFreed
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 事件= libvlc_MediaStateChanged
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 事件= libvlc_MediaSubItemTreeAdded
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - createMediaInstance(媒体= SimpleMedia [MRL = C:\用户\卡米尔\文件\视频\ 25.mp4,mediaOptions = [Ljava.lang.String; @ 47722435])
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 将mrl视为一条路径
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - mediaInstance =原生@ 0x245e2850 (uk.co.caprica.vlcj.binding.internal.libvlc_media_t@245e2850)
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - registerMediaEventListener()
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 事件= libvlc_MediaMetaChanged
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 结果为0
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 事件= libvlc_MediaSubItemAdded
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 结果为0
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 事件= libvlc_MediaDurationChanged
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 结果为0
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 事件= libvlc_MediaParsedChanged
15:40:40.221 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 结果为0
15:40:40.222 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 事件= libvlc_MediaFreed
15:40:40.222 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 结果为0
15:40:40.222 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 事件= libvlc_MediaStateChanged
15:40:40.222 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 结果为0
15:40:40.222 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 事件= libvlc_MediaSubItemTreeAdded
15:40:40.222 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 结果为0
15:40:40.222 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - MRL(mediaInstance =天然@ 0x245e2850 (uk.co.caprica.vlcj.binding.internal.libvlc_media_t@245e2850))
15:40:40.222 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 结果=真
15:40:40.222 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - parseMedia()
15:40:40.222 [pool-4-thread-1] DEBUG u.c.c.v.p.DefaultMediaPlayer - mediaChanged(媒体播放器= uk.co.caprica.vlcj.player.embedded.DefaultEmbeddedMediaPlayer @ 250aa6d9,媒体=原生@ 0x245e2850 (uk.co.caprica.vlcj.binding.internal.libvlc_media_t@245e2850),MRL =文件:/// C:/Users/Kamil/Documents/video/25.mp4)
15:40:40.222 [pool-4-thread-1] DEBUG u.c.c.v.p.DefaultMediaPlayer - 为新媒体举办活动
15:41:03.047 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 播放()
15:41:03.047 [AWT-EventQueue-0] DEBUG u.c.c.v.p.e.DefaultEmbeddedMediaPlayer - onBeforePlay()
15:41:03.047 [AWT-EventQueue-0] DEBUG u.c.c.v.p.e.DefaultEmbeddedMediaPlayer - attachVideoSurface()
15:41:03.047 [AWT-EventQueue-0] DEBUG u.c.c.v.p.e.v.CanvasVideoSurface - attach()
15:41:03.047 [AWT-EventQueue-0] DEBUG u.c.c.v.p.e.v.CanvasVideoSurface - componentId = 2693554
15:41:03.047 [AWT-EventQueue-0] DEBUG u.c.c.v.p.e.v.w.WindowsVideoSurfaceAdapter - 附(COMPONENTID = 2693554)
15:41:03.047 [AWT-EventQueue-0] DEBUG u.c.c.v.p.e.v.CanvasVideoSurface - 视频表面附加
15:41:03.048 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - 玩完后
15:41:03.048 [AWT-EventQueue-0] DEBUG u.c.c.v.p.DefaultMediaPlayer - addMediaPlayerEventListener(listener=com.xxx.ContentPanel$1@14db5202)