jmcvideo
Class JMC

java.lang.Object
  extended by processing.core.PImage
      extended by jmcvideo.JMC
All Implemented Interfaces:
com.sun.media.jmc.event.BufferDownloadListener, com.sun.media.jmc.event.VideoRendererListener, java.lang.Cloneable, java.util.EventListener, processing.core.PConstants
Direct Known Subclasses:
JMCMovie, JMCMovieGL

public abstract class JMC
extends processing.core.PImage
implements processing.core.PConstants, com.sun.media.jmc.event.VideoRendererListener, com.sun.media.jmc.event.BufferDownloadListener

JMC is an abstract class which provides the base functionality for Processing to interact with the JMC rendering callbacks. You should either use JMCMovie to access the video framss as a PImage pixel buffer or JMCMovieGL to render the frames to a openGL texture. Or you can extend from this class to create your own renderer.


Field Summary
 int bounces
           
 double bounceStart
           
 double bounceStop
           
 java.awt.image.BufferedImage bufferedImage
           
 boolean forward
           
 float h
           
 int imageType
           
 boolean isBouncing
           
 int numBounces
           
 int pixelFormat
           
 double progress
           
 double rate
           
 boolean stopVideoAfterBouncing
           
 int vh
           
 int vw
           
 float w
           
 float x
           
 float y
           
 
Fields inherited from class processing.core.PImage
cacheMap, format, height, modified, mx1, mx2, my1, my2, parent, pixels, saveImageFormats, width
 
Fields inherited from interface processing.core.PConstants
A, AB, ADD, AG, ALPHA, ALPHA_MASK, ALT, AMBIENT, AR, ARC, ARGB, ARROW, B, BACKSPACE, BASELINE, BEEN_LIT, BEVEL, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BURN, CENTER, CENTER_DIAMETER, CENTER_RADIUS, CHATTER, CLOSE, CMYK, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DA, DARKEST, DB, DEG_TO_RAD, DELETE, DG, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_OPENGL_2X_SMOOTH, DISABLE_OPENGL_ERROR_REPORT, DODGE, DOWN, DR, DXF, EB, EDGE, EG, ELLIPSE, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_2X_SMOOTH, ENABLE_OPENGL_4X_SMOOTH, ENABLE_OPENGL_ERROR_REPORT, ENTER, EPSILON, ER, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, G, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINE, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MOVE, MULTIPLY, NORMAL, NORMALIZED, NX, NY, NZ, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINTS, POLYGON, POSTERIZE, PROBLEM, PROJECT, QUAD, QUAD_STRIP, QUADS, QUARTER_PI, R, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPLACE, RETURN, RGB, RIGHT, ROUND, SA, SB, SCREEN, SG, SHAPE, SHIFT, SHINE, SOFT_LIGHT, SPB, SPG, SPHERE, SPOT, SPR, SQUARE, SR, SUBTRACT, SW, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, TX, TY, TZ, U, UP, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZ, WAIT, WHITESPACE, WINDOWS, X, Y, Z
 
