Pause background music to play again later?
in
Core Library Questions
•
5 months ago
I'm making a game in processing that has different background music in different scenes, and am using the minim library for AudioPlayer.
Currently, what I'm doing is importing/opening both audio files in my setup() function, calling player1.play() when the user triggers that scene, then when the user triggers the next scene, I call player1.close() and player2.play() to stop the first song and play the second one, and then player2.close() when that scene ends to stop the music.
Of course, if I want the user to be able to run this music again because he's playing the game through a second time, that's an issue because I've closed player1 and player2 and it causes a NullPointerException.
Is there a function/method for the audio player that allows me to temporarily stop/pause the background music from playing so that I can .play() it again later?
1