GM Android Music

GM Android Music for Gamemaker: Studio devlopers

GM Android Music is an extension for Android devices that allows you to play music from the users music library. Selling price is $1.99.
    You must have Gamemaker: Studio with the android module to use this extension. In your project you must have WRITE_EXTERNAL_STORAGE enabled by going to Global game settings in the resource tree, select Android>Permissions and check the WRITE_EXTERNAL_STORAGE box. Also note that on android os versions 6.0 and later that permissions arn't set automatically anymore in the users device, in which case the user would have to go to phone settings>Applications>Application manager>(Your app name) and on the permissions section enable storage. included in the extension is a basic project showing you the features of GM Android Music such as finding and reporting the number of songs on the device, scroll buttons to view the song names, auto playing the songs, random plaaying the songs, creating a playlist (the example allows creating 100 songs on the playlist but you can adjust or make your own code to play more or less), play the playlist in order, play the playlist randomly, go to a specific song, and the usual functions including play, pause, stop, next (also works in playlist mode), and previous (also works in playlist mode). 

When adding the extension from your marketplace library into a brand new project make sure you put the controller object in the provided room and set android permissions in global game settings. Also I've seen trouble with the ADD ALL button in the marketplace library not adding all the assets, so add eacch category individuaally and check that they are all added into your project. No other objects need to be placed in any rooms.

When adding the extension from your marketplace library to an existing project take all of the create event code out but leave the alarm[1]=1; and set=1; code in it and put it in your controller object that runs at the beginning of your game to define the global variables. No other objects need to be placed in any rooms.

For the virtual key setup if your rooms are not 1024 x 768, or you use views you need to change the values in the first 2 lines of code in the room oMusicRoom 's creation code, these 2 lines are set like this by default:

var base_w = 1024;//width of original game
var base_h = 768;//height of original game

So for example if your rooms are 600 x 400 or your view is 600 x 400 you'd change the above code to:

var base_w = 600;//width of original game
var base_h = 400;//height of original game

If you don't then the controller (bottom left directional arrows) for moving the pointer in the Create playlist menu will most likely not work. All the buttons on the music player it'self are not virtual and will work fine no matter what your resolution is.
MAJOR UPDATE! I have added 4 new functions for the extension and updated the included assets project to reflect the new functions, they are as follows:
GetSongLength(track_Number) - gets the length in milliseconds of a requested song
GetCurrentSongLength() - gets the song length in milliseconds of the song currently playing
GetElapsedTime() - gets the time the song has been playing in milliseconds
GoToSeek(Time_In_Ms) - go to any position in the song by inputting the milliseconds

List of all of the functions in the extension (including the new ones):
PauseMusic() - pauses the music if playing
MusicStopped() - use to check if music is stopped
NumberOfTracks() - use to find number of tracks
ResumeMusic() - plays music if paused
PlayMusic(Track_Number) - play a particular song
GetCurrentSongName() - gets the currently playing song name
GetCurrentArtistName() - gets the currently playing artist name
MusicPlaying() - use to check if music is playing
NextTrack() - play the next song
PreviousTrack() - play the previous song
Init() - reset the player
GetSongName(Track_Number) - get the name of a particular song
GetArtistName(Track_Number) - get the name of a particular artist
MusicPaused() - use to check if the music is paused
StopMusic() - stop the music
GoToTrack(Track_Number) - go to a particular track, simillar to PlayMusic()
Final() - end all music and music player processes
GetSongLength(Track_Number) - gets the length in milliseconds of a requested song 
GetCurrentSongLength(Track_Number) - gets the song length in milliseconds of the song currently playing
GoToSeek(Time_In_Milliseconds) - go to any position in the song by inputting the milliseconds
GetElapsedTime() - gets the time the song has been playing in milliseconds

In the assets I added a seekbar and fixed some minor bugs in the playlist script.

Clipboard01.png
Time stamps below seek bar are total track time / track time currently played / track time in miliseconds / seek to time in milliseconds (active when dragging slider)​

Also uploaded a new apk showing the features:
GM Android Music

Enjoy and happy programming!!
Apk instructions - press Y button to bring up the music player or close it (closing it does not shut it off)
Press the Make playlist button to create a playlist, use the bottom left controller arrow buttons to move the pointer to the 'ADD' menu item, press the A button and a text box appears, type in the song NUMBER you wish to add, you can scroll through the songs list with the 2 top right arrow buttons. repeat for up to 100 songs then press the B button to exit the create playlist menu.

And here is a link to the listing on the gamemaker marketplace:

Credits:
This extension is modified and reworked with permission from GMMusic for Android by Neil from Red Line Games










Post a Comment