Developer   API   Media   AudioPlayer

AudioPlayer(native)

This class provides the ability to play back sounds and music files on a device. By default, this class supports free formats like: wav, ogg and mod but most platforms support also other frequently used formats like mp3.

Example

// create new player and load source file this.player = new AudioPlayer(); this.player.openFile("dat://xxx.ogg"); ..... // play sound if nothing is playing if (!this.player.playing) this.player.play(); // otherwise pause playing else this.player.pause();

Properties

  • duration : Integer
    Value expressing the length of songs.
  • playing : Boolean
    When player is playing some file value is true. Otherwise, it is false.
  • position : Integer
    Value between zero and song duration.

Methods

  • dispose()
    Dispose function releases resource, allocated in memory. For Audio Player object it is for example opened file.
  • loop(repeat)
    Loop function determines, what happens after the song end. However, this function has to be used before play function.
  • openFile(file)
    Easy way to open file for playing.
  • pause()
    The pause function pauses playing. The next time you use the start function, playback will continue from the time when it was paused.
  • play()
    This call, starts playing opened file.
  • seek(percent)
    Efficient way to rewind plaing song.
  • stop()
    This function stops the playback.
  • this() : AudioPlayer
    Object constructor creates new instance of AudioPlayer class.