Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Code sample on how to add Mp3 support using mpg123  (Read 14907 times)

0 Members and 1 Guest are viewing this topic.

cptn ndongo

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Code sample on how to add Mp3 support using mpg123
« on: August 25, 2015, 04:23:11 pm »
Hello!

I wrote a small program which reads from Mp3 files and plays them. View it on github here: https://github.com/hansiC/sfml-soundfileReader-example

I based it mostly on an example I found in the wiki or on the sfml homepage some time ago. The original example directly subclassed sf::Music and implemented the mp3 support in that class. The downside to this approach is that you lose support for the natively supported formats,  wav, ogg and flac.

The prefered way is to subclass sf::SoundFileReader and register it using the static template function sf::SoundFileFactory::registerReader().

So this is what my code example demonstrates. I thought it might be a good addition to the wiki or the code examples on the homepage. Feel free to use any code from my repository.

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Code sample on how to add Mp3 support using mpg123
« Reply #1 on: August 25, 2015, 05:15:47 pm »
Hi  :)
Did you actually add it to the Wiki? You should post a link here to its page  ;)

I based it mostly on an example I found in the wiki or on the sfml homepage some time ago.
Maybe you mean this one:
https://github.com/SFML/SFML/wiki/Source:-MP3-Player
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

cptn ndongo

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Code sample on how to add Mp3 support using mpg123
« Reply #2 on: August 25, 2015, 05:32:45 pm »
Yes, that's the example I meant.
So how do I add stuff to the wiki? Do I have to commit the example to the sfml github repo? Or should I simply copy an existing wiki page and edit my stuff in?

EDIT: I created a wiki page here: https://github.com/SFML/SFML/wiki/Mp3-Soundfile-Reader

How do I add it to the main page at: https://github.com/SFML/SFML/wiki/Sources ?

EDIT 2: I'm sorry, I did it wrong. I clicked Create New Page on the wiki and now my wiki page is not tagged as source and is listed as a normal page in the main overview to the right at wiki. How can I create a wiki page as a source so I can link to it on the sources page?
« Last Edit: August 25, 2015, 05:58:27 pm by cptn ndongo »

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Code sample on how to add Mp3 support using mpg123
« Reply #3 on: August 25, 2015, 06:04:02 pm »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

cptn ndongo

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Code sample on how to add Mp3 support using mpg123
« Reply #4 on: August 25, 2015, 06:14:16 pm »
Thank you! The page is now up at: https://github.com/SFML/SFML/wiki/Mp3-Soundfile-Reader

NOTE: The page is now also listed as the 3rd item in the navigation box to the right. It is also listed correctly with a source tag below. However, the first entry should probably be removed.
« Last Edit: August 25, 2015, 06:30:19 pm by cptn ndongo »

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Code sample on how to add Mp3 support using mpg123
« Reply #5 on: August 25, 2015, 06:38:48 pm »
It looks like you've modified it further and your version doesn't have the altered name.

There are now two versions:
https://github.com/SFML/SFML/wiki/Source%3A-Mp3-Soundfile-Reader
and
https://github.com/SFML/SFML/wiki/Mp3-Soundfile-Reader

The latter one needs to be deleted.
I assume that only the SFML team can remove pages. Nevermind. Just found the delete button  :-[
« Last Edit: August 25, 2015, 06:55:08 pm by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

cptn ndongo

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Code sample on how to add Mp3 support using mpg123
« Reply #6 on: August 25, 2015, 06:45:34 pm »
Ok, I deleted the non-source version and everything is fine. For some reason, when I deleted it before, this also removed the link from the source page. Anyway, it works now. Thanks for helping!

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Code sample on how to add Mp3 support using mpg123
« Reply #7 on: August 25, 2015, 06:55:41 pm »
You're welcome and thank you for contributing to the community  :)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*