在iTunes中获取当前播放的歌曲 [英] Get the currently played song in iTunes

查看:81
本文介绍了在iTunes中获取当前播放的歌曲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取iTunes当前正在播放的歌曲的名称. 我应该参考什么API?

I'd like to get the name of the song that iTunes is currently playing. What API should I refer to?

我想根据它更易于使用,将其用于仪表板小部件或Java/python应用程序.

I'd like to use that both for a dashboard widget or a Java/python application depending on what it is easier to use.

您对我有参考吗?

预先感谢, 马里奥(Mario)

Thanks in advance, Mario

推荐答案

下面是一个AppleScript,它将告诉您iTunes中当前正在播放的歌曲的信息-

Here's an AppleScript that will tell you the information of the currently playing song in iTunes -

on run
  set info to ""
  tell application "System Events"
    set num to count (every process whose name is "iTunes")
  end tell
  if num > 0 then
    tell application "iTunes"
      if player state is playing then
        set trackname to name of current track
      end if
    end tell
  end if
  return trackname
end run

希望对您有所帮助!

这篇关于在iTunes中获取当前播放的歌曲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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