我如何捕捉 itunes 活动?
添加
iTunes.OnPlayerPlayingTrackChangedEvent += new _IiTunesEvents_OnPlayerPlayingTrackChangedEventEventHandler(iTunes_OnPlayerPlayingTrackChangedEvent);
我已将此代码和此代码
private void iTunes_OnPlayerPlayingTrackChangedEvent(object iTrack)
{
if (iTunes.CurrentTrack != null)
{
if (iTunes.CurrentTrack.Artist != null & iTunes.CurrentTrack.Album != null & iTunes.CurrentTrack.Name != null)
{
artist = iTunes.CurrentTrack.Artist;
album = iTunes.CurrentTrack.Album;
title = iTunes.CurrentTrack.Name;
if (!NowPlaying.IsBusy)
{
NowPlaying.RunWorkerAsync();
}
}
}
}
到我的应用程序中,该应用程序是用 C# 编写的,但当歌曲更改时它不会捕获。 我错过了什么吗?
还有其他方法可以捕获 iTunes 曲目更改事件吗?
i have added this code
iTunes.OnPlayerPlayingTrackChangedEvent += new _IiTunesEvents_OnPlayerPlayingTrackChangedEventEventHandler(iTunes_OnPlayerPlayingTrackChangedEvent);
and this code
private void iTunes_OnPlayerPlayingTrackChangedEvent(object iTrack)
{
if (iTunes.CurrentTrack != null)
{
if (iTunes.CurrentTrack.Artist != null & iTunes.CurrentTrack.Album != null & iTunes.CurrentTrack.Name != null)
{
artist = iTunes.CurrentTrack.Artist;
album = iTunes.CurrentTrack.Album;
title = iTunes.CurrentTrack.Name;
if (!NowPlaying.IsBusy)
{
NowPlaying.RunWorkerAsync();
}
}
}
}
to my app thats programmed in c# but its not catching when the song changes. Am i Missing Something?
is there any other way to catch iTunes track changed event?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您实际上订阅了错误的事件来捕获此信息。
这是一个代码片段,可以为您提供您想要的内容:
You're actually subscribing to the wrong event to capture this info.
Here is a code snippet that will give you what you want:
你应该使用“或”,而不是“和”。 在您的代码中,它只会报告艺术家、专辑和歌曲名是否发生更改。 那是你要的吗? (因为如果我播放同一专辑中的另一首歌曲,用户界面将不会更新)。
You should use "or", not "and". In your code, it will only report if the artist and the album and the songname change. Is that what you want? (because if I play another song in the same album, the UI won't update).
我想出了一个办法让它发挥作用。
首先,我添加了一个计时器
,然后每 1 秒检查
一次:)
I figured out a way to make it work.
First of all I added a timer
Then every 1 second it checks
that's it :)