Re-playing music from start?

Monkey Forums/Monkey Programming/Re-playing music from start?

SLotman(Posted 2015) [#1]
This may be a silly question but...

I want to be able to play my music, from start, every time my game begins, and I don't want to reload the audio file every time.

Calling a ResumeMusic() after StopMusic() won't work. And I couldn't find anyway to "rewind" the current music to position 0.

Is there any hope? Or will I have to hack into every target to be able to do this?


rIKmAN(Posted 2015) [#2]
Just call PlayMusic() again and it will play from the start - or am I missing something?

PlayMusic streams the audio, so it isn't loading the whole file into memory every time like you do when you use LoadSound().


Soap(Posted 2015) [#3]
If it streams or not depends on target. Pretty sure GLFW doesn't stream the file and instead loads it all in at once. Different filetypes are handled differently too.


SLotman(Posted 2015) [#4]
Just call PlayMusic() again and it will play from the start - or am I missing something?

Hmmm? Here I always need to pass a file. Calling PlayMusic() (without any parameters) just complains about not being able to find an overload method.

PlayMusic(file) will always try to load the music again. Unless the target streams

And calling ResumeMusic() after StopMusic does nothing.


rIKmAN(Posted 2015) [#5]
Sorry SLotman, I didn't mean that "PlayMusic()" literally - I just didn't put any parameters so as not to confuse things (multiple targets/filetypes etc) but of course you would use the path to your music file in there yes.

Thanks for the tips Soap - I guess I have been lucky to use targets that don't give me any problems with regards to music, and I have quite a few music files that are played repeatedly in menus/game etc and have never had to think any more about it.

Have you tried looking if anyone has converted something like FMod to Monkey, or maybe converting one of the BMax audio modules over that would allow you to have skip functionality?


SLotman(Posted 2016) [#6]
1 year and this is still an issue :(

Once again, I want to change music mid-game (for a power-up) and If I just use "loadmusic" there is a big "stop" (1-2s) in the gameplay before the new song starts on GLFW2. Don't know if this is fixed in GLFW3, but it's annoying as hell :(

Having a "rewind" command (which would actually reset the stream) would be nice :/