How to play mp3 file?

Just starting out? Need help? Post your questions and find answers here.
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

How to play mp3 file?

Post by SkyManager »

Any library or example?
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: How to play mp3 file?

Post by JHPJHP »

Hi SkyManager,

A simple solution (depending on your requirements) is using the WebGadget: HTML Audio
- see the following for similar working examples
-- MP4 Player
-- YouTube Player
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: How to play mp3 file?

Post by falsam »

Another solution : FModex (Unicode) PB 5.60 (x86 & x64)
:arrow: https://github.com/pbcodex/FMODEX-MIN-UNICODE

Try Fmod Ex - Play Sound.pb

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4664
Joined: Sun Apr 12, 2009 6:27 am

Re: How to play mp3 file?

Post by RASHAD »

Simple and straightforward

Code: Select all

If InitMovie() = 0
  MessageRequester("Error", "Can't initialize movie playback !", 0) 
  End
EndIf

MovieName$ = OpenFileRequester("Choose the movie to play", "", "All Files|*.*", 0)
If MovieName$
  If LoadMovie(0, MovieName$)
  
    OpenWindow(0, 100, 150, MovieWidth(0), MovieHeight(0), "PureBasic - Movie")
    PlayMovie(0, WindowID(0))
      
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
  Else
    MessageRequester("Error", "Can't load the movie...", 0)
  EndIf
EndIf 
Egypt my love
firace
Addict
Addict
Posts: 903
Joined: Wed Nov 09, 2011 8:58 am

Re: How to play mp3 file?

Post by firace »

Tiny solution (on Windows):

Code: Select all


sfile.s = "C:\song.mp3"
mciSendString_("open " + sFile + " alias 1", 0, 0, 0) 
mciSendString_("play 1 wait", 0, 0, 0);

Cyllceaux
Enthusiast
Enthusiast
Posts: 469
Joined: Mon Jun 23, 2014 1:18 pm
Contact:

Re: How to play mp3 file?

Post by Cyllceaux »

firace wrote:Tiny solution (on Windows):

Code: Select all


sfile.s = "C:\song.mp3"
mciSendString_("open " + sFile + " alias 1", 0, 0, 0) 
mciSendString_("play 1 wait", 0, 0, 0);

Thats what I was looking for
Post Reply