Oh, snap. I was too slow.
And here I was so giddy with my success.
Hey man I made my own solution for your problem. Of course, credit for the idea goes to Ocelot. I just patched together a few code snippets. You are free to use it if you want...
Code:
Code: Select all
default pauseddict = {}
init python:
def _insert(name, time):
store.pauseddict[name] = time
def fading_pause(channel = "music", pause = "toggle", fade = None, filename = None):
if pause == "toggle":
pause = renpy.music.get_playing(channel)
if pause:
_insert(renpy.music.get_playing(), renpy.music.get_pos())
renpy.music.stop(channel, fade)
else:
if filename == None:
name, time = store.pauseddict.popitem()
else:
name, time = store.pauseddict.pop(filename)
fn = "<from {}>".format(time) + name
renpy.music.play(fn, channel, fadein = fade)
Installation:
Paste the code at the top of your script file.
Use:
Code: Select all
label start:
"Start"
play music "music.mp3"
"Click to pause."
$ fading_pause()
"Click to unpause."
$ fading_pause()
"End"
return
And here's the beauty of it. You can pass a number of arguments to the fading_pause function...
You can specify the channel, pause, and fade time, and a filename.
Code: Select all
$ fading_pause(channel = "music", pause = True, fade = 1.0, filename = "Song.mp3")
Or, any one of them.
Or you could even use it as in my example, without any arguments.
The default behavior uses the music channel, if it's playing it pauses, if it isn't playing it starts playing, and fading is disabled, if you provide a filename it will resume playing that particular song.
It can not only fade out when you pause but fade in when you unpause.
You can, in theory even pause multiple files then unpause them.
Now this isn't entirely foolproof, but if you don't try anything crazy you shouldn't run into any problems.