简体   繁体   English

C ++:如何使用Windows Media Player在Visual Studio控制台应用程序中播放和暂停mp3文件?

[英]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.

相关问题 在Windows上播放和暂停.wav或.mp3文件 - Play and pause an .wav or .mp3 file on windows C ++-从控制台应用程序运行Windows Media Player-COM - C++ - Running Windows Media Player from Console Application - COM 如何用c ++在vlc中播放mp3文件 - how to play a mp3 file in vlc with c++ 如何在 Visual Studio 代码中完成后暂停控制台 C++ 应用程序 - How to pause a console c++ application when it finished in Visual studio code 使用Struct为mp3播放器模拟C ++(不需要播放mp3的唯一显示列表) - Using Struct for a mp3 player simulation C++ (does not need to play mp3's only display lists) 在 C++ 程序中暂停控制台 - Pause Console in C++ program 如何使用IPropertyStore在Windows中使用C ++访问mp3元数据? - How do I use IPropertyStore to access mp3 metadata in Windows with C++? 如何在Visual Studio 2012上使用带有控制台的GUI Windows应用程序? - How to use GUI Windows Application with Console on Visual Studio 2012? Visual Studio C ++ 2010如何将ICON添加到控制台应用程序 - Visual Studio C++ 2010 How to add an ICON to a console application 强制C ++程序在Visual Studio调试器中暂停 - Force C++ program to pause in Visual Studio debugger
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM