codeanticode.gsvideo
Class GSPlayer

java.lang.Object
  extended by processing.core.PImage
      extended by codeanticode.gsvideo.GSPlayer
All Implemented Interfaces:
java.lang.Cloneable, processing.core.PConstants

public class GSPlayer
extends processing.core.PImage
implements processing.core.PConstants

This class makes it possible to load and play generic media content through playbin (not only movies, but also audio files, etc).


Field Summary
 byte[] data
           
 java.lang.String dataCaps
           
 
Fields inherited from class processing.core.PImage
format, height, parent, pixels, 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, BILINEAR, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BURN, CENTER, CENTER_DIAMETER, CENTER_RADIUS, CHATTER, CLAMP, 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_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_2X_SMOOTH, DISABLE_OPENGL_ERROR_REPORT, DODGE, DOWN, DR, DXF, DYNAMIC, EB, EDGE, EG, ELLIPSE, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_MASK, 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, FIXED, G, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HAS_NORMAL, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINEAR, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, NORMALIZED, NX, NY, NZ, OPAQUE, OPEN, OPENGL, OPENGL2, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINT_SPRITES, POINTS, POLYGON, POSTERIZE, PROBLEM, PROG_GL2, PROG_GL3, PROG_GL4, PROJECT, PROJECTION, QUAD, QUAD_STRIP, QUADRATIC, QUADS, QUARTER_PI, R, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SA, SB, SCREEN, SG, SHAPE, SHIFT, SHINE, SOFT_LIGHT, SPB, SPG, SPHERE, SPOT, SPR, SQUARE, SR, STATIC, STREAM, SUBTRACT, SW, TAB, TARGA, TEXT, TEXTURE2D, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TRILINEAR, TWO_PI, TX, TY, TZ, U, UP, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZ, WAIT, WHITESPACE, WINDOWS, X, Y, Z
 
Constructor Summary
GSPlayer(processing.core.PApplet parent, java.lang.String filename)
          Creates an instance of GSPlayer loading the media file from filename, assuming that it is a video file.
GSPlayer(processing.core.PApplet parent, java.lang.String filename, int type)
          Creates an instance of GSPlayer loading the media file from filename, and trying to understand it as the indicated type.
 
Method Summary
 boolean available()
          Return the true or false depending on whether there is a new frame ready to be read.
 void delete()
          Releases the gstreamer resources associated to this player object.
 void dispose()
          Same as delete.
 void disposeBuffer(java.lang.Object buf)
           
 float duration()
          Get the full length of the current stream (in seconds).
 int frame()
          Return the current frame.
 void frameRate(float ifps)
          Set how often new frames are to be read from the stream.
 java.lang.String getFilename()
          Returns the text string containing the filename of the media loaded.
 float getSourceFrameRate()
          Get the original framerate of the source video.
 int getSourceHeight()
          Get the height of the source video.
 int getSourceWidth()
          Get the width of the source video.
 void goToBeginning()
          Jumps to the first frame of the stream.
 void goToEnd()
          Jumps to the last frame of the stream.
 boolean isLooping()
          Returns whether the media is looping or not.
 boolean isPaused()
          Returns whether the media is paused or not.
 boolean isPlaying()
          Returns whether the media is playing or not.
 boolean isSeeking()
          Returns true if stream is completing a seeking (jump) operation.
 void jump(float where)
          Jump to a specific location (in seconds).
 void jump(int frame)
          Jump to a specific frame.
 long length()
          Get the full length of this movie (in frames).
 void loop()
          Begin playing the stream, with repeat.
 boolean newFrame()
          Returns true if a new frame has been read to the pixels array with the read() method.
 void noLoop()
          Shut off the repeating loop.
 void oldFrame()
          Sets the new frame flag to false.
 void pause()
          Pause the stream at its current time.
 void play()
          Begin playing the stream, with no repeat.
 void read()
          Reads the current video frame or data buffer.
 boolean ready()
          Returns true if the stream is already producing frames.
 void setEventHandlerObject(java.lang.Object obj)
          Uses a generic object as handler of the media file.
 void setPixelDest(java.lang.Object dest)
          Sets the object to use as destination for the frames read from the stream.
 void setPixelDest(java.lang.Object dest, boolean copy)
          Sets the object to use as destination for the frames read from the stream.
 void setPixelDest(java.lang.Object dest, java.lang.String mask, boolean copy)
          Sets the object to use as destination for the frames read from the stream.
 void speed(float irate)
          Set a multiplier for how fast/slow the movie should be run.
 void stop()
          Stop the stream, and rewind.
 float time()
          Return the current time in seconds.
 void volume(float v)
          Change the volume.
 
Methods inherited from class processing.core.PImage
blend, blend, blendColor, clone, copy, copy, filter, filter, get, get, get, getCache, getImage, getModifiedX1, getModifiedX2, getModifiedY1, getModifiedY2, getParams, init, isModified, loadPixels, mask, mask, removeCache, removeParams, resize, save, set, set, setCache, setModified, setModified, setParams, updatePixels, updatePixels
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

public byte[] data

dataCaps