Constructor Summary
JMC()
           
 
Method Summary
 void bounce()
          Begins video playback, playing forwards and then backwards forever if backward playback is supported.
 void bounce(double bounceStart, double bounceStop)
          Begins video playback, playing forwards and then backwards forever from the specified start time to the specified end time.
 void bounce(int numBounces)
          Begins video playback, playing forwards and then backwards a specified number of times.
 void bounce(int numBounces, double bounceStart, double bounceStop)
          Begins video playback, playing forwards and then backwards a specified number of times from the specified start time to the specified end time.
 void centerVideo()
           
 void centerVideo(float inset)
           
 void centerVideo(float frameWidth, float frameHeight, float inset)
           
 void changeBalance(float amt)
           
 void changeRate(double amt)
          Increase or decrease the rate of video playback by a specified amount.
 void changeVolume(float amt)
          Increase or decrease the volume by a specified amount.
 int currentLoop()
          Gets the current loop iteration.
 void dispose()
          Dispose of native resources.
 void frameVideo(float frameWidth, float frameHeight, float inset)
          Sets the bounds
 float getBalance()
           
 double getCurrentTime()
          Gets the current video playback position.
 double getDuration()
          Gets the duration of the video.
 java.lang.String getDurationString()
          Gets a nicely formatted version of the duration of the video.
 float getFader()
           
 int getImageType()
           
 java.lang.String getLoopString()
          Gets info about the loop settings.
 double getPlaybackPercentage()
          Gets the position of the video playback as a percentage between the start time and the end time of the video.
 double getProgress()
          Gets the download progress of the video.
 java.lang.String getProgressString()
          Gets a nicely formatted version of the download progress of the video.
 double getRate()
          Gets the current rate of video playback.
 double getStartTime()
           
 double getStopTime()
           
 java.lang.String getTimeString()
          Gets a nicely formatted version of the current playback position of the video.
 float getVolume()
          Gets the current volume.
 void handleBouncingBehavior()
           
 void initializeVideo(processing.core.PApplet parent, java.net.URI uri, int pixelFormat)
           
 boolean isLooping()
          Determines whether or not the video is looping.
 boolean isMuted()
          Determine if the video is muted or not.
 boolean isPlaying()
          Determine if the video is currently playing.
 boolean isReady()
          Checks to make sure that the video has a legitimate duration and that we are not trying to play past what has been downloaded.
 void loop()
          Begins video playback, looping forever
 void loop(double start, double stop)
          Begins video playback, looping forever from the specified start time to the specified end time.
 void loop(int numRepeats)
          Begins video playback, looping a specified number of times.
 void loop(int numRepeats, double start, double stop)
          Begins video playback, looping a specified number of times from the specified start time to the specified end time.
 void mediaDownloadProgressChanged(com.sun.media.jmc.event.BufferDownloadedProgressChangedEvent bde)
           
 void paintBufferedImage()
          Paints the newest video frame onto a BufferedImage.
 void pause()
          Pauses the video playback.
 void play()
          Begins video playback.
 void play(double start, double stop)
           
 void setBalance(float balance)
           
 void setBounds(float x, float y, float w, float h)
          Explicitly sets the bounds of this PImage.
 void setCurrentTime(double time)
          Sets the current video playback position.
 void setFader(float fader)
           
 void setImageType(int imageType)
          Sets the imageType of the bufferedImage that the frame is painted on.
 void setMute(boolean mute)
          Mutes or unmutes the video.
 void setPlaybackPercentage(double perc)
          Sets the position of the video playback using a percentage between the start time and the end time of the video.
 void setRate(double rate)
          Sets the rate of video playback
 void setStartTime(double start)
           
 void setStopTime(double stop)
           
 void setupBufferedImage()
          Creates a BufferedImage the same size as the video and initializes the PImage pixel buffer.
 void setVideo(java.net.URI uri)
          Sets the video for this MediaProvider.
 void setVolume(float vol)
          Sets the volume to the specified volume.
 void stop()
          Stops and rewinds the movie to the beginning.
 void switchVideo(java.io.File file)
          Switch to a new video.
 void switchVideo(java.lang.String filename)
          Switch to a new video.
 void switchVideo(java.net.URI uri)
          Switch to a new video.
 void switchVideo(java.net.URL url)
          Switch to a new video.
 void toggleMute()
          Make the video mute if it is not, or unmutes it if it is.
 int totalLoops()
          Gets the total number of loops that has been set.
 
Methods inherited from class processing.core.PImage
blend, blend, blendColor, blurAlpha, blurARGB, blurRGB, buildBlurKernel, checkAlpha, clone, copy, copy, dilate, filter, filter, get, get, get, getCache, getImage, getImpl, init, isModified, loadPixels, loadTIFF, mask, mask, removeCache, resize, save, saveImageIO, saveTGA, saveTIFF, set, set, setCache, setImpl, setModified, setModified, updatePixels, updatePixels, updatePixelsImpl
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.media.jmc.event.VideoRendererListener
videoFrameUpdated
 

