Computer Science Canada Music Player Help |
| Author: | Inuspal [ Fri Jan 02, 2009 11:38 pm ] |
| Post subject: | Music Player Help |
I'm currently doing a culminating task for my grade 10 science course, I'm making a music player with Turing. I did some searching on the forum and got some neat ideas. I tried doing a file search and I saw some hints for it in the forum which I tried using, but my problem is, I can't get my program to actually search for file names with a .mp3/.wav/.midi extension, and then display them on the program. I realize the usage of arrays is needed but I'm horrible with those (I've tried learning them several times before, I barely understand the concept). could someone please help me out with this? |
|
| Author: | The_Bean [ Fri Jan 02, 2009 11:58 pm ] |
| Post subject: | Re: Music Player Help |
Look up Dir.Open and Dir.Get in the turing help files (F10). From that use some string manipulation to see if they are the correct file type. Use a flexible array to store them if they are the correct format. |
|
| Author: | petree08 [ Sat Jan 03, 2009 9:50 am ] |
| Post subject: | RE:Music Player Help |
If your searching method is to include subfolders then you might want to have a look at recursion, |
|
| Author: | B-Man 31 [ Sat Jan 03, 2009 1:11 pm ] |
| Post subject: | Re: Music Player Help |
i tried making a music player, and i got the player to open and play files but you cant do much more than that. you cant ghange volume and only thing you could maybe add is a play list and play/stop buttons. |
|
| Author: | Inuspal [ Sun Jan 04, 2009 10:32 am ] |
| Post subject: | RE:Music Player Help |
Thanks for the help, and now I got the file names to come up on the program, but my problems now are: I got some .jpg files (album artwork) and I'm not sure how to limit it to just .mp3, .wav, and .midi files? Also, for the user to select the song, do I need to use GUI? If so, how can I make each and every song clickable? |
|
| Author: | andrew. [ Sun Jan 04, 2009 11:51 am ] |
| Post subject: | RE:Music Player Help |
To limit it to mp3, wav, and midi, just check each filename to see if the ending is .mp3, .wav, etc. No, you don't need to use the GUI. I highly recommend not using the GUI. Instead read up on Mouse.Where. Off-topic: In Java, we're using some source code someone already came up with to read wav files into an array to be played. We are able to reverse it, add echoes, speed it up, slow it down, etc. I suppose we can change the volume. Do you think there is a way to load wav files into Turing into an array? I highly doubt it, but you never know. |
|
| Author: | Euphoracle [ Sun Jan 04, 2009 11:56 am ] |
| Post subject: | RE:Music Player Help |
No there isn't, it provides no methods of doing so. Turing can only use its built-in procedures for playing sound, iirc. |
|
| Author: | Inuspal [ Sun Jan 04, 2009 1:19 pm ] |
| Post subject: | RE:Music Player Help |
I don't understand how to get Turing to check the filename endings...can someone please expand on that? |
|
| Author: | The_Bean [ Sun Jan 04, 2009 1:50 pm ] | ||||
| Post subject: | Re: Music Player Help | ||||
You'll need to check the last 4 or 5 characters to see if they're '.mp3' or '.wav' or '.midi'. Since every name will have a different length you'll need to make it in relation to the total length of the string. length() To check certain characters in a string you can call the string with parameters like an array but with a range.
Now to make it in relation to the max length of the string
|
|||||
| Author: | Inuspal [ Sun Jan 04, 2009 2:14 pm ] | ||
| Post subject: | Re: Music Player Help | ||
Oh thanks for the tip I tried it out, this is what it looks like
but I'm getting errors... :/ it's telling me "Operands of comparison and operators must be the same type" |
|||
| Author: | The_Bean [ Sun Jan 04, 2009 2:37 pm ] |
| Post subject: | Re: Music Player Help |
(length (fileName) - 4) is just a number and ".mp3" is a string. Look at my post again and see how it works. |
|
| Author: | Inuspal [ Sun Jan 04, 2009 2:58 pm ] | ||
| Post subject: | Re: Music Player Help | ||
This is rather confusing for me, I apologize for sounding like a total n00b, I suck at Turing, but I'm not trying to do the same thing you did in your post though... I just want my program to display all the files that end in .mp3/.wav/.midi every time I try it and change parts of it, I get a different error here's what I just tried recently:
|
|||
| Author: | The_Bean [ Sun Jan 04, 2009 3:39 pm ] |
| Post subject: | Re: Music Player Help |
I know what you're trying to do, I was just showing how to get the last characters to check. 1) Why are you using Dir.Open() twice with the same folder? 2) fileName (length (fileName) - 4 .. length (fileName)) --- will give more characters than you want, you only want the last four so its like starting counting with 0 you will end with 1 extra than you want (subtract only 3) 3) Move the exit when to above the if statement 4) The first files in a windows folder are "." and ".." so they have less than 4 and will get a negative string subscript. So you need to make sure that the name length of file is greater than 4 first. |
|
| Author: | Inuspal [ Sun Jan 04, 2009 5:22 pm ] |
| Post subject: | RE:Music Player Help |
Yaay it worked! Thankyou very much, The_Bean, you're very helpful =D ...And now I've stumbled upon more problems @_@ does it ever end? 1) I can't get the darn scrollbar to work 2) I have no idea how to make it so that I can select song names with a mouse and play them, since it's recommended I don't use GUI like huh D: |
|
| Author: | Insectoid [ Sun Jan 04, 2009 8:09 pm ] |
| Post subject: | RE:Music Player Help |
Make your own buttons with Draw.Box and Mouse.Where using ordinary collision detection. If the user clicks the button with this name on it, play that music file. elsif he clicks that button, do that one. If he clicks 'stop', Music.PlayFileStop. That easy. Scroll bar might be a bit complicated. |
|
| Author: | Inuspal [ Sun Jan 04, 2009 8:52 pm ] |
| Post subject: | RE:Music Player Help |
May I ask what ordinary collision detection is? Also, I'm trying to make a sort of "startup" image, and I don't understand why its not working. the filename and everything is correct; I've checked it over countless times, and it won't work. (the file type is compatible as well) Could it have something to do with the file size, or any other attributes of the picture? |
|
| Author: | DarkRider [ Sun Jan 04, 2009 9:37 pm ] |
| Post subject: | Re: RE:Music Player Help |
Inuspal @ Sun Jan 04, 2009 8:52 pm wrote: May I ask what ordinary collision detection is?
Also, I'm trying to make a sort of "startup" image, and I don't understand why its not working. the filename and everything is correct; I've checked it over countless times, and it won't work. (the file type is compatible as well) Could it have something to do with the file size, or any other attributes of the picture? Collision detection is when you check the coordinates of one object against another object and determine if they intercept each other. As for the rest of your questions I can't really help because I don't know what your code looks like for those specific parts. Could you possibly post your code? |
|
| Author: | Inuspal [ Sun Jan 04, 2009 9:39 pm ] | ||
| Post subject: | RE:Music Player Help | ||
Ah I see. I don't see what the interception of objects would do for my scroll bar though XD Oh right, silly me, I should have posted the code:
|
|||
| Author: | The_Bean [ Sun Jan 04, 2009 9:42 pm ] | ||
| Post subject: | Re: Music Player Help | ||
Ordinary Collision detection:
Your pictures not showing because the coordinates maxx, maxy are the top right corner so its off the screen use 0,0 You would almost need something with a scroll bar though, because some people do have a couple hundred songs in there music folder. |
|||
| Author: | DarkRider [ Sun Jan 04, 2009 9:46 pm ] |
| Post subject: | RE:Music Player Help |
An object is just a fancy way of saying "thing." You can check circles, boxes, dots, sprites, anything... So for the case of a scroll bar you are checking boxes (or graphics) against a mouse pointer to see if they are touching each other (not really needed if you are using Turings scroll bar though). Anyways you are drawing the picture at coordinates (maxx, maxy) which will render your image outside of your window ((maxx, maxy) being the upper right-hand corner of your window). You should be drawing it at coordinates within the screen, say (100, 100). |
|
| Author: | Inuspal [ Sun Jan 04, 2009 9:54 pm ] |
| Post subject: | RE:Music Player Help |
Oh my gosh, that was the stupidest mistake I have ever made. I don't know why I mixed it up with HTML thinking I had to put the image size. Anywho, does it matter what values I put in for the collision detection variables?? |
|