- May 13, 2018
- 1,341
- 2,485
Hi Friends,
I am trying to set up ren'py to play an audio file, and have a progress bar showing elapsed time, and time remaining using a colored png.
I have this kind of working but there are a couple of things I can't figure out, and was hoping to get your help
So as you can see it is playing the file, and displaying how much of the file has already been listened to.
Here is the code for the screens:
and this is the code for the script
There are a couple of things I would like to do, and one that I really need to do. As you can see from the screenshot, once we jump to Dark, it runs the audio and shows the duration bar, but then it immediately executes the end routine too
1. I really need to delay this until the audio file has stopped. I only put this in because I realized I didn't have full control over the audio file yet
2. The second thing I would like to be able to do is to grab the remaining duration of the file in seconds and assign this value to a variable that I could then display on the screen alongside the progress bar and this number would also change as the file plays through, probably as time already elapsed. The audio files I plan on using are very long files so it would be helpful for the people who will use this game to see how much time in total it will take to listen to all the files, and how much time has already elapsed in the current file
I have really tried to find this info myself and have tried all sorts of things, but I am at the very beginning of learning ren'py so basically, I have no idea how to do it. I experimented with capturing the duration and assigning that duration to a variable , but was getting a 0.0 value so I am probably not doing it right
renpy.music.get_duration(channel=u'music') is what I was trying to use
Can some kind soul please help explain what I should be doing? And remember please, a complicated answer will likely confuse me so keep it simple if you can!
I am trying to set up ren'py to play an audio file, and have a progress bar showing elapsed time, and time remaining using a colored png.
I have this kind of working but there are a couple of things I can't figure out, and was hoping to get your help
So as you can see it is playing the file, and displaying how much of the file has already been listened to.
Here is the code for the screens:
Code:
screen audio_duration():
bar:
value AudioPositionValue(channel='music',update_interval=0.1)
xalign 0.5
yalign 0.5
xsize 500
xmaximum 500
Code:
define Dark = "audio/dark.ogg"
image BG peach="bg peach.jpg"
## Start
label start:
scene BG peach with dissolve
jump Dark
label Dark:
play music Dark noloop
#$ x=renpy.music.get_duration(channel=u'music')
show screen audio_duration
label end:
"Goodbye"
return
There are a couple of things I would like to do, and one that I really need to do. As you can see from the screenshot, once we jump to Dark, it runs the audio and shows the duration bar, but then it immediately executes the end routine too
1. I really need to delay this until the audio file has stopped. I only put this in because I realized I didn't have full control over the audio file yet
2. The second thing I would like to be able to do is to grab the remaining duration of the file in seconds and assign this value to a variable that I could then display on the screen alongside the progress bar and this number would also change as the file plays through, probably as time already elapsed. The audio files I plan on using are very long files so it would be helpful for the people who will use this game to see how much time in total it will take to listen to all the files, and how much time has already elapsed in the current file
I have really tried to find this info myself and have tried all sorts of things, but I am at the very beginning of learning ren'py so basically, I have no idea how to do it. I experimented with capturing the duration and assigning that duration to a variable , but was getting a 0.0 value so I am probably not doing it right
renpy.music.get_duration(channel=u'music') is what I was trying to use
Can some kind soul please help explain what I should be doing? And remember please, a complicated answer will likely confuse me so keep it simple if you can!
Last edited: