使用WMPLib和C#暂停和恢复mp3 [英] Pausing and resuming mp3 with WMPLib and C#

查看:122
本文介绍了使用WMPLib和C#暂停和恢复mp3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#和WMPLib库开发一个简单的mp3播放器项目.这个想法是使它能够通过PIC组件进行控制,从而可以从我家中的任何地方"控制PC中的媒体播放(是的,这是一个大学项目).

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

问题:我无法获取WindowsMediaPlayer.controls.play()方法来恢复暂停的播放.我该怎么办? 我已经尝试保存并设置WindowsMediaPlayer.controls.currentPosition属性,但是它不起作用.

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:
相同的问题: http://social.msdn.microsoft.com/Forums/zh-CN/windowspro-audiodevelopment/thread/770d22fc-7ef1-475e-a699-b60e2282a7c7/
不同的问题:在C#中暂停和恢复Windows Media Player

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#

预先感谢

WindowsMediaPlayer.controls.currentPosition可用于设置位置,但不适用于获取位置:

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

推荐答案

您可以通过将当前位置转换为字符串来获取当前位置,例如:
label1.text = convert.tostring(Player.controls.currentPosition);

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

我已经使用标签向您显示了确切的currentPosition值.

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

致谢

这篇关于使用WMPLib和C#暂停和恢复mp3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