Léo
Léo

Reputation: 88

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

Upvotes: 1

Views: 6812

Answers (2)

Yoteli Tefuno
Yoteli Tefuno

Reputation: 21

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

Upvotes: 2

Francisobi94
Francisobi94

Reputation: 48

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

Upvotes: 1

Related Questions