How can I have Gambas play an MP3 file?

Post

Posted
Rating:
#1 (In Topic #1591)
Avatar
Regular
Askjerry is in the usergroup ‘Regular’
 There are times when a button is pressed, or a process finishes that I would like to play an MP3 file.

How can I do this?
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

Askjerry said

How can I do this?
Step 1: Add component gb.sdl2.audio to your project
Step 2: In code do something like:

Code (gambas)

  1.     Music.Load("/path/to/soundfile.mp3")
  2.     Music.Play
  3.  
"/path/to/soundfile.mp3" is the full path to the mp3 to play.

If you want to keep the mp3 inside you project as a sound file for example, make sure to place it in Data folder (in IDE project browser that is). You could make a sub folder in de Data folder named sounds to place all sound files. The above path in code would then be "sounds/nameof.mp3" and the files will be part of the executable or package (if making one).

More on Music: https://gambaswiki.org…/comp/gb.sdl2.audio/music

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’

Askjerry said

There are times when a button is pressed, or a process finishes that I would like to play an MP3 file.

How can I do this?

With the new gambas forum and website?
I don't think you can.   ;)

If you mean with gambas in general then gbWilly has the answer but your question is in the wrong forum place. New Gambas One Forum and Website / Comments, questions, and discussions
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

BruceSteers said

If you mean with gambas in general then gbWilly has the answer but your question is in the wrong forum place. New Gambas One Forum and Website / Comments, questions, and discussions
:lol: , good one.
I moved the topic, so we're good now

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top
1 guest and 0 members have just viewed this.