Pausing and resuming mp3 with WMPLib and C#

和自甴很熟 提交于 2019-12-01 10:36:18

问题


I'm working on a simple mp3 player project with C# and the WMPLib library. The idea is to make it controllable with a PIC component, to control media playing in the PC from "anywhere" in my house (yes, this is a college project).

The problem: I can't get the WindowsMediaPlayer.controls.play() method to resume a paused playback. How should I do it? I've already tried to save and set the WindowsMediaPlayer.controls.currentPosition property, but it doesn't work.

PS:
The same problem: http://social.msdn.microsoft.com/Forums/en-US/windowspro-audiodevelopment/thread/770d22fc-7ef1-475e-a699-b60e2282a7c7/
Different problem: pause and resume Windows Media Player in C#

Thanks in advance

EDIT: WindowsMediaPlayer.controls.currentPosition works fo setting the position, but not for getting it:

double time = Player.controls.currentPosition; //Returns 0 always
Player.controls.currentPosition = time; //Works fine, makes music jump to time seconds

回答1:


You can get currentposition by converting it to string for example:
label1.text = convert.tostring(Player.controls.currentPosition);

I've used a label to show you the exactly currentPosition value.

Regards




回答2:


...
double time = Player.controls.currentPosition; //return always 0 for you, because you pause first and after get the value
Player.controls.pause();

Player.controls.currentPosition = time;
Player.controls.play();


来源:https://stackoverflow.com/questions/6644064/pausing-and-resuming-mp3-with-wmplib-and-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!