[英]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. 对于一个学期的项目,我计划在Visual Studio c ++控制台应用程序中制作一个媒体播放器,该播放器将提供播放,暂停,上一首,下一首,随机播放,重复,最近播放,播放最多的歌曲的不同播放列表,搜索歌曲的功能。等等
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.
为了避免多线程,我正在考虑尽可能使用Windows Media Player .dll。 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
您只需调用系统即可启动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. 这将运行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. 此外,如果您不想看到WM Player干扰,可以使用类似https://gallery.technet.microsoft.com/scriptcenter/2c3caa06-ca29-4faa-a16d-7db57e80428b这样的脚本,我认为这是您问题的最简单解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.