[solved] use mp3 files from folder?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
ironk
Newbie
Posts: 6
Joined: Tue Oct 09, 2018 4:17 am
Contact:

[solved] use mp3 files from folder?

#1 Post by ironk » Thu Dec 19, 2019 11:34 am

Creating an mp3 player with a screen is not difficult. you take the picture, give the buttons the desired function and that's it.
But how can I set it up that I don't need a playlist, just play all mp3 files from a folder? I don't care about order.
I want to be able to drop in or remove songs without rewritig the code all the time.
Last edited by ironk on Fri Dec 27, 2019 3:20 pm, edited 5 times in total.

User avatar
namastaii
Eileen-Class Veteran
Posts: 1310
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: deadseed
itch: lunalucid
Location: USA
Contact:

Re: Help- How to: - use files from folder?- assign several variables?

#2 Post by namastaii » Fri Dec 20, 2019 2:05 pm

So, I think the most uncomplicated way to play a list of songs from a folder without doing much else would be to name all of the mp3 files the same thing and add a number at the end of it, have a code that iterates through those (song_1.mp3, song_2.mp3) and attach a variable so it's playing song_[variablehere].mp3, but you would need another variable for the number of songs in that folder so you don't run into an error when it tries to find song_12 but you only have 11 songs, then have it go back to song_1 (or song_0 depending on how you do it) if that makes sense. This is untested but it's the most straightforward way I can think of.
You did say you'd like to drop songs in without rewriting code and I'm not sure if there's a way to do that 100% but renaming your mp3 to be routine for the code to find and just updating the variable that holds the total number of songs in the folder would work.

ironk
Newbie
Posts: 6
Joined: Tue Oct 09, 2018 4:17 am
Contact:

Re: Help- How to: - use files from folder?- assign several variables?

#3 Post by ironk » Fri Dec 27, 2019 2:40 pm

ok, i stick to a song list. If I take version 2 and rename the songs to "song1" etc. the exchange is difficult.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 2850
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: [solved] use mp3 files from folder?

#4 Post by Imperf3kt » Fri Dec 27, 2019 4:30 pm

There is one user before you who had the exact same idea and a working solution was given at the time.

I am afraid I cannot find a link, but if you search around the forum you might find an answer.
IIRC, this was about three years ago.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Twitter

Post Reply

Who is online

Users browsing this forum: Adrian_DVL, beastcarving, cdstar99, Google [Bot], noeinan, trooper6