开发者

Pausing and resuming mp3 with WMPLib and C#

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


...
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();


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