Playing a music file

Posted on 1999-11-07
Medium Priority
Last Modified: 2010-05-02
I am using the ShellExecute feature in one of my programs to open the default player and play an mp3 file. This feature works well, but the only problem is that I would like to be able to play a few files, one right after the other. The way my code is now it will start playing the first file and immediately resume to the next line in code. How can I program it so that it won't look for the next file until the previous song is finished playing?
Question by:damonc090698
  • 3
  • 2

Expert Comment

ID: 2190115
You have to use the OCX of media player and not shell execute ...

You use the OCX to play is pretty simple you have all info in the microsoft site :


and after that you know how to use it
you have only to play the next in the list when it finish to play the current

       If you have problem let me know

Author Comment

ID: 2190217
Thanks Faraj for the response, but I am using shell execute so that I can have it open up in the default program for the file (not necessarily Media Player). What I need to know is how I can control when the songs are played. Any ideas?

Author Comment

ID: 2190511
Adjusted points to 200
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

LVL 14

Accepted Solution

mcrider earned 800 total points
ID: 2190580
Most MP3 Players will support playing ".M3U" files...

An M3U file is nothing more than a text file containing the paths to MP3 files.  Basically it acts as a "play list".

All you have to do is create a text file with the ".M3U" extension and put the path to each MP3 you want to play on a separate line in the file.

Then, instead of using your ShellExecute to launch the MP3, launch the M3U file...

Hope this helps...


Author Comment

ID: 2191706
Thank you! That is a very cool trick. I never knew what a .m3u file was.  The only other issue that I will have now is how to tell when the playlist is done playing so that I can close the mp3 player. Any ideas?
LVL 14

Expert Comment

ID: 2196675
Unfortunately, because you're using shellexecute to play your mp3/m3u files, there's no way of knowing when the play is over...

To have more control over your app, you really need to use a control like the mediaplayer control.

You can get this control from microsoft when you install MediaPlayer 6.


Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question