Forge Documentation


This documentation is deprecated, and only kept here to support users of browser extension APIs. If you are using for iOS or Android, see

media: Media file playback


The media module must be enabled in config.json

    "modules": {
        "media": {
            "enable_background_audio": true
  • enable_background_audio: If this is true then audio players will continue to play even when the app is running in the background.



Platforms: Mobile

Play a video at a URL fullscreen on the device.


Allow users to select or capture videos using their device you may use the file module.

media.videoPlay(url, success, error)
  • url (string) -- URL to video.
  • success (function()) -- callback to be invoked when no errors occur
  • error (function(content)) -- called with details of any error which may occur


Platforms: Mobile

Create a audio player object from a media file which can then be used to play the audio.

The audio player object returned in the success callback has the following methods, all of which take success and error callbacks in the same manner as other Forge methods:

  •, error): Begin (or resume) playing the audio file.
  • player.pause(success, error): Pause the playback of the file.
  • player.stop(success, error): Stop the playback of the file and release the audio system.
  • player.duration(success, error): Calls the success callback with the duration of the audio in seconds.
  •, success, error): Seek to the given time (in seconds) in the audio file, if the file is playing it will continue to play after seeking.


For player.duration and to work properly on Android, use 128kb/s constant bit-rate MP3 files.


forge.file.getLocal("music.mp3", function (file) {, function (player) {;
media.createAudioPlayer(file, success, error)
  • file (string) -- File object created using forge.file methods representing audio object.
  • success (function(player)) -- callback to be invoked when player has been created
  • error (function(content)) -- called with details of any error which may occur