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.
ok
clearInterval(id)
Stops a timeout, an interval or an onFrameHandler from being called.
node
createNode(xml)
Creates a new Node.
 
enableAudio(bEnable)
Enables or disables audio playback.
framerate
getEffectiveFramerate()
Returns the framerate that the player is actually achieving.
node
getElementByID(id)
Returns an element in the avg tree.
time
getFrameTime()
Returns the number of milliseconds that have elapsed since playback has tarted.
rate
getFramerate()
Returns the current target framerate in frames per second.
KeyModifier
getKeyModifierState()
Returns the current modifier keys (shift, ctrl) pressed.
event
getMouseState()
Returns an interface to the last mouse event.
node
getRootNode()
Returns the outermost element in the avg tree.
 
getTestHelper(...)
 
getTracker()
returns a tracker previously created with addTracker.
rate
getVideoRefreshRate()
Returns the current hardware video refresh rate in number of refreshes per second.
bool
isPlaying()
Returns True if play() is currently executing, False if not.
 
loadFile(filename)
Loads the avg file specified in filename.
 
loadPlugin(name)
load a Plugin and extend the XML DTD.
 
loadString(avgString)
Parses avgString and loads the nodes it contains.
 
play()
Opens a playback window or screen and starts playback.
bitmap
screenshot()
Returns the contents of the current screen as a bitmap.
 
setCursor(bitmap, hotspot)
Sets the mouse cursor to the bitmap given.
 
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.
id
setInterval(time, pyfunc)
Sets a python callable object that should be executed regularly.
 
setMousePos(pos)
Sets the position of the mouse cursor.
 
setMultiSampleSamples(multiSampleSamples)
 
setOGLOptions(UsePOW2Textures, UseYCbCrShaders, UsePixelBuffers, MultiSampleSamples)
Determines which OpenGL extensions to check for and use if possible.
id
setOnFrameHandler(pyfunc)
Sets a python callable object that should be executed once per frame.
 
setResolution(fullscreen, width, height, bpp)
Sets display engine parameters.
id
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.
 
setWindowPos(x, y)
Sets the location of the player window.
 
showCursor(show)
Shows or hides the mouse cursor.
 
stop()
Stops playback and resets the video mode if necessary.
 
stopOnEscape(stop)
Toggles player stop upon escape keystroke.

Inherited from unreachable.instance: __new__

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

Static Methods
 
get(...)
This method gives access to the player, which must have been created.
Class Variables
  __instance_size__ = 452
Properties
  pluginPath
A colon-separated list of directories where the player searches for plugins when loadPlugin() is called.
  volume
Total audio playback volume.

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 default config file and 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.

    createNode(type, args) -> node Creates a new Node. This node can be used as parameter to DivNode::appendChild() and insertChild(). This method will only create one node at a time.

  • type - type string of the node to create.
  • args - a dictionary specifying attributes of the node.
Returns: node

enableAudio(bEnable)

 

Enables or disables audio playback. If audio playback is disabled, no nodes with sound can be created. Mainly used to speed up the test suite.

get(...)
Static Method

 

This method gives access to the player, which must have been created. before by calling the constructor.

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 tarted. Honors FakeFPS. The time returned stays constant for an entire frame; it is the time of the last display update.

Returns: time

getKeyModifierState()

 

Returns the current modifier keys (shift, ctrl) pressed. The return value is several KeyModifier values or'ed together.

Returns: KeyModifier

loadFile(filename)

 

Loads the avg file specified in filename.

Parameters:
  • filename

loadPlugin(name)

 

load a Plugin and extend the XML DTD.

Parameters:
  • name - name of the plugin (without directory and file extension)

loadString(avgString)

 

Parses avgString and loads the nodes it contains.

Parameters:
  • avgString - An xml string containing an avg node hierarchy.

play()

 

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

setCursor(bitmap, hotspot)

 

Sets the mouse cursor to the bitmap given. The bitmap must have a size divisible by 8 and an RGBA pixel format. The cursor generated is binary black and white with a binary transparency channel. hotspot is the relative position of the actual pointing coordinate in the 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. FakeFPS can be used to get reproducible effects for recordings or automated tests. Setting FakeFPS has the side-effect of disabling audio.

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

setMousePos(pos)

 

Sets the position of the mouse cursor. Generates a mouse motion event.

Parameters:
  • pos - new coordinates as a Point2D.

setMultiSampleSamples(multiSampleSamples)

 
Parameters:
  • 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.

setOGLOptions(UsePOW2Textures, UseYCbCrShaders, 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.
  • UseYCbCrShaders - If True, shaders are used to copy YCbCr to the screen. Results in a major video playback performance boost.
  • 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 or loadString.

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.

setWindowPos(x, y)

 

Sets the location of the player window. Must be called before loadFile or loadString.

showCursor(show)

 

Shows or hides the mouse cursor.

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

stopOnEscape(stop)

 

Toggles player stop upon escape keystroke.

Parameters:
  • stop - True if player should stop on escape

Property Details

pluginPath

A colon-separated list of directories where the player searches for plugins when loadPlugin() is called.

Get Method:
unreachable(...)
Set Method:
unreachable(...)

volume

Total audio playback volume. 0 is silence, 1 passes media file volume through unchanged. Values higher than 1 can be used to amplify playback. A limiter prevents distortion when the volume is set to high.

Get Method:
unreachable(...)
Set Method:
unreachable(...)