gpt4 book ai didi

macos - itunes 是否会触发操作系统上其他进程可以监听的事件?

转载 作者:行者123 更新时间:2023-12-03 16:35:52 26 4
gpt4 key购买 nike

我正在考虑创建一个应用程序,该应用程序需要了解 iTunes 中正在播放的歌曲。

如果 itunes 不触发事件,是否有数据库或某种方法可以以编程方式获取 itunes 中正在播放的内容?

最佳答案

iTunes 确实会发出分布式通知。您可以通过观察com.apple.iTunes.playerInfo

来获取完整的轨道状态
NSDistributedNotificationCenter.defaultCenter().addObserver(self, selector: "iTunesNotification:", name: "com.apple.iTunes.playerInfo", object: nil)
func iTunesNotification (notification:NSNotification!) {
var trackInfo:NSDictionary! = notification.userInfo
println("Track Info \(trackInfo)")
}

轨道的示例输出是:

Track Info {
Album = "The Very Best Of Sting & The Police";
"Album Artist" = "Sting & The Police";
"Album Rating" = 0;
"Album Rating Computed" = 1;
Artist = "Sting & The Police";
"Artwork Count" = 1;
Composer = Sting;
Genre = Rock;
"Library PersistentID" = 3465537150503037139;
Location = "file://localhost/Users/GoodSpeed/Music/iTunes/iTunes%20Media/Music/Sting%20&%20The%20Police/The%20Very%20Best%20Of%20Sting%20&%20The%20Police/17%20Roxanne.mp3";
Name = Roxanne;
PersistentID = 716102833338382931;
"Play Count" = 1;
"Play Date" = "2013-12-28 10:43:24 +0000";
"Player State" = Playing;
"Playlist PersistentID" = 5080879747404822807;
"Rating Computed" = 1;
"Skip Count" = 0;
"Store URL" = "itms://itunes.com/link?n=Roxanne&an=Sting%20%26%20The%20Police&pn=The%20Very%20Best%20Of%20Sting%20%26%20The%20Police&cn=Sting";
"Total Time" = 190458;
"Track Number" = 17;
Year = 2002;
}

关于macos - itunes 是否会触发操作系统上其他进程可以监听的事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24358098/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com