Programming a music player

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

mitch1423
Posts: 47
Joined: Sun Sep 26, 2010 6:10 pm UTC

Programming a music player

Postby mitch1423 » Thu Sep 13, 2012 12:10 am UTC

Just wondering how hard you guys think it would be to program a media player type program. If you could also recommend a good programming language for this that would be cool. Although I'm not sure that it matters really. I would love any resources you could provide me for this kind of project, and even some info about copyright having to do with codecs for if this project becomes robust enough to release to people. Tell me what you think.

User avatar
WanderingLinguist
Posts: 237
Joined: Tue May 22, 2012 5:14 pm UTC
Location: Seoul
Contact:

Re: Programming a music player

Postby WanderingLinguist » Thu Sep 13, 2012 1:26 pm UTC

It would help if you told us what platform this is for, and what programming languages you know.

Edit: There are already lots of music players out there. Do you want to make a new one just for the experience, or is there some other reason? Your question is incredibly broad. Give us something to work with :P

User avatar
freakish777
Posts: 354
Joined: Wed Jul 13, 2011 2:14 pm UTC

Re: Programming a music player

Postby freakish777 » Thu Sep 13, 2012 2:27 pm UTC

VLC Player is open source.

http://wiki.videolan.org/Developers_Corner

Try fixing some bugs in there first to get your feet wet maybe??

LikwidCirkel
Posts: 169
Joined: Thu Nov 08, 2007 8:56 pm UTC
Location: on this forum (duh)
Contact:

Re: Programming a music player

Postby LikwidCirkel » Sun Sep 16, 2012 4:27 pm UTC

Making an audio player wouldn't be super hard. Video is a bit more challenging, and doing both at once introduces more even more complications.

In any case, the very most basic thing any audio player does is:

1) open file
2) determine what kind of container format the file is and what codecs the content uses.
3) run data through demuxer appropriate for file format, which will output audio and/or video streams, generally compressed using some kind of codec.
4) Run audio data (or video) through appropriate decoder for the codec type.
5) Write to output device. This part should be super simple with audio, as it will have it's own buffering and rate-control.
6) Also provide some sort of front-end (obviously).

It really depends on what you want to gain from this and what part of the code you want to write yourself. If you just use a library that handles all the computational stuff, such as like ffmpeg/libavcodec/libavdemux it's just an exercise in opening files, I/O devices and GUI design. I'd use C++, but if wrappers exist for other languages, I don't see why you can't use whatever you're comfortable with.

If you also want to support video, the there's significant complexity in properly handling things like A/V sync and smooth video rendering.


In terms of legality, it depends mostly on what country you want to sell to and what codecs you're using. I'm pretty sure you can compile ffmpeg to omit support for certain codecs to keep it legal where it matters. I am by no means an expert in this area though.

mitch1423
Posts: 47
Joined: Sun Sep 26, 2010 6:10 pm UTC

Re: Programming a music player

Postby mitch1423 » Sun Sep 16, 2012 11:37 pm UTC

Well I'm an amateur programmer in that I've messed around with a lot of languages, but never really created a decent product with my skills. I know VB.NET and C# fairly well, the basics of python, and just the syntax of C++. Not to derail my own thread, but if you guys know of a good way to learn C++ I'm all ears. Anyway back to music players, I've looked at a lot of them, but I don't really like any of them all that much. I've used Foobar2000 for a long time, but I want to customize it more than it seems to allow at this point. I don't really like WinAMP, Windows Media Player, or Songbird. This is probably more of an exercise than a real serious project. I was probably a bit overzealous when I talked about selling it. I'm conflicted when it comes to what programming language to use, with .NET languages, I can use the WPF and easily make the UI, but I also want to use C++ if just for the experience of actually writing a program in C++. Also about fixing bugs in VLC, that seems like it would be much more complex than to build my own. First, I would have to learn how VLC works, and from what I understand, VLC has the codecs hard coded into it. Once I learned about the workings of VLC, I would have to fix one of the most likely complex bugs in the programming that probably involve complex audio/video code. I suppose I could stumble upon a "stupid" error every now and again as would be normal with a project of that size, but still, what would that teach me? Anyway, hope that answers some questions, sorry if I rambled too much.

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Programming a music player

Postby EvanED » Sun Sep 16, 2012 11:51 pm UTC

I've also thought of writing a media player because I don't like the library features in any existing ones.

I have a couple comments:

1) I suspect that for virtually any language you're interested in using, there's some library you can use that wrap up steps 1-5 of LikwidCirkel's post into play("foo.mp3"). Edit: of course, how you get information to update the position in the audio is up to the API. Could be problematic.
2) IMO, the "right" way to do a media player is to use the system's "native" audio framework to play -- e.g. for Linux, you'd want to use gstreamer. I'm not sure what the API to it looks iike, but presumably it has to isolate you from determining the codec and decoding the file yourself, by its very nature.

User avatar
PM 2Ring
Posts: 3715
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Sydney, Australia

Re: Programming a music player

Postby PM 2Ring » Mon Sep 17, 2012 7:47 am UTC

You might have fun building your own customised media player using something like MLT.

User avatar
freakish777
Posts: 354
Joined: Wed Jul 13, 2011 2:14 pm UTC

Re: Programming a music player

Postby freakish777 » Mon Sep 17, 2012 1:11 pm UTC

mitch1423 wrote:Also about fixing bugs in VLC, that seems like it would be much more complex than to build my own. First, I would have to learn how VLC works


Yes and no. You'd need a general understanding of what it's doing (and/or what it's methods/functions are trying accomplish).

Once I learned about the workings of VLC, I would have to fix one of the most likely complex bugs in the programming that probably involve complex audio/video code.


Not true at all. As functionality gets added to any application, new bugs, both trivial and non-trivial are introduced.


what would that teach me?


Once you get the general understanding of what VLC is doing as a program, and what some of it's main methods are trying to accomplish, you'll have the knowledge of how other people approach the same problem you're setting out to do. It will probably take longer to arrive at "I know how to make a media player on my own" doing it that way but will also likely be a (far) more robust understanding than doing it on your own.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 6 guests