[SOLVED] Make the music run Once in Title Screen

Hey

Do you guys remember in old games when you just start and get in the title screen, a catchy and short music runs, with "press start" blinking on the screen, and when the music ends, the music doesn't replay until you actually press start and start a new game ?

I tried to do this on RPGMV. I thought it was as easy as calling AudioManager.playMe instead of playTitleMusic. But I ran into a problem.

The music plays once. Just fine. But when I get into the options (using Yanfly's Option Core) or going into the load screen, if I go back to the main menu, the music starts again. I wouldn't mind if my jingle was very short like "*DODON* SUPER MAGIC FIGHTERS 2" but my title menu screen is actually a short music and it feels weird when it starts again

My question is : Can I somehow put a condition like "If the player is coming from Scene_File, don't play the ME" ?

EDIT : I set a global variable in Scene_Boot and I set it to 1 after the ME starts (so I can put a condition to check if the ME already started). And I set it back to 0 when the player starts a new game or loads a file, so the ME can still play again when the game returns to title via Menu screen or event

Is that a clean solution or are there any risk of bug with this method ?
@belatucadrus If you are interested, I recently updated an ancient plugin to allow a BGM, BGS, ME, or SE to be played instead of the standard title screen music: Any Title Music
That's awesome ! I'll try this out
@belatucadrus Let me know if it works out for you!
Tried it in a new project, and it doesn't work :/
@belatucadrus Hmm, could you press F8 while in the game and copy-paste any error messages from the debug console?
Here's what I get :

Code:
Uncaught ReferenceError: /D:/Onexora/BT/gja/Project3/js/plugins/Ossra_Scene-AnyTitleMusic.js:213 
Invalid left-hand side in assignment
@belatucadrus Aah, you're using an older version. I have updated the plugin. Hopefully this should work: Any Title Music
Now i'm getting this error in console :

Code:
TypeError: Cannot read property 'name' of undefined
    at Scene_Title.$.playTitleMusic (/D:/Onexora/BT/gja/Project3/js/plugins/Ossra_Scene-AnyTitleMusic.js:311)
    at Scene_Title.start (rpg_scenes.js:448)
    at Function.SceneManager.updateScene (rpg_managers.js:2019)
    at Function.SceneManager.updateMain (rpg_managers.js:1983)
    at Function.SceneManager.update (rpg_managers.js:1907)
@belatucadrus Oop, I made a bit of a programming mistake. Download the plugin again and give that a try.
Thank you, it works now ! 👍

However, like I said in my original post, the music replays when you go in options (or the load window) and then go back to the title. Thing that I doesn't want

If you haven't shared your plugin in the forum, I suggest you to do so, it would help many people struggling to have some jingle in the title screen and not a full looping music !

I think I'll stick with the global variable method as long as no bug is showing🙂
@belatucadrus Updated the plugin to version 1.09 to include a 'Play Conditional' option. For what you want, enter the following :

Code:
SceneManager._previousClass !== Scene_Options && SceneManager._previousClass !== Scene_Load

That should keep the audio file from playing when you return to the title screen from the options menu.
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/solved-make-the-music-run-once-in-title-screen.115604/