Package libavg :: Module avg :: Class Player

Class Player




The class used to load and play avg files.

Instance Methods
 
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
addTracker()
Adds a camera-based tracker to the avg player.
 
clearInterval(id)
Stops a timeout, an interval or an onFrameHandler from being called.
 
createNode(xml)
Creates a new Node.
 
getEffectiveFramerate()
Returns the framerate that the player is actually achieving.
 
getElementByID(id)
Returns an element in the avg tree.
 
getFrameTime()
Returns the number of milliseconds that have elapsed since playback has started.
 
getFramerate()
Returns the current target framerate in frames per second.
 
getMemUsed()
Returns the memory used by the process in bytes.
 
getMouseState()
Returns an interface to the last mouse event.
 
getRootNode()
Returns the outermost element in the avg tree.
 
getTestHelper(...)
 
getVideoRefreshRate()
Returns the current hardware video refresh rate in number of refreshes per second.
 
isPlaying()
Returns True if play() is currently executing, False if not.
 
loadFile(filename)
Loads the avg file specified in filename.
 
play()
Opens a playback window or screen and starts playback.
 
screenshot()
Returns the contents of the current screen as a bitmap.
 
setFakeFPS(fps)
Sets a fixed number of virtual frames per second that are used as clock source for video playback, animations and other time-based actions.
 
setFramerate(framerate)
Sets the desired framerate for playback.
 
setGamma(red, green, blue)
Sets display gamma.
 
setInterval(time, pyfunc)
Sets a python callable object that should be executed regularly.
 
setOGLOptions(UsePOW2Textures, YCbCrMode, UsePixelBuffers, MultiSampleSamples)
Determines which OpenGL extensions to check for and use if possible.
 
setOnFrameHandler(pyfunc)
Sets a python callable object that should be executed once per frame.
 
setResolution(fullscreen, width, height, bpp)
Sets display engine parameters.
 
setTimeout(time, pyfunc)
Sets a python callable object that should be executed after a set amount of time.
 
setVBlankFramerate(rate)
Sets the desired number of monitor refreshes before the next frame is displayed.
 
showCursor(show)
Shows or hides the mouse cursor.
 
stop()
Stops playback and resets the video mode if necessary.

Inherited from unreachable.instance: __new__

Inherited from object: __delattr__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables
  __instance_size__ = 316
Properties

Inherited from object: __class__

Method Details

__init__(...)
(Constructor)

 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

addTracker()

 
Adds a camera-based tracker to the avg player. The tracker can be configured using the .avgtrackerrc file and tracker immediately starts reporting events.

clearInterval(id)

 
Stops a timeout, an interval or an onFrameHandler from being called. Returns True if there was an interval with the given id, False if not.
Parameters:
  • id - An id returned by setInterval, setTimeout or setOnFrameHandler.
Returns:
ok

createNode(xml)

 
Creates a new Node. This node can be used as parameter to DivNode::appendChild() and insertChild(). This method will create any type of node, including <div> nodes with children.
Parameters:
  • xml - xml string in avg syntax that specifies the node to create.
Returns:
node

getEffectiveFramerate()

 
Returns the framerate that the player is actually achieving. The value returned is not averaged and reflects only the current frame.
Returns:
framerate

getElementByID(id)

 
Returns an element in the avg tree.
Parameters:
  • id - id attribute of the node to return.
Returns:
node

getFrameTime()

 
Returns the number of milliseconds that have elapsed since playback has started. Honors FakeFPS. The time returned stays constant for an entire frame; it is the time of the last display update.
Returns:
time

getFramerate()

 
Returns the current target framerate in frames per second.
Returns:
rate

getMouseState()

 
Returns an interface to the last mouse event.
Returns:
event

getRootNode()

 
Returns the outermost element in the avg tree.
Returns:
node

getVideoRefreshRate()

 
Returns the current hardware video refresh rate in number of refreshes per second.
Returns:
rate

isPlaying()

 
Returns True if play() is currently executing, False if not.
Returns:
bool

loadFile(filename)

 
Loads the avg file specified in filename.
Parameters:
  • filename -

play()

 
Opens a playback window or screen and starts playback. play returns when playback has ended.

screenshot()

 
Returns the contents of the current screen as a bitmap.
Returns:
bitmap

setFakeFPS(fps)

 
Sets a fixed number of virtual frames per second that are used as clock source for video playback, animations and other time-based actions. If a value of -1 is given as parameter, the real clock is used.
Parameters:
  • fps -

setFramerate(framerate)

 
Sets the desired framerate for playback. Turns off syncronization to the vertical blanking interval.
Parameters:
  • framerate -

setGamma(red, green, blue)

 
Sets display gamma. This is a control for overall brightness and contrast that leaves black and white unchanged but adjusts greyscale values. 1.0 is identity, higher values give a brighter image, lower values a darker one.
Parameters:
  • red, green, blue -

setInterval(time, pyfunc)

 
Sets a python callable object that should be executed regularly. setInterval returns an id that can be used to call clearInterval() to stop the function from being called. The callback is called at most once per frame.
Parameters:
  • time - Number of milliseconds between two calls.
  • pyfunc - Python callable to execute.
Returns:
id

setOGLOptions(UsePOW2Textures, YCbCrMode, UsePixelBuffers, MultiSampleSamples)

 
Determines which OpenGL extensions to check for and use if possible. Mainly used for debugging purposes while developing libavg, but can also be used to work around buggy drivers. The values set here override those in avgrc. Note that with the exception of MultiSampleSamples, fallbacks are always used - if a feature is specified that the system doesn't support, a less demanding one will be used.
Parameters:
  • UsePOW2Textures - If True, restricts textures to power-of-two dimensions.
  • YCbCrMode - Selects the preferred method of copying video textures to the screen. Can be shader, mesa, apple or none.
  • UsePixelBuffers - If False, disables the use of OpenGL pixel buffer objects.
  • MultiSampleSamples - The number of samples per pixel to compute. This costs performance and smoothes the edges of polygons. A value of 1 turns multisampling (also knowna as FSAA - Full-Screen Antialiasing) off. Good values are dependent on the graphics driver.

setOnFrameHandler(pyfunc)

 
Sets a python callable object that should be executed once per frame. Returns an id that can be used to call clearInterval() to stop the function from being called.
Parameters:
  • pyfunc - Python callable to execute.
Returns:
id

setResolution(fullscreen, width, height, bpp)

 
Sets display engine parameters. Must be called before loadFile.
Parameters:
  • fullscreen - True if the avg file should be rendered fullscreen.
  • width, height - Set the window size (if fullscreen is false) or screen resolution (if fullscreen is true).
  • bpp - Number of bits per pixel to use.

setTimeout(time, pyfunc)

 
Sets a python callable object that should be executed after a set amount of time. setTimeout returns an id that can be used to call clearInterval() to stop the function from being called.
Parameters:
  • time - Number of milliseconds before the call.
  • pyfunc - Python callable to execute.
Returns:
id

setVBlankFramerate(rate)

 
Sets the desired number of monitor refreshes before the next frame is displayed. The resulting framerate is determined by the monitor refresh rate divided by the rate parameter.
Parameters:
  • rate - Number of vertical blanking intervals to wait.

showCursor(show)

 
Shows or hides the mouse cursor.
Parameters:
  • show - True if the mouse cursor should be visible.