com.hdcookbook.grin.media
Class PlayerWrangler

java.lang.Object
  extended by com.hdcookbook.grin.media.PlayerWrangler
All Implemented Interfaces:
java.util.EventListener, javax.media.ControllerListener, org.bluray.media.PlaybackListener

public class PlayerWrangler
extends java.lang.Object
implements org.bluray.media.PlaybackListener, javax.media.ControllerListener

This is a singleton class that's used to control A/V playback on the primary JMF player.


Method Summary
 void controllerUpdate(javax.media.ControllerEvent event)
          Callback from ControllerListener
 org.bluray.net.BDLocator createLocator(java.lang.String str)
          Create a BD locator.
 org.davic.media.MediaLocator createMediaLocator(java.lang.String loc)
          Create a MediaLocator, given a BD locator string
 void destroy()
          Destroy the playback engine.
static PlayerWrangler getInstance()
           
 long getMediaTime()
          Returns the current media time in ns, or -1 if no playlist has started.
 int getMediaTimeMS()
          Returns the current media time in ms, or -1 if no playlist has started.
 float getRate()
          Gets the rate of playback.
 javax.tv.media.AWTVideoSizeControl getSizeControl()
          Returns an AWTVideoSizeControl that can be used to scale the video.
 void initialize(AnimationEngine engine)
          Initialize the playback engine.
 void markReached(org.bluray.media.PlaybackMarkEvent event)
          Callback from PlaybackListener
 void playItemReached(org.bluray.media.PlaybackPlayItemEvent event)
          Callback from PlaybackListener
 void setMediaTime(long time)
          Sets the current media time in ns.
 void setMediaTimeMS(int time)
          Sets the current media time in ns.
 void setRate(float rate)
          Sets the rate of playback, subject to the restrictions of the BD spec.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static PlayerWrangler getInstance()

initialize

public void initialize(AnimationEngine engine)
Initialize the playback engine. This must be called after the xlet starts, and before playback of video clips is attempted.


destroy

public void destroy()
Destroy the playback engine. This must be called on xlet termination. Once destroyed, any attempt at media control fill fail, because PlayerWrangler.getInstance() will return null.


createLocator

public org.bluray.net.BDLocator createLocator(java.lang.String str)
Create a BD locator.


createMediaLocator

public org.davic.media.MediaLocator createMediaLocator(java.lang.String loc)
Create a MediaLocator, given a BD locator string


getMediaTime

public long getMediaTime()
Returns the current media time in ns, or -1 if no playlist has started.


getMediaTimeMS

public int getMediaTimeMS()
Returns the current media time in ms, or -1 if no playlist has started.


setMediaTime

public void setMediaTime(long time)
Sets the current media time in ns. This method can only be called after the first playlist is started, because that's the first time a JMF player is acquired.


setMediaTimeMS

public void setMediaTimeMS(int time)
Sets the current media time in ns. This method can only be called after the first playlist is started, because that's the first time a JMF player is acquired.


setRate

public void setRate(float rate)
Sets the rate of playback, subject to the restrictions of the BD spec. This is just a pass-through to the JMF Player.setRate() method. This method can only be called after the first playlist is started, because that's the first time a JMF player is acquired.


getRate

public float getRate()
Gets the rate of playback. This is just a pass-through to the JMF Player.getRate method. This method can only be called after the first playlist is started, because that's the first time a JMF player is acquired.


getSizeControl

public javax.tv.media.AWTVideoSizeControl getSizeControl()
Returns an AWTVideoSizeControl that can be used to scale the video. This returns null if a playlist hasn't been started yet. That's inconvenient, but it's a function of how the underlying API is structured, where you can't get a JMF player until you start it on something.

This method is only available on the Xlet version of this class, because AWTVideoSizeControl is a JavaTV API.

In the future, it might be intersting to integrate InterpolatedModel or some other way of declaratively controlling the display size with the Playlist API. Doing that is non-trivial, though, partly because of AWTVideoSizeControl.checkSize(). As of this writing, that has not been done, so scripting from Java is needed to adjust the video size.


markReached

public void markReached(org.bluray.media.PlaybackMarkEvent event)
Callback from PlaybackListener

Specified by:
markReached in interface org.bluray.media.PlaybackListener

playItemReached

public void playItemReached(org.bluray.media.PlaybackPlayItemEvent event)
Callback from PlaybackListener

Specified by:
playItemReached in interface org.bluray.media.PlaybackListener

controllerUpdate

public void controllerUpdate(javax.media.ControllerEvent event)
Callback from ControllerListener

Specified by:
controllerUpdate in interface javax.media.ControllerListener