Here is a very simple example on how to play MP3 music files. Also shows how simple it is to use a list box control. Playing MP3 music files doesn't get much easier then this using asm. Requires masm32 to assemble. Also includes executable.
[attachment deleted by admin]
Hi Cycle Saddles:
Nice mp3 demo.
Regards herge
Thanks herge, have fun buddy! :wink
Quote from: Cycle Saddles on October 20, 2008, 02:36:53 PM
Here is a very simple example on how to play MP3 music files.
Hi, Cycle Saddles
Thanks. It works and my prog play mp3 music now! Thank you :U
Rui
Your welcome RuiLoureiro, I'm glad you found it useful! :bg
Cycle Saddles,
How to know when the music ends ? I want to play 2 musics one after another
When one ends i want to play the other. How ?
(To play a music i call PlayMp3File)
Thanks
Rui
The MM_MCINOTIFY message is sent to the app when the music has completed. MCI devices send this message only when the MCI_NOTIFY flag is used. So when this message is received point to the next music filename and call the PlayMp3File procedure again.
Here is a good source of info using MCI. http://msdn.microsoft.com/en-us/library/ms709461(VS.85).aspx
That was very cool! I like your coding style ... easy to read and learn from.
Thanks thomas, there are more of my examples around here and you can find more in hutch's masm32 package under the examples/bcraven directory. I also plan on whipping out a few more simple examples for those who wish to learn sometime this winter. :bg
Quote from: Cycle Saddles on October 22, 2008, 12:03:45 PM
The MM_MCINOTIFY message is sent to the app when the music has completed. MCI devices send this message only when the MCI_NOTIFY flag is used. So when this message is received point to the next music filename and call the PlayMp3File procedure again.
Cycle Saddles,
Thank you again, it works !
Rui
Good! :wink
hi, Bill Cravener, that;s good app :U
btw, I'm in search how to get time length of file1.mp3
I think MCIWndGetEnd will give me the duration of file1.mp3 file. but I m wrong.
the real duration of file1.mp3 is 3 minutes and 5 seconds
with MCIWndGetEnd, I get 1850762 . Maybe I missunderstand
I also want to get who is the artist, what is the album title of file1.mp3. I don't have imagine how to do that..
would you like to give me a clue?
thank you
sorry for my bad english
invoke MCIWndDestroy, hMci ;kill any currently playing tracks
invoke MCIWndCreate,
hWnd, 400000h,
WS_CHILD or MCIWNDF_NOOPEN,
SADD("C:\file1.mp3")
mov hMci,eax
pop eax ;For some reason 4 things are pushed onto stack unnecessarily
pop eax ;so they have to be popped off the stack to prevent crashing
pop eax ;Thanks to Ron Thomas for spotting that one!
pop eax
invoke MCIWndGetEnd, hMci
invoke MessageBox,hWnd,str$(eax),SADD("duration of file1.mp3"),0
Hi elmo,
I have no idea how to achieve what you want and I'm just too busy with the real world to find it for you.
That simple little example was derived from the information I gathered from reading the mciSendCommand API from Microsoft's SDK. I think you can find what you need by digging in the MS SDK under that subject.
Microsoft's SDK is your friend! :bg
Technically, it all depends on what the current time format is, but..
1850762 / 10000 = 185.0762
3 minutes + 5 seconds = 3*60 + 5 = 185
As for the album information, it's stored in the ID3 tag. I don't think MCI provides direct access to that, so you may have to extract them yourself. Version 1 tags are very simple, and stored in the last 128 bytes of the file, version 2 provides much better information, so it's a little more complex, and is attached at the beginning of the file.
Hi elmo,
It's not too difficult to get the duration of an MP3 file without the MCI functions. They fail on VBR encoding anyway, at least they did when I checked them out a few years ago. I posted a tag reader I wrote some time ago that will calculate the duration (in milliseconds) of an MP3 file:
http://www.masm32.com/board/index.php?topic=10610.0
You're welcome to use any part of it you want.