Field Detail

vw

public int vw

vh

public int vh

rate

public double rate

isBouncing

public boolean isBouncing

numBounces

public int numBounces

bounces

public int bounces

bounceStart

public double bounceStart

bounceStop

public double bounceStop

forward

public boolean forward

stopVideoAfterBouncing

public boolean stopVideoAfterBouncing

progress

public double progress

imageType

public int imageType

pixelFormat

public int pixelFormat

bufferedImage

public java.awt.image.BufferedImage bufferedImage

x

public float x

y

public float y

w

public float w

h

public float h
Constructor Detail

JMC

public JMC()
Method Detail

initializeVideo

public void initializeVideo(processing.core.PApplet parent,
                            java.net.URI uri,
                            int pixelFormat)

mediaDownloadProgressChanged

public void mediaDownloadProgressChanged(com.sun.media.jmc.event.BufferDownloadedProgressChangedEvent bde)
Specified by:
mediaDownloadProgressChanged in interface com.sun.media.jmc.event.BufferDownloadListener

switchVideo

public void switchVideo(java.lang.String filename)
Switch to a new video.

Parameters:
filename - The name of the new video file in the data directory.

switchVideo

public void switchVideo(java.io.File file)
Switch to a new video.

Parameters:
file - A video file.

switchVideo

public void switchVideo(java.net.URL url)
Switch to a new video.

Parameters:
url - The URL of a video file.

switchVideo

public void switchVideo(java.net.URI uri)
Switch to a new video.

Parameters:
uri - The URI of a video file.

setImageType

public void setImageType(int imageType)
Sets the imageType of the bufferedImage that the frame is painted on.

Parameters:
imageType -

getImageType

public int getImageType()

handleBouncingBehavior

public void handleBouncingBehavior()

paintBufferedImage

public void paintBufferedImage()
Paints the newest video frame onto a BufferedImage.


setupBufferedImage

public void setupBufferedImage()
Creates a BufferedImage the same size as the video and initializes the PImage pixel buffer.


setBounds

public void setBounds(float x,
                      float y,
                      float w,
                      float h)
Explicitly sets the bounds of this PImage.

Parameters:
x -
y -
w -
h -

frameVideo

public void frameVideo(float frameWidth,
                       float frameHeight,
                       float inset)
Sets the bounds

Parameters:
frameWidth -
frameHeight -
inset -

centerVideo

public void centerVideo()

centerVideo

public void centerVideo(float inset)

centerVideo

public void centerVideo(float frameWidth,
                        float frameHeight,
                        float inset)

getTimeString

public java.lang.String getTimeString()
Gets a nicely formatted version of the current playback position of the video.

Returns:
The playback position.

getDurationString

public java.lang.String getDurationString()
Gets a nicely formatted version of the duration of the video.

Returns:
The duration of the video.

getProgressString

public java.lang.String getProgressString()
Gets a nicely formatted version of the download progress of the video.

Returns:
The progress of the video.

getLoopString

public java.lang.String getLoopString()
Gets info about the loop settings.

Returns:
The loop settings.

getStartTime

public double getStartTime()

setStartTime

public void setStartTime(double start)

getStopTime

public double getStopTime()

setStopTime

public void setStopTime(double stop)

getDuration

public double getDuration()
Gets the duration of the video.

Returns:
The duration of the video.

getProgress

public double getProgress()
Gets the download progress of the video.

Returns:
The download progress of the video.

changeRate

public void changeRate(double amt)
Increase or decrease the rate of video playback by a specified amount.

Parameters:
amt - Amount by which to change the rate.

setRate

public void setRate(double rate)
Sets the rate of video playback

Parameters:
rate - The rate to set the playback to.

