简体   繁体   中英

C++:How to use windows media player to play and pause mp3 file in a visual studio console application program?

For a semester project, I am planning to make a media player in visual studio c++ console application which will provide the functions of play, pause, previous, next, shuffle, repeat, different playlists of recently played, most played songs, search a song etc.

However, I can't find a way to do that without using multi-threading (which I dont know at the moment). To avoid multi-threading, I was thinking of making use of windows media player .dll if that is possible. I am expecting to give a path to play function which plays the song in background and then changes the song when I give it another path using the 'Next Song' function. Kindly tell how to do that if this is possible. Thank you.

For your console application. You can simply call the system to launch windows media player

 system ("start wmplayer.exe -p C:\\Folder\\Music\\Sample.mp3");

this will start your player. You can change track by doing this

 system ("start wmplayer.exe -p C:\\Folder\\Music\\Sample2.mp3");

this will run Sample2.mp3. You can store other information in your program like for playlist store information in an array of string and start them individually.

Moreover if you want to don't want to see the WM Player interference you can use some sort of script like https://gallery.technet.microsoft.com/scriptcenter/2c3caa06-ca29-4faa-a16d-7db57e80428b I think this is the simplest solution of your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM