Created
February 15, 2015 07:03
-
-
Save oboenikui/30d5aa2b69d0b2a85ce8 to your computer and use it in GitHub Desktop.
VLCJ test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.oboenikui.videotest; | |
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.videosurface.CanvasVideoSurface; | |
import uk.co.caprica.vlcj.runtime.RuntimeUtil; | |
import javax.swing.*; | |
import java.awt.*; | |
/** | |
* Created by oboenikui on 2015/02/15. | |
*/ | |
public class MainWindow extends JFrame{ | |
private Canvas mCanvas; | |
public static void main(String[] args) { | |
//TODO You must change the path string | |
String vlcHome = "VLC Installed Path"; | |
NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), vlcHome); | |
MainWindow mainWindow = new MainWindow(); | |
mainWindow.setVisible(true); | |
mainWindow.play(); | |
} | |
public MainWindow(){ | |
super(); | |
setTitle("Test frame"); | |
setBounds(100, 100, 1000, 800); | |
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
setLayout(new BorderLayout()); | |
mCanvas = new Canvas(); | |
mCanvas.setBackground(Color.BLACK); | |
mCanvas.setVisible(true); | |
add(mCanvas, BorderLayout.CENTER); | |
} | |
public void play(){ | |
MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(); | |
CanvasVideoSurface videoSurface = mediaPlayerFactory.newVideoSurface(mCanvas); | |
EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.newEmbeddedMediaPlayer(); | |
mediaPlayer.setVideoSurface(videoSurface); | |
//TODO You must change the path string | |
mediaPlayer.playMedia("Video Path"); | |
mediaPlayer.play(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment