如何通过winForms控制iTunes [英] How to control iTunes through winForms

查看:71
本文介绍了如何通过winForms控制iTunes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以看到类似的问题已在此处得到解答(

I can see a similar question that has been answered here (How would i play a specific song in iTunes through java?) but it doesn't really answer my question (I don't think, anyway).

我在winform上有几个按钮(播放,暂停,向前跳,向后跳),并希望能够通过iTunes连接这些按钮,从而创建一个迷你媒体播放器".

I have a couple of buttons on a winform (play, pause, skip forward, skip back) and want to be able to connect these through iTunes, so as to create a 'mini media player'.

但是,所有这些"COM"恶意代码都存在问题(很明显,否则我不会写这个:P).我试图(几乎)包括所有来自"Apple","iTunes"的参考,但似乎仍然找不到找到按播放"按钮并在iTunes中实际播放歌曲的方法.

However, I am having issues (obviously, or I wouldn't be writing this :P) with all this 'COM' malarkey. I have tried including (nearly) all the possible references from 'Apple', 'iTunes' and still can't seem to be able to find a way of pressing the button 'play' and actually playing a song in iTunes.

我在点击事件上有一个按钮(我称为按钮btnPlay).但是有人知道将iTunes连接到Winforms的正确"或有效"方法吗?

I have a button on click event (i've called the button btnPlay). But does anyone know the 'correct' or 'efficient' way of connecting iTunes to winforms?

我听说过称为sendKeys的东西,但是我完全是个菜鸟,真的不知道如何创建这种东西.

I've heard about something called sendKeys, but I'm a total noob and have really no idea of how to create this sort of thing.

PS.我还尝试为using iTunesLib;找到参考(从

PS. I've also tried to find a refence for using iTunesLib; (from http://blogs.msdn.com/b/noahc/archive/2006/07/06/automating-itunes-with-c-in-net.aspx) but this is a dated post, and i'm not certain this namespace is available anymore (well, I can't find it anywhere in the Com references anyway.

一如既往,任何帮助都非常感激.

As always, any help much appreciated.

推荐答案

添加对iTunes 1.xx类型库的引用(它将在COM引用列表中).

Add a reference to iTunes 1.xx Type Library (it will be in the COM list of references).

然后,您可以在点击事件中使用iTunes应用

Then you can use iTunes app as so in your click event

iTunesApp app = new iTunesAppClass();
app.Play();

您将需要执行以下步骤嵌入COM iTunes应用.

you will need to perform the following step to embed the the COM iTunes app.

Go to the Solution Explorer.
Right click on References –> iTunesLib and hit Properties.
Set "Embed Interop Types" to False.

这篇关于如何通过winForms控制iTunes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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