uk.co.caprica.vlcj.player
Class MediaPlayerFactory

java.lang.Object
  extended by uk.co.caprica.vlcj.player.MediaPlayerFactory

public class MediaPlayerFactory
extends java.lang.Object

Factory for media player instances.

The factory initialises a single libvlc instance and uses that to create media player instances.

If required, you can create multiple factory instances each with their own libvlc options.

This factory attempts to determine the run-time operating system and create an appropriate media player instance.

You should release the factory when your application terminates to properly clean up native resources.

The factory also provides access to the native libvlc Logger.

Usage:

   // Set some options for libvlc
   String[] libvlcArgs = {...add options here...};
 
   // Create a factory instance (once), you can keep a reference to this
   MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(libvlcArgs);
   
   // Create a full-screen strategy
   FullScreenStrategy fullScreenStrategy = new DefaultFullScreenStrategy(mainFrame);
   
   // Create a media player instance for the run-time operating system
   EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.newMediaPlayer(fullScreenStrategy);
 
   // Do some interesting things with the media player
   
   ...
   
   // Release the media player
   mediaPlayer.release();
   
   // Release the factory
   factory.release();
 


Constructor Summary
MediaPlayerFactory()
          Create a new media player factory.
MediaPlayerFactory(LibVlc libvlc)
          Create a new media player factory.
MediaPlayerFactory(java.lang.String[] libvlcArgs)
          Create a new media player factory.
MediaPlayerFactory(java.lang.String[] libvlcArgs, LibVlc libvlc)
          Create a new media player factory.
 
Method Summary
 java.util.List<AudioOutput> getAudioOutputs()
          Get the available audio outputs.
 int getLogVerbosity()
          Get the current log verbosity level.
 Log newLog()
          Get a new message Logger.
 MediaList newMediaList()
           
 MediaListPlayer newMediaListPlayer()
           
 HeadlessMediaPlayer newMediaPlayer()
          Create a new head-less media player.
 EmbeddedMediaPlayer newMediaPlayer(FullScreenStrategy fullScreenStrategy)
          Create a new embedded media player.
 DirectMediaPlayer newMediaPlayer(int width, int height, RenderCallback renderCallback)
          Create a new direct video rendering media player.
 void release()
          Release the native resources associated with this factory.
 void setLogLevel(LogLevel level)
          Set the log verbosity level.
 void setUserAgent(java.lang.String userAgent)
          Set the application name.
 void setUserAgent(java.lang.String userAgent, java.lang.String httpUserAgent)
          Set the application name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MediaPlayerFactory

public MediaPlayerFactory()
Create a new media player factory.

This factory uses an implementation of the interface to the native libvlc library that is synchronised and logs each method invocation - if you do not want this behaviour you must use one of the other constructors.


MediaPlayerFactory

public MediaPlayerFactory(java.lang.String[] libvlcArgs)
Create a new media player factory.

This factory uses an implementation of the interface to the native libvlc library that is synchronised and logs each method invocation - if you do not want this behaviour you must use one of the other constructors.

Parameters:
libvlcArgs - initialisation arguments to pass to libvlc

MediaPlayerFactory

public MediaPlayerFactory(LibVlc libvlc)
Create a new media player factory.

Parameters:
libvlc - interface to the native library

MediaPlayerFactory

public MediaPlayerFactory(java.lang.String[] libvlcArgs,
                          LibVlc libvlc)
Create a new media player factory.

Parameters:
libvlcArgs - initialisation arguments to pass to libvlc
libvlc - interface to the native library
Method Detail

setUserAgent

public void setUserAgent(java.lang.String userAgent)
Set the application name.

Parameters:
userAgent - application name

setUserAgent

public void setUserAgent(java.lang.String userAgent,
                         java.lang.String httpUserAgent)
Set the application name.

Parameters:
userAgent - application name
httpUserAgent - application name for HTTP

getLogVerbosity

public int getLogVerbosity()
Get the current log verbosity level.

Returns:
log level

setLogLevel

public void setLogLevel(LogLevel level)
Set the log verbosity level.

Parameters:
level - log level

getAudioOutputs

public java.util.List<AudioOutput> getAudioOutputs()
Get the available audio outputs.

Returns:
collection of audio outputs

release

public void release()
Release the native resources associated with this factory.


newMediaPlayer

public EmbeddedMediaPlayer newMediaPlayer(FullScreenStrategy fullScreenStrategy)
Create a new embedded media player.

Parameters:
fullScreenStrategy - full screen implementation, may be null
Returns:
media player instance

newMediaPlayer

public DirectMediaPlayer newMediaPlayer(int width,
                                        int height,
                                        RenderCallback renderCallback)
Create a new direct video rendering media player.

Parameters:
width -
height -
renderCallback -
Returns:
media player instance

newMediaPlayer

public HeadlessMediaPlayer newMediaPlayer()
Create a new head-less media player.

Returns:
media player instance

newMediaListPlayer

public MediaListPlayer newMediaListPlayer()
Returns:

newMediaList

public MediaList newMediaList()
Returns:

newLog

public Log newLog()
Get a new message Logger.

The log will be opened.

Returns:
new log instance

(C)2010 Caprica Software Limited