Skip to main content

mobage.shellapp.Music

Methods​

mobage.shellapp.Music.play​

void play(String fileName, Number fadeTime, Number loopCount)

This function plays back music.

  • Android only supports ogg file format. iOS only supports m4a (AAC) format.
  • If another application is playing music in the background, this function plays BGM after first pausing the other application. The function checks when the Music.play() or resume() functions are called.
  • This function pauses the playback of music when the application is suspended. Other paused applications will not resume playing music in the background.
  • This function resumes playing music from the point where it had been paused.
  • This function does not provide volume controls.
  • This function does not provide APIs for switching sound on or off.

Parameters

NameTypeDescription
fileNameStringString representation of sound filename Music does not play when a non-existent file name is specified.
fadeTimeNumberDuration (in seconds) of fade when switching music Music does not fade when this parameter is set to 0.
loopCountNumberNumber of times to loop Loops indefinitely when set to -1.

Return value
None

Sample

mobage.shellapp.Music.play("bgm1.ogg", 1.0, -1); // for Android
mobage.shellapp.Music.play("bgm1.m4a", 1.0, -1); // for iOS
mobage.shellapp.Music.play("bgm1", 1.0, -1); // without extension

mobage.shellapp.Music.pause​

void pause()

This function pauses music playback.

Parameters
None

Return value
None

Sample

mobage.shellapp.Music.pause();

mobage.shellapp.Music.resume​

void resume()

This function resumes music playback that had been paused.

Parameters
None

Return value
None

Sample

mobage.shellapp.Music.resume();

mobage.shellapp.Music.stop​

void stop()

This function stops music playback.

Parameters
None

Return value
None

Sample

mobage.shellapp.Music.stop();

Revision History​

  • 12/11/2012
    • Initial release.
  • Methods
    • mobage.shellapp.Music.play
    • mobage.shellapp.Music.pause
    • mobage.shellapp.Music.resume
    • mobage.shellapp.Music.stop
  • Revision History