Back

CreateMediaPlayer

Returns a MediaPlayer object.

For more information in the detailed docs see CreateMediaPlayer

  ply = app.CreateMediaPlayer() → app object - MediaPlayer

Example - Example



function OnStart()
{
    player = app.CreateMediaPlayer();
    player.SetOnReady( player_OnReady );
    player.SetFile( "/Sys/Snd/Trill.ogg" );
}

function player_OnReady()
{
    app.ShowPopup( "OnReady" );
    player.Play();
}
    Copy     Copy All       Run      

Example - OnComplete



function OnStart()
{
    lay = app.CreateLayout( "Linear", "FillXY,VCenter" );

    btn = app.CreateButton( "Play", 0.4, 0.1 );
    btn.SetOnTouch( btn_OnTouch );
    lay.AddChild( btn );

    app.AddLayout( lay );

    player = app.CreateMediaPlayer();
    player.SetOnComplete( player_OnComplete );
    player.SetFile( "/Sys/Snd/Poing.ogg" );
}

function btn_OnTouch()
{
    player.SeekTo( 0 );
    player.Play();
}

function player_OnComplete()
{
    app.ShowPopup( "OnComplete" );
}
    Copy     Copy All       Run      

The following methods are available on the MediaPlayer object:

  Close()
  GetDuration() → unknown
  GetPosition( options ) → object: { left, top, right, bottom}
  GetType() → string: "MediaPlayer"
  IsLooping()
  IsPlaying()
  IsReady()
  Method( name, types, p1, p2, p3, p4 )
  Pause()
  Play( from )
  SeekTo( time )
  SetFile( file )
  Stop()

number
string: "screen", "px"
Returns data about the position and size of the control.
If the screen option is given the position on the screen will be returned. Otherwise relative to the parent control.
The px options turns the relative values into pixels.
Returns the control class name.
string
string: comma separated: "boolean", "char", "byte", "short", "int", "long", "float", "double"
Allows access to other functions defined on the object in Java via reflection.
number: float
Play given time in in seconds
SeekTo given time in seconds
string: path to file or folder ( "/absolute/..." or "relative/..." )
SetFile
boolean
SetLooping mode
function()
called when
function()
called when playing file finished
function()
?
number: percent
SetVolume