Help Making Media Player

Cabose

Active member
Joined
Oct 18, 2006
Messages
39
Programming Experience
Beginner
I was wanting to make a media player with a media library and an id3 tag editor for my semester project in my programming class and i dont have any idea of how to do it will someone please help me figure it out?
I use VB .net 2005

Thanks,
Much
 
I can help.

Hi

This is actually very easy.
There is a component called wmplib.dll, (windows media player), if you use this you will be required to have windows media player installed on the computer.It can handle playing a song/video and all the basic controls with any one statement eg "wmp.ctlcontrols.play" (or something like that) this does not allow for tag editing(as far as i know), but there is a cool dll called ultraID3lib.dll this will allow you to do just about anything with ID3 v1 and v2. I have made several media players and batch ID3 editors, and some turned out pretty good.
I am currently making my best one yet and I am creating a website for it , Its hardly ever online at the moment but I will post a link at a later date. there is allot of code that goes along with each one, so i will just cover some basics here and if you or anyone else wants the whole project files you can e-mail me for them.

Just ask a question.(e.g if you dont know how to add the wmp dll, ect)

What visual studio are you using (03 or 05) ?
The DLL will be in your "Add to toolbox" dialog under components.

I will make a quick demo after you reply if you want, just ask.
 
So what do you want to do

First What do you want to do with this media player.
eg. search for songs, make a playlist, sort by artist ect
 
well i have had a lot of help since i have posted this but what i would like is an opinion on how you would make a playlist and media library and how to do like a current position as in like at this point in time the current position is 3:45 out of 4:14 minutes to show how long the song has been playing. I have been told how to make a playlist and media library but i am not to fond of it. I am using the Window Media Player Control. I would also like to know how to make the Id3 Tag editor to edit my mp3s. I will upload my project so you can see what i have and see if there is any adjustments that you may think would help it. And if it would help you can put like all the adjustments you think it might need in like a little text file and compress the folder again and resend it.
http://programmingcentral.uni.cc/mediaplayer.zip (You have to copy the link into your browser for some reason my free host wont allow direct links like that)

Thanks,
Cabose
 
Good timing

I just pressed the save button on a simple library program for you as i got an email about your reply,so here it is. you can test it first by just clicking
"Load Data"
then click
"Show listview items"
(some of my media info is saved to a ser file that you can use for a quick display and example)
but you can search your own, just choose search, wait until it says mp3 search complete, then click save, then do above..

feel free to ask any questions
 

Attachments

  • LibraryTest.zip
    333.3 KB · Views: 56
some tips

how to set or get volume
wmpInfinite.settings.volume = 23 '(from 0 to 100)i use a slider thing
dim i as integer = wmpInfinite.settings.volume

how to get song length
Dim strSongTime AsString = wmpInfinite.currentMedia.durationString
Dim currentTimePos AsString = wmpInfinite.Ctlcontrols.currentPosition

Some tips for playlist...
if you choose to do a library a similar way I have, you could use a listview items index as playlist index, and use some code to remove all others from the listview or womething like that... I havent doe it this way before but i think its ok.
do you know how to search for songs ect from the list... bla bla bla
I will just upload an old media plyer of mine, i know it wont work first as some file paths are specific to my comp but im sure you can make it work.
the code is a mess, im not sure if anyone could follow the whole thing. when adding media to library choose buttons from right to left (at the bottom), overwrite library does nothing i think... well after looking it is VERY MESSY CODE. but some snippets in there should be of use for you...

ooops i forgot to upload file here it is...
As you will see I have come a long way since making this and the library from above...
I will semi complete the library from the earlier post today and post it tongiht.

PS where are you from, and when is your assignment due?
 

Attachments

  • Media Player.zip
    643.8 KB · Views: 66
Last edited:
how do i make a slider for my volume and my position thing like Window Media Player has? Also the Library test thing freezes up when i try searching for media it says search for wma files complete or something like that and when i click ok it freezes up and quits responding.

~Cabose
 
Last edited:
Track bar

You can use a trackbar control,
and on trackbar value changed event set the volume to the trackbars value

sub whatever(byval blabla) handles trackbar1.valuechanged (i think) just dbl click it and it will give you the right sub.

and then

wmp.settings.volume = trackbar1.value

or for changing the position of the song

