10.18.2013

Embedding Video with VLC Media Player


VLC has a handy Java library that can be used to create an instance of the VLC media player that can be embedded in a separate Java program. This player will play any media that VLC player can play independently if it is given the correct file path to that media as well as the location to the pre-downloaded VLC libraries. This includes media streams from other devices such as internet servers. This API (Application Programming Interface) is very useful for designing your own media player in which your GUI (Graphical User Interface) foundation is a functional media stream. It is also relatively easy to set up.


  1. http://www.videolan.org/vlc/download-windows.html go to this link and download the appropriate system architecture version of the VLC installer for your operating system (64-bit or 32-bit). It is important to get the bit number right as a 32-bit VLC will not work for a 64-bit system and vice versa. 
    • make sure to note the location of the VLC folder containing its files (usually something like C:\Program Files\VideoLAN\VLC)
  2. http://www.capricasoftware.co.uk/downloads/index.html go to this website and download the latest vlcj distribution zip. Extract this to a folder of your choosing. 
  3. Open up Eclipse (we use Eclipse but if you understand how import external libraries in a different IDE then use that). Create a new project and right click on it. Select the "build path" option then select "configure build path"
  4. In the resulting window, select "add external jars" and navigate to the vlcj distribution you downloaded in step 2. Select the "jna.jar," "platform.jar," and "vlcj.jar" (note: each of those will have a version number in the name).
From there, you will need to point your program toward the VLC folder mentioned in step 1 as well as the media file you want to play. http://www.youtube.com/watch?v=orMgNh0o38A This video does a very good job of describing the basic procedure of coding a media window to play a file pointed to during run time. in order to play a video stream, you must replace the argument for 

"mediaPlayer.getMediaPlayer().playMedia()"

with the url of the stream (what you might enter into a web browser to view the stream). For the MJPG-streamer software that we use, this is a little different. We pass the string 

"http://[local ip adress of stream]:port/?action=stream"

Our code for the media player will be on our Github and a link will be posted soon. 

No comments:

Post a Comment