Programmatically Controlling Windows Media Player, Preferably From Java

核能气质少年 提交于 2019-12-08 03:39:51

问题


I'm adding functionality to an existing Java application that's already been deployed extensively. (So there are some design decisions that I can't touch unless I have a seriously compelling reason.) The app controls a PC broadcasting audio and visual to a small local TV network. Right now, it mostly broadcasts static slides, but it can also do background music at the client's discretion. The background music (CD, local music files, internet radio, whatever) is handled by Windows Media Player.

My current project is adding narration to the static slides. When the narration plays, I need to send some kind of STFU signal that temporarily either quiets or mutes the WMP output. So my core question is: What's the best way to accomplish this?

I know WMP has an ActiveX interface, but I'm not experienced with ActiveX/COM. I can (and probably will) learn, certainly, but at this point, I'm not well positioned to distinguish between solutions that are easy, solutions that are technically feasible but painful, and "solutions" that are actually blind alleys.

Would a Java-based solution require me to make use of a Java->ActiveX bridge like Jacob? Or is that overkill?

Or, am I barking up the wrong tree entirely? I'm certainly willing to deploy small command-line executables written in another language entirely and then access them via Runtime.exec(). Is this the sort of thing that (say) VisualBasic makes dirt simple? (VB isn't in my skillset either, but if it's the right tool for this job, I'll learn. I just don't know if it's the right tool. Google gave me plenty of examples of incorporating WMP into a VB GUI; VB command line script, not so much.)

Finally, one last point: the WMP instance would be started by the user, not started by the Java app. Don't know if that makes a difference, but figured it was worth mentioning.

My thanks in advance for any insight anybody can offer me.


回答1:


Your best bet is to use Jacob (or some other Java/COM bridge); I assume you don't want to just mute the system volume.



来源:https://stackoverflow.com/questions/711560/programmatically-controlling-windows-media-player-preferably-from-java

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