npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mep-instant

v2.1.0

Published

Top level namespace for the Instant Games SDK.

Downloads

5

Readme

MEPInstant

Top level namespace for the Instant Games SDK.

initializeAsync()

Initializes the SDK library. This should be called before any other SDK functions.

Examples


MEPInstant.initializeAsync().then(function() {
  // Many properties will be null until the initialization completes.
  // This is a good place to fetch them:
  var platform = MEPInstant.getPlatform(); // 'IOS'
  var sdkVersion = MEPInstant.getSDKVersion(); // '2.0'
  var playerID = MEPInstant.getPlayerID();
});

Returns Promise<void> that resolves when the SDK is ready to use.

getSDKVersion()

The string representation of this SDK version.

Examples


var sdkVersion = MEPInstant.getSDKVersion(); // '2.0'

Returns string The SDK version.

getPlatform()

The platform on which the game is currently running.

Examples


var platform = MEPInstant.getPlatform(); // 'IOS'

Returns string The platform.

getPlayerId()

Get the id of the player.

Examples


var platform = getPlayerId(); // '123'

Returns string The player id.

startGameAsync()

Start the game initialization flow.

Examples


MEPInstant.startGameAsync().then(function(song: Song) {
  myGame.start(song);
});

Returns Promise<Song> that resolves when game is loaded and data is fulfilled.

getNotesAsync()

Read notes data from the level file.

Parameters

  • levelUrl string The link to level file.

Examples


MEPInstant.getNotesAsync().then(function(notes: Note[]) {
  myGame.createObstacles(notes);
});

Returns Promise<Note[]> that resolves when the notes data is fetched.

onPause()

Set a callback to be fired when a pause event is triggered.

Parameters

  • func Function A function to call when a pause event occurs.

Examples


MEPInstant.onPause(function() {
  console.log('Pause event was triggered!');
  pauseGameplay();
})

Returns void

onResume()

Set a callback to be fired when a resume event is triggered.

Parameters

  • func Function A function to call when a resume event occurs.

Examples


MEPInstant.onResume(function() {
  console.log('Resume event was triggered!');
  resumeGameplay();
})

Returns void

showReviseConfirmation()

Show a revise confirmation dialog to allow user to choose whether continue or end game.

Parameters

  • onYesAnswer Function A function to call when user has chosen continue.
  • onNoAnswer Function A function to call when user has chosen stop.

Examples


MEPInstant.showReviseConfirmation(
function() {
  console.log('Continue is chose!');
  continueGameplay();
}, 
function() {
  console.log('Stop is chose!');
  stopGameplay();
})

Returns void

endGame()

Indicates that the game has finished.

Parameters

  • result Result The playing section result.

Examples


MEPInstant.endGame({ score: 23, star: 3, crown: 1, loop: 2, notes: 100, revise: 0, 1.4});

Returns void

createMusicPlayer()

Create music player to control music playback.

Parameters

Examples


var player = createMusicPlayer({
	src: [mp3Url],
	onLoad: function() {
	   loadLevel()
   }
});

Returns MusicPlayer to control music playback.

MusicPlayer

Music player that should be used to control music playback. In our game we use MusicPlayer to play mp3.

play()

Play music or resume previous playback.

Examples


player.play();

Returns void

pause()

Pause playback and save current position.

Examples


player.pause();

Returns void

resume()

Resume previous playback.

Examples


player.resume();

Returns void

stop()

Stop playback and reset to start.

Examples


player.stop();

Returns void

getDuration()

Get the duration.

Examples


var duration = player.getDuration(); // 120

Returns number the duration in second.

setCurrentTime()

Set the current position of a sound.

Parameters

  • sec number The position in second.

Examples


player.setCurrentTime(30);

Returns number the duration in second.

getCurrentTime()

Get the current position of a playback.

Examples


var currentTime = player.getCurrentTime(); // 90

Returns number the current position in second.

setVolume()

Set the volume for sound.

Parameters

  • volume number Volume from 0.0 to 1.0.

Examples


player.setVolume(0.9);

Returns void

getVolume()

Get the volume.

Examples


var volume = player.getVolume(); // 0.6

Returns number the volume.

isPlaying()

Check if a music is currently playing or not.

Examples


if (!player.isPlaying()) {
	player.play()
}

Returns boolean True if playing and false if not.

getState()

Returns the current loaded state.

Examples


var state = player.getState() // "loaded"

Returns string One of "unloaded", "loading", "loaded".

Song

Represents a song data for MEPInstant.startGameAsync.

Type: Object

Properties

  • id string Song's id.
  • title string Song's title.
  • artist string Artist's name.
  • duration number Duration in second.
  • mp3Url string Link to the mp3.
  • levelUrl string Link to level.

Note

Represents a note data for MEPInstant.getNotesAsync.

Type: Object

Properties

  • name string Name of note.
  • time number Time in seconds when the note is appeared.
  • duration number Duration of note in seconds.

Result

Represents a result data for MEPInstant.endGame.

Type: Object

Properties

  • score number The score.
  • star number The star.
  • crown number The crown. Earn by playing endless mode.
  • notes number The number of notes have been hit.
  • loop number The loop count. Once song is over then loop += 1.
  • revise number The revise count.
  • percent number The percentage of current song. e.g. 0.8.

MusicPlayerOptions

Represents option to create an MusicPlayer.

Type: Object

Properties

  • src string The sources to the track(s) to be loaded for the sound (URLs or base64 data URIs).
  • loop boolean Set to true to automatically loop the sound forever. default false.
  • autoplay boolean Set to true to automatically start playback when sound is loaded. default false.
  • rate number The rate of playback. 0.5 to 4.0, with 1.0 being normal speed. default 1.0
  • onLoad Function Fires when the sound is loaded.
  • onPlay Function Fires when the sound begins playing.
  • onSeek Function Fires when the sound has been seeked.
  • onPause Function Fires when the sound has been paused.
  • onStop Function Fires when the sound has been stopped.
  • onEnd Function Fires when the sound finishes playing (if it is looping, it'll fire at the end of each loop).