Computer Science Canada Display .mp3 names in GUI.CreateTextboxChoice |
Author: | Musta [ Wed Jan 16, 2013 8:00 pm ] |
Post subject: | Display .mp3 names in GUI.CreateTextboxChoice |
What is it you are trying to achieve? <Importing Sound files and displaying their names in GUI> What is the problem you are having? <Confusion inside of my brain.> Describe what you have tried to solve this problem <Attempting to read help files, didn't help> Please specify what version of Turing you are using <4.0.5> I'm doing a final project, my intentions are to use a GUI.CreateTextBoxChoice to display a list of songs that are placed in the program's saved location. So somebody puts a song with the filename "Xsong.mp3", and in the GUI's scroll list shows a file called "Xsong.mp3". Clicking the song plays it, all songs will be of same format so that they cancel each other. I could probably figure out how to make people pick from a selection of songs, but I would like it so that the user can use their own songs. I just need to know if it's possible in Turing to do this. If you don't think it would work with GUI.CreateTextBoxChoice (Because I myself have doubts), please say how I could get this to work. GUI was one of the few things we didn't learn how to do, so that's why I'm asking here Thanks |
Author: | Insectoid [ Wed Jan 16, 2013 9:37 pm ] |
Post subject: | RE:Display .mp3 names in GUI.CreateTextboxChoice |
What you could do is keep a text file that contains the names and paths to all the songs. When you run the program, read in all the songs from this file. If the user wants to add a song, have the program add it to the file. |
Author: | Musta [ Wed Jan 16, 2013 10:09 pm ] |
Post subject: | Re: RE:Display .mp3 names in GUI.CreateTextboxChoice |
Insectoid @ Wed Jan 16, 2013 9:37 pm wrote: What you could do is keep a text file that contains the names and paths to all the songs. When you run the program, read in all the songs from this file. If the user wants to add a song, have the program add it to the file.
I see... that makes sense. I'm assuming... when you first run the program it checks the directory for .mp3 files (Not sure how you would go about doing that), then saves the names into a text file that can be read later... This just got more confusing now |
Author: | evildaddy911 [ Thu Jan 17, 2013 12:14 am ] |
Post subject: | RE:Display .mp3 names in GUI.CreateTextboxChoice |
I think he means that you manually create the txt file, but the program adds the filename youve entered to the txt file. Scanning the folder for .mp3 files is pretty advanced, so I suggest you drop the file scanning and use this basic outline: - read .txt: .mp3 filenames - add or play? - if add, get new filename -- add to .txt file - if play, use the textBoxChoice setup |
Author: | Dreadnought [ Thu Jan 17, 2013 12:10 pm ] |
Post subject: | Re: Display .mp3 names in GUI.CreateTextboxChoice |
The dirmodule likely has something that can help read file names in a directory. |
Author: | Musta [ Thu Jan 17, 2013 8:29 pm ] | ||
Post subject: | Re: Display .mp3 names in GUI.CreateTextboxChoice | ||
You have all been helpful. Here is what I have right now, it works but I need some advice, or something. (I'm sure there's a lot of useless lines in there, a result of experimenting)
(Put sound file in same directory as saved example then just run) How would I go about having an if statement, that would use string manipulation to determine if a line in the text file it reads ends with .mp3? I have it so that it reads from the text file and (used to) skip a few items that weren't songs (hence the for loop "w" starting at 3 and going to x-3). Now with a ton of songs it doesn't skip them properly, so I'll have to use an if statement or something to only show them on the screen if it ends in .mp3, or at least a 3 using an *. |
Author: | Tony [ Thu Jan 17, 2013 8:40 pm ] |
Post subject: | RE:Display .mp3 names in GUI.CreateTextboxChoice |
you can select just a part of a string. substring |
Author: | Musta [ Thu Jan 17, 2013 9:05 pm ] | ||
Post subject: | Re: RE:Display .mp3 names in GUI.CreateTextboxChoice | ||
Tony @ Thu Jan 17, 2013 8:40 pm wrote: you can select just a part of a string. substring
But how would I even use that in an if statement?
* being last, *-2 being the last three, equaling "mp3", sounds like it works, just doesn't. I don't know how to do this properly. Edit: Durr, put the things backwards. Still doesn't work though. |
Author: | Tony [ Thu Jan 17, 2013 9:32 pm ] | ||
Post subject: | RE:Display .mp3 names in GUI.CreateTextboxChoice | ||
what is it actually though?
|
Author: | Musta [ Thu Jan 17, 2013 9:41 pm ] | ||
Post subject: | Re: RE:Display .mp3 names in GUI.CreateTextboxChoice | ||
Tony @ Thu Jan 17, 2013 9:32 pm wrote: what is it actually though?
I scan the directory and save all of the files onto a text file. Then I open the text file and display all of the objects on the screen, allowing the user to see the choices they can select. This part right here is the "put" part, "adder" is an array, "adder(1)" is line 1 in the text file, "adder(2)" is line 2 etc. So instead of putting every line (Which includes the program's name itself, the text file's name etc.), I'm trying to get it to only put files that end in "mp3" on the screen. That "Not MP3" part works I guess, but it would be nice to just not show them at all |
Author: | Tony [ Fri Jan 18, 2013 1:39 pm ] |
Post subject: | RE:Display .mp3 names in GUI.CreateTextboxChoice |
The "not mp3" line is just a placeholder for understanding what your program is actually doing. |
Author: | Musta [ Fri Jan 18, 2013 3:00 pm ] |
Post subject: | Re: RE:Display .mp3 names in GUI.CreateTextboxChoice |
Tony @ Fri Jan 18, 2013 1:39 pm wrote: The "not mp3" line is just a placeholder for understanding what your program is actually doing.
I spent some more time on it today and got it working 100% perfectly, I am happy. Thanks for the help everybody, the Dir module really helped. Even my teacher didn't know what it was lol |