[TUTORIAL] Simple MP3 Player

Started by Ivan Iraola, November 27, 2009, 03:06:19 PM

Previous topic - Next topic

Ivan Iraola

** MP3 Player - Tutorial **

  Step by step guide to create a basic MP3 player.

- Requirements:

  - FireFly 3.04.
  - At least (1) MP3 file.
  - A text file containing Path and MP3 name(s) (see instructions in source code).

- Specs:

  - Format         : Project
  - Compiler       : PB9
  - GUI Designer : FireFly 3.04
  - Language     : English

NOTE: The attached file contains a little fix, it adds quotes to the MP3Name$ variable in order to prevent not playing a track when the path or name contains spaces.
Android App Developer
http://www.uncledroid.com

Haakon Birkeland

Quote
' Setup the values for volume in reverse order (because is vertical)
' the Volume control on the slider should go from 0 to 1000
' 11 values in total, YES, the volume on this player goes to 11!!!
Yes, yess...! 8o)
Haakon 8o)

Stephane Fonteyne

Dear developer,

Nice first project. But whynot do you added the source code for your current applications such I can see the GUI interface in you Euphony.exe ?

I would like to learn how FireFly SDK source code works, the controls

Thanks if you can share your source code

Stephane
Stephane Fonteyne
Ba. Elektronica - ICT
GSM : +32-xxxxxxxxxx
PowerBasic Developer & Hardware Support

Gary Stout


Ivan Iraola

Quote from: Stephane Fonteyne on November 29, 2009, 08:20:51 PM
Dear developer,

Nice first project. But whynot do you added the source code for your current applications such I can see the GUI interface in you Euphony.exe ?

I would like to learn how FireFly SDK source code works, the controls

Thanks if you can share your source code

Stephane

Of course I can share, my question is, what exactly are you looking for?, the code in this tutorial is Euphony's base code, if you need some samples about using controls, I've posted a Code Sampler on This thread.
Android App Developer
http://www.uncledroid.com

Barry Marks

I hope if it's okay to ask an MCI question here.  One of the problems I had with the little program I made based on some source I found in the PB forums about a year or two ago was that I didn't really understand how to control the volume, among other things.  I'm using your Firefly sample code to try to figure out how you did it to get my little program working better.  Basically I'm adding a trackbar for volume and I haven't used one before.

It seems like the code I'm using has the maximum volume at 1000.  I'm not sure if that's because it was that way in the code I started with or if it's something I did.  Since the default range of the trackbar is 0 to 100 I thought I'd set the volume the same way.  I think I remember there is a way to do that but I can't seem to find it.

I have the trackbar working okay and I'm using arithmetic to make up the difference in scales so there's no real problem to solve here, except that I think there should be a way to do this without the arithmetic and I'd like to know what it is.

I realize I can change the scale on the trackbar but I already know how to do that (I think) and I want to learn how to change the scale in MCI if that can be done.  Or learn that it can't be done and go from there.

Any suggestions on this will be very much appreciated.

I do realize that this isn't really a Firefly question and I hope that's okay.  If not, somebody please say something and I'll stay on the topic of Firefly more directly from now on.

Ivan Iraola

#6
I don't know if I understood you correctly, but let explain something about the volume.

On the example I set the volume like this:

MciSendString "SetAudio " + MP3Name$ + " Volume to " + Volume$, "", 0, 0

Where MP3Name$ is the file to play (e.g MySong.mp3) and Volume$ is the level (e.g. 500)

The range for volume is from 0-1000, so, if you create a Trackbar, you can set the range of it from 0 to 1000 and Small Change = 1 (do this on the FireFly Workspace, under properties of the trackbar in this example)

Once you have that setup, then you just read the value of the trackbar position and set the volume:

tPos& = FF_TrackBar_GetPos(HWND_FORM1_VOLUME) (VOLUME is the name of the trackbar in this example)

MciSendString "SetAudio " + MP3Name$ + " Volume to " + Str$(tPos&), "", 0, 0

That way, you don't have to do any arithmetic, the volume will go from 0 to 1000 and the increment will be 1, but you can change that as well, to 10 or 20 or whatever value you like.

I hope this answer your question.
Android App Developer
http://www.uncledroid.com

Barry Marks

Yep that answers my question. :)

I had thought there was a way to set the range of numbers that was used to control the volume and I couldn't find it anywhere.  I guess I just remembered wrong.

Thanks,
Barry

Stephane Fonteyne

Ivan

I would scaled my trackbar with +10dB(top) 0dB (middele) and -60dB (bottom) on the tracker.

1) How can I do this in FF3 and don't know how, can you give an example in code?

2) How can I get de value on the Trackbar en used then ?

Thanks
Stephane
Stephane Fonteyne
Ba. Elektronica - ICT
GSM : +32-xxxxxxxxxx
PowerBasic Developer & Hardware Support

Ivan Iraola

Quote from: Stephane Fonteyne on December 02, 2009, 08:17:17 PM
Ivan

I would scaled my trackbar with +10dB(top) 0dB (middele) and -60dB (bottom) on the tracker.

1) How can I do this in FF3 and don't know how, can you give an example in code?

2) How can I get de value on the Trackbar en used then ?

Thanks
Stephane
I hope this sample helps you.
Android App Developer
http://www.uncledroid.com

Stephane Fonteyne

Hi Ivan,

Thanks for sharing

Stephane
Stephane Fonteyne
Ba. Elektronica - ICT
GSM : +32-xxxxxxxxxx
PowerBasic Developer & Hardware Support