public java.lang.String dataCaps
Constructor Detail

GSPlayer

public GSPlayer(processing.core.PApplet parent,
                java.lang.String filename)
Creates an instance of GSPlayer loading the media file from filename, assuming that it is a video file.

Parameters:
parent - PApplet
filename - String

GSPlayer

public GSPlayer(processing.core.PApplet parent,
                java.lang.String filename,
                int type)
Creates an instance of GSPlayer loading the media file from filename, and trying to understand it as the indicated type.

Parameters:
parent - PApplet
filename - String
type - int
Method Detail

delete

public void delete()
Releases the gstreamer resources associated to this player object. It shouldn't be used after this.

Overrides:
delete in class processing.core.PImage

dispose

public void dispose()
Same as delete.


setPixelDest

public void setPixelDest(java.lang.Object dest)
Sets the object to use as destination for the frames read from the stream. The color conversion mask is automatically set to the one required to copy the frames to OpenGL.

Parameters:
Object - dest

setPixelDest

public void setPixelDest(java.lang.Object dest,
                         boolean copy)
Sets the object to use as destination for the frames read from the stream. The color conversion mask is automatically set to the one required to copy the frames to OpenGL. If copy is true, then the frames are copied into new buffer objects, this can help solve threading problems when playing back a large number of videos.

Parameters:
Object - dest
boolean - copy

setPixelDest

public void setPixelDest(java.lang.Object dest,
                         java.lang.String mask,
                         boolean copy)
Sets the object to use as destination for the frames read from the stream. If copy is true, then the frames are copied into new buffer objects, this can help solve threading problems when playing back a large number of videos.

Parameters:
Object - dest
String - mask
boolean - copy

setEventHandlerObject

public void setEventHandlerObject(java.lang.Object obj)
Uses a generic object as handler of the media file. This object should have a movieEvent method that receives a GSMovie argument. This method will be called upon a new frame read event.


getSourceWidth

public int getSourceWidth()
Get the width of the source video. Note: calling this method repeatedly can slow down playback performance.

Returns:
int

getSourceHeight

public int getSourceHeight()
Get the height of the source video. Note: calling this method repeatedly can slow down playback performance.

Returns:
int

getSourceFrameRate

public float getSourceFrameRate()
Get the original framerate of the source video. Note: calling this method repeatedly can slow down playback performance.

Returns:
float

frameRate

public void frameRate(float ifps)
Set how often new frames are to be read from the stream. Does not actually set the speed of the playback, that's handled by the speed() method.

Parameters:
int - ifps
See Also:
speed

speed

public void speed(float irate)
Set a multiplier for how fast/slow the movie should be run. The default is 1.0. speed(2) will play the movie at double speed (2x). speed(0.5) will play at half speed. speed(-1) will play backwards at regular speed.

Parameters:
float - irate

duration

public float duration()
Get the full length of the current stream (in seconds).

Returns:
float

time

public float time()
Return the current time in seconds.

Returns:
float

length

public long length()
Get the full length of this movie (in frames).

Returns:
float

frame

public int frame()
Return the current frame.

Returns:
int

jump

public void jump(float where)
Jump to a specific location (in seconds). The number is a float so fractions of seconds can be used.

Parameters:
float - where

jump

public void jump(int frame)
Jump to a specific frame.

Parameters:
frame - int

ready

public boolean ready()
Returns true if the stream is already producing frames.

Returns:
boolean

newFrame

public boolean newFrame()
Returns true if a new frame has been read to the pixels array with the read() method.

Returns:
boolean

oldFrame

public void oldFrame()
Sets the new frame flag to false. This is useful to avoid reading pixels array when there is no new frame data.


available

public boolean available()
Return the true or false depending on whether there is a new frame ready to be read.

Returns:
boolean

isPlaying

public boolean isPlaying()
Returns whether the media is playing or not.

Returns:
boolean

isPaused

public boolean isPaused()
Returns whether the media is paused or not. If isPlaying() and isPaused() both return false it means that the media is stopped.

Returns:
boolean

isLooping

public boolean isLooping()
Returns whether the media is looping or not.

Returns:
boolean

isSeeking

public boolean isSeeking()
Returns true if stream is completing a seeking (jump) operation.

Returns:
boolean

play

public void play()
Begin playing the stream, with no repeat.


loop

public void loop()
Begin playing the stream, with repeat.


noLoop

public void noLoop()
Shut off the repeating loop.


pause

public void pause()
Pause the stream at its current time.


stop

public void stop()
Stop the stream, and rewind.


read

public void read()
Reads the current video frame or data buffer.


goToBeginning

public void goToBeginning()
Jumps to the first frame of the stream.


goToEnd

public void goToEnd()
Jumps to the last frame of the stream.


volume

public void volume(float v)
Change the volume. Values are from 0 to 1.

Parameters:
float - v

getFilename

public java.lang.String getFilename()
Returns the text string containing the filename of the media loaded.

Returns:
String

disposeBuffer

public void disposeBuffer(java.lang.Object buf)


processing library GSVideo by Andres Colubri. (c) 2008-2011