getRate

public double getRate()
Gets the current rate of video playback.

Returns:
The current rate.

pause

public void pause()
Pauses the video playback.


play

public void play()
Begins video playback.


play

public void play(double start,
                 double stop)

loop

public void loop()
Begins video playback, looping forever


loop

public void loop(int numRepeats)
Begins video playback, looping a specified number of times.

Parameters:
numRepeats -

loop

public void loop(double start,
                 double stop)
Begins video playback, looping forever from the specified start time to the specified end time.

Parameters:
start -
stop -

loop

public void loop(int numRepeats,
                 double start,
                 double stop)
Begins video playback, looping a specified number of times from the specified start time to the specified end time.

Parameters:
start -
stop -

bounce

public void bounce()
Begins video playback, playing forwards and then backwards forever if backward playback is supported.


bounce

public void bounce(int numBounces)
Begins video playback, playing forwards and then backwards a specified number of times.

Parameters:
numBounces -

bounce

public void bounce(double bounceStart,
                   double bounceStop)
Begins video playback, playing forwards and then backwards forever from the specified start time to the specified end time.

Parameters:
bounceStart -
bounceStop -

bounce

public void bounce(int numBounces,
                   double bounceStart,
                   double bounceStop)
Begins video playback, playing forwards and then backwards a specified number of times from the specified start time to the specified end time.

Parameters:
numBounces -
bounceStart -
bounceStop -

isReady

public boolean isReady()
Checks to make sure that the video has a legitimate duration and that we are not trying to play past what has been downloaded.

Returns:
Whether or not the video is available for playing and querying.

isPlaying

public boolean isPlaying()
Determine if the video is currently playing. This seems to be inaccurate sometimes!

Returns:
A boolean indicating whether or not the video is currently playing.

changeVolume

public void changeVolume(float amt)
Increase or decrease the volume by a specified amount.

Parameters:
amt - Amount by which to change the volume.

setVolume

public void setVolume(float vol)
Sets the volume to the specified volume.

Parameters:
vol -

getVolume

public float getVolume()
Gets the current volume.

Returns:
The current volume.

setMute

public void setMute(boolean mute)
Mutes or unmutes the video.


isMuted

public boolean isMuted()
Determine if the video is muted or not.

Returns:
A boolean indicating if the video is muted.

toggleMute

public void toggleMute()
Make the video mute if it is not, or unmutes it if it is.


changeBalance

public void changeBalance(float amt)

setBalance

public void setBalance(float balance)

getBalance

public float getBalance()

setFader

public void setFader(float fader)

getFader

public float getFader()

getCurrentTime

public double getCurrentTime()
Gets the current video playback position.

Returns:
The current time.

setCurrentTime

public void setCurrentTime(double time)
Sets the current video playback position.

Parameters:
time -

getPlaybackPercentage

public double getPlaybackPercentage()
Gets the position of the video playback as a percentage between the start time and the end time of the video.

Returns:
A number between 0.0 and 1.0, where 0.0 is the start of the video and 1.0 is the end of the video.

setPlaybackPercentage

public void setPlaybackPercentage(double perc)
Sets the position of the video playback using a percentage between the start time and the end time of the video.

Parameters:
perc - A number between 0.0 and 1.0, where 0.0 is the start of the video and 1.0 is the end of the video.

isLooping

public boolean isLooping()
Determines whether or not the video is looping.

Returns:
A boolean indicating whether or not the video is looping.

totalLoops

public int totalLoops()
Gets the total number of loops that has been set.

Returns:
The total number of loops set.

currentLoop

public int currentLoop()
Gets the current loop iteration.

Returns:
The current loop number.

stop

public void stop()
Stops and rewinds the movie to the beginning.


dispose

public void dispose()
Dispose of native resources.


setVideo

public void setVideo(java.net.URI uri)
Sets the video for this MediaProvider.

Parameters:
uri - The URI of the video.