如何在VB.net中检测Media Center中当前打开的文件

问题描述:

大家好,


我正在Vb.net上写一个媒体中心Addin,直到我想要找到目前播放歌曲FilePath或URl


我花了几个小时来绞尽脑汁想办法看看当前打开的文件是什么。在任何时间都在机器上。


我的想法是获取所有当前打开的文件,然后从这些文件中过滤扩展,找到当前正在播放的媒体项目,并获得文件路径..


有谁知道我怎么做到这一点?我应该看看或导入哪些方法或类或图书馆..这个确实让我思考。


我在看WMI Windows Management控件,但似乎无法看到找到我要找的东西..任何帮助都会很棒..


干杯


罗比

Hi Guys,

I am writing a Media Centre Addin in Vb.net and it was all going good until i got to the point where i want to find the "Currently Playing song FilePath or URl"

I have spend a number of hours racking my brain to figure out a way of seeing what the "Currently Opened Files" are on a machine at any point of time.

My idea is to get all the currently opened files, and then filter the Extensions from these and find the media item that is currently playing, and get the filepath..

Does anyone know how i can do this? and what methods or classes or Librarys i should be looking at or importing In.. This one has really got me thinking.

I was looking at the WMI Windows Management controls, but cant seem to find what i am looking for.. any help would be great..

Cheers

Robbie

大家好,

如果有人想知道怎么做的话,我会在接下来的几天内发布一个回复。


干杯


罗比
Hi Guys,
Worked this one out, will post a reply in the next few days if anyone wants to know how to do it.

Cheers

Robbie


分享解决方案是一个好主意,以便其他面临同样问题的人能够找到答案......否则你只会让他们挂起来。


如果你能分享你的解决方案,我们将不胜感激。


谢谢


-Frinny
Sharing the solution is a great idea so that others facing the same problem will be able to find the answer....otherwise you''re just going to leave them hanging.

If you could share your solution it would be greatly appreciated.

Thanks

-Frinny


嗨大家好,


以为我会通过关于如何获得当前播放的Vb.net代码媒体中心环境中的歌曲。


它的工作方式是挂钩到backgroup WMPlayer进程,看看它当前打开了哪些文件,然后循环遍历它们直到找到匹配的扩展名。


此代码也适用于没有媒体中心的标准应用程序..
Hi Guys,

Thought i would send through the Vb.net code for how to get the currently playing song in a Media Centre Environment.

The way it works is it hooks on to the backgroup WMPlayer process, and sees what files it currently has opened, it then loops throught them until it finds a matching extention.

This code will also work in a standard application without media centre..
展开 | 选择 | Wrap | 行号