Playing MP3 music files

Just starting out? Need help? Post your questions and find answers here.
MikeB
Enthusiast
Enthusiast
Posts: 183
Joined: Sun Apr 27, 2003 8:39 pm
Location: Cornwall UK

Playing MP3 music files

Post by MikeB »

I sometimes want to play a music file (often speech) while a program is running. I have usually used .wav files which is simple enough using a thread or to play once, using a separate program started with run program. However to cut down on file size and speed the loading I would like to use MP3 files as I already have them. The question is can PB play these without using the Mci() command to pass strings, this works but I don't like doing it this way. I can use Ogg Varbis, which is as easy as .wav (using UseOGGSoundDecoder()) but this means making another file just for this as I don't think I have anything else that can play .Ogg files.
Mike.
(I'm never going to catch up with the improvements to this program)
dioxin
User
User
Posts: 97
Joined: Thu May 11, 2006 9:53 pm

Post by dioxin »

Mike,
<< this works but I don't like doing it this way>>

Why not? It's simple and it works, what more could you want?

Paul.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

It's not cross-platform.
MikeB
Enthusiast
Enthusiast
Posts: 183
Joined: Sun Apr 27, 2003 8:39 pm
Location: Cornwall UK

Post by MikeB »

There is a good reason why I don't like doing it using Mci(), I have copied the relevant bits from a player by Dominique Bodin and it works, but I don't have a clue as to what is happening and can't find any reference to it anywhere else. :?

On the other hand quite a lot of my programs have bits that work without my knowing how! :lol:
Mike.
(I'm never going to catch up with the improvements to this program)
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

Use the built in Movie library, playMovie().., or a webgadget if you can live with loop, or << >>. ? :)
josku_x
Addict
Addict
Posts: 997
Joined: Sat Sep 24, 2005 2:08 pm

Post by josku_x »

yeah, a good idea is to use the movie library, because it supports MPEG videos, and MP3 is just a variation of MPEG. So it should work, shouldn't it?
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

http://msdn.microsoft.com/library/defau ... 2_open.asp
Look here for all the information you'll need on MCI strings!

And this page is also very good:
http://www.geocities.com/smigman.geo/mci/mci.html

Code: Select all

If mciSendString_("OPEN "+#DQUOTE$+File+#DQUOTE$+" ALIAS Media",0,0,0)=0
  mciSendString_("PLAY Media",0,0,0)
  Delay(5000)
  mciSendString_("STOP Media",0,0,0)
  mciSendString_("CLOSE Media",0,0,0)
Else
  ;error
EndIf
I'm making a MCI media player, it's fun!
josku_x
Addict
Addict
Posts: 997
Joined: Sat Sep 24, 2005 2:08 pm

Post by josku_x »

I have done one 2 years ago, it's really simple, but sometimes just not so fleixble and efficient. I ended up using FMOD and a simple wrapper I made myself.
MikeB
Enthusiast
Enthusiast
Posts: 183
Joined: Sun Apr 27, 2003 8:39 pm
Location: Cornwall UK

Post by MikeB »

Thanks utopiomania,
Have just tried using the movie commands and it works a treat, also alleviates the need to use a thread to run asynchronously. :D
Mike.
(I'm never going to catch up with the improvements to this program)
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Post by Baldrick »

MikeB,
Don't know if this may be of any use for you, but I made a little Mp3 lib up a while ago based around simple use of Mcistrings. I havent looked at updating it for V4 yet though.
If you don't want to use it as a user lib with PB, I have included the source in the download which you may find usefull to help teach yourself how Mci works.
Lib, helpfile and source can be downloaded from here for PB 3.94 - http://www.purearea.net/pb/download/userlibs/DeMp3.zip
MikeB
Enthusiast
Enthusiast
Posts: 183
Joined: Sun Apr 27, 2003 8:39 pm
Location: Cornwall UK

Post by MikeB »

Thanks Baldrick, actually your userlib is one of the things I had downloaded in my initial search for a method of playing MP3s. I tried it (using PB V4) and got a string of linker errors. I saw that it was for PB 3.94 and assumed that was the reason and went on to try alternative methods. To convert for V4 seems to me to be just a matter of changing the variables to pointers for the PeekS() commands but I have never tried making a library so apart from not knowing how to do it, I might well be talking piffle. I must have a look at how to make a library when I have time, so far I have seen in the PB help file about making .dll files, but that is not the same and as far as I can see makes the calls more complicated instead of easier. :?
Mike.
(I'm never going to catch up with the improvements to this program)
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Post by Baldrick »

Yes,
The pointers are pretty much all there is, I have not bothered at this stage as I decided better to wait until V4 is stable before I put Tailbite back in, etc.
All I need is a little motivation & I will probably update it soon.
Meanwhile, the source with the lib might be helpfull to you as copy , paste & modify directly into your code.
DominiqueB
Enthusiast
Enthusiast
Posts: 103
Joined: Fri Apr 25, 2003 4:00 pm
Location: France

Hi MikeB

Post by DominiqueB »

I've read your post.
Do you mean you don't have the code for my player ?
If anyone needs it i can send it for free . . .

Just ask with your e-mail adress cause i've no way to post it anywhere else.

Dominique
Dominique

Windows 10 64bits. Pure basic 32bits
MikeB
Enthusiast
Enthusiast
Posts: 183
Joined: Sun Apr 27, 2003 8:39 pm
Location: Cornwall UK

Post by MikeB »

DominiqueB, I downloaded your player and it works fine as a player, but what I have done as well as keeping it in the original form as a player, is to take just the bits I needed to play one particular MP3 file in the background of another program. For the purpose I only need to load the file, play it and detect when it is finished so I didn't need the whole thing.
:D
Mike.
(I'm never going to catch up with the improvements to this program)
Post Reply