VLCJ SetRepeat在Eclipse JAVA中不起作用

时间:2018-12-03 19:29:05

标签: java vlcj

我希望使用Java中的VLCJ循环播放mp4视频。以下是我的代码,但无法正常工作视频播放一次并停止播放,不再重复。 我有安装了64位JRE和64位VLC的Windows 10 64位OS。 请让我知道我在做错什么。

package com.srccodes.demo;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import org.w3c.dom.stylesheets.MediaList;

import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;
import uk.co.caprica.vlcj.binding.LibVlc;
import uk.co.caprica.vlcj.player.MediaPlayerFactory;
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
import uk.co.caprica.vlcj.player.embedded.windows.Win32FullScreenStrategy;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;
import uk.co.caprica.vlcj.runtime.x.LibXUtil;

public class VideoForm {

    public static void main(String[] args) {
           System.out.println(System.getProperty("sun.arch.data.model"));
           JFrame frame = new JFrame("Tutoriel vlcj");
           frame.setLocation(100, 100);
           frame.setSize(1050, 600);
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           frame.setVisible(true);
           Canvas c = new Canvas();
           c.setBackground(Color.black);
           JPanel p = new JPanel();
           p.setLayout(new BorderLayout());
           p.add(c, BorderLayout.CENTER);
           frame.add(p, BorderLayout.CENTER);
           NativeLibrary.addSearchPath(
                   RuntimeUtil.getLibVlcLibraryName(), "C:\\Program Files\\VideoLAN\\VLC");
           Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
           //LibXUtil.initialise();
           MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory();
           EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.newEmbeddedMediaPlayer(new               Win32FullScreenStrategy(frame));
           mediaPlayer.setVideoSurface(mediaPlayerFactory.newVideoSurface(c));
           //mediaPlayer.toggleFullScreen();
           //mediaPlayer.setEnableMouseInputHandling(false);
           //mediaPlayer.setEnableKeyInputHandling(true);

           mediaPlayer.prepareMedia("E:\\Plastic.mp4");
            mediaPlayer.setRepeat(true);
            mediaPlayer.setPlaySubItems(true);
            mediaPlayer.playMedia("E:\\Plastic.mp4", options);
           mediaPlayer.play();
       }

}

0 个答案:

没有答案