'Set this when the song starts to play
trackbar1.maximum = wmpInfinite.currentMedia.duration

wmpInfinite.Ctlcontrols.currentPosition = (trackbar1.value)

or if you want a custom track bar that looks real nice (not like the one in the app above :eek: ) then use photoshop or something and use some labels or what ever with the images of the background set to your cool pics, and use some math on the click event... or create a mousedown and drag or something... I think that might be in the program from above, if it is its probably crappy code, but youll get it................

And about the freezing, are you sure its not still looking for MP3 files?? because after the WMA message box, wait for the mp3 one.

Im writing a better one now. it uses a background worker (so it wont freeze and crash) and its just plain better...(it shows all tags too)
 
Hi guys, I too am building a MP3/WMA Player and I'm not at a standstill yet, but I can't figure out how to sort the darn filesize, numerically. Other than that. The player is coming along nice, and i've downloaded your projects to get an idea of what I might be missing, or what I can improve on. Fixing my messy code into pretty code is one on the 'TODO: list :) I do have one more question however. Where is a good reference to be able to make the ID3 tag values show up in the ListView? I know you have to add the items.. i've got a For Next loop that adds the items, but... reading the files is going to be an issue that I see coming on down the road. I'd also like to be able to edit the ID3 tag and save it back to the file if that would also be possible. All these answers are probally in your projects, but I havn't taken a look yet. So, that's what i'm about to do. I've got about 5 MP3 players to look at. Thanks for all the help thus far, this thread has been a huge help. And good choice with the backgroundworker, I used that in my previous project and it is just the most awsome thing. It really makes the UI more responsive if you use it correctly. If you need any help with that, let me know.
 
Set ID3

hey, i will upload a demo now that will allow you to set file size option before searching. and it will include a little ID3 tag editor

I didnt realy get what you meant by the file size, do you want to sort them in listview once they were found? or do you want to restrict files larger or smaller than a defined size being found?
 
The problem that I am having when I sort, on the ListView is that the numbers are sorting as a string, so what I get when I click the ColumnHeader, I get this

1
120
13
131
1331
14
...
...

The numbers are not in ascending order, it's being sorted by the IComparer, i'm not sure if that's the best way of doing it, i took the example from MSDN's library. It workd like a charm for string, but no so much for numbers.
 
ID3 editor and numericly sort Sample app

do you use an array of some sort for adding these items to list view?
or a structure?
or ???

Ive attached a library demo that show how to edit ID3 tags and you can sort an array by order of numbers(and show in listview)
it is an array of the "song" structure used in the demo above with the change of the track property being set to an integer value
 

Attachments

  • Library_Demo.zip
    248.8 KB · Views: 41
Last edited:
Thanks for all the help thus far, this thread has been a huge help. And good choice with the backgroundworker, I used that in my previous project and it is just the most awsome thing. It really makes the UI more responsive if you use it correctly. If you need any help with that, let me know.

Glad I could help man...

If you could have a look at how i used a background worker and let me know of any improvements, that would be cool...

thanx
 
Well, first I cast the files into an array when you click the node on my TreeView

VB.NET:
Dim Dir AsNew DirectoryInfo(e.Node.FullPath.ToString)
Dim files() As FileInfo = Dir.GetFiles("*.mp3*", SearchOption.AllDirectories)
Dim finext As FileInfo
Second, I pick through all the information I need... more specifically, here's the code I use for the FileSize:

VB.NET:
Dim fSize
 
For Each finext In files
 
fSize = FileSize(finext.Length())
 
Next
VB.NET:
Const KByte AsLong = 1024
Const MByte AsLong = 1024 ^ 2
Const GByte AsLong = 1024 ^ 3
 
Function FileSize(ByVal _Size AsLong) AsString
SelectCase _Size
CaseIs > KByte
Return Format(_Size / KByte, "##########0") '& " KB"
CaseElse
Return Format(_Size / KByte, "##########0") '& " KB"
EndSelect
EndFunction

then all the data gets placed in a column as a listviewsubitem, but... it sorts it as a string =\

And, i'd be more than happy to take a look at your background worker. Tomorrow, that's what I plan on doing to mine... throw all the code into a background worker. There is a very good book that explains Threading in detail.. named "The Book of Visual Basic 2005". Without this book and another one... this would be a rough road to travel.
 
Back
Top