Streaming 在iTunes中播放流而不将其添加到库/播放列表

Streaming 在iTunes中播放流而不将其添加到库/播放列表,streaming,applescript,itunes,Streaming,Applescript,Itunes,我通过AppleScript控制iTunes,播放来自HTTP服务器的流。我使用的代码如下所示: tell application "iTunes" open location "your_url_here" play end tell 它工作正常,但我希望避免这些URL出现在iTunes库或任何播放列表中。有什么技巧可以做到这一点吗?您是否考虑过使用QuickTimePlayer来播放流 tell application "QuickTime Player" open URL

我通过AppleScript控制iTunes,播放来自HTTP服务器的流。我使用的代码如下所示:

tell application "iTunes"
  open location "your_url_here"
  play
end tell

它工作正常,但我希望避免这些URL出现在iTunes库或任何播放列表中。有什么技巧可以做到这一点吗?

您是否考虑过使用QuickTimePlayer来播放流

tell application "QuickTime Player"
    open URL "http://www.a-1radio.com/listen.pls"
end tell
它应该打开所有iTunes格式,它在OsX上是默认的,它更“最小”,不会保存曲目

(我知道您指定要使用iTunes,所以这可能不是一个解决方案,但作为预装软件,值得一试)

编辑要将其隐藏,这似乎可行:

tell application "QuickTime Player"
    -- don't use launch or activate
    -- on my mac with launch I see a flicker of the window
    set numberOfWindows to (count windows)
    repeat with i from 1 to numberOfWindows
        close front window
    end repeat
end tell

-- may add some delay here if it still flickers the window
    -- delay 1

tell application "QuickTime Player"
    open URL "http://www.a-1radio.com/listen.pls"
    set visible of every window to false
end tell

tell application "System Events"
    set visible of process "QuickTime Player" to false
end tell

-- must be called after the open URL command or won't work (no idea why)
要关闭流,请退出或关闭窗口(如果计划重新打开,请关闭):

如果在打开url之前将其隐藏,它将不起作用(不知道为什么)。当然,窗口,即使不可见,仍然是打开的,因此如果有人单击dock图标,它将显示所有打开的窗口。
如果您不想停止以前的流,请删除顶部的第一个
repeat--end repeat
部分,但保留
将numberOfWindows设置为(count windows)
,这是无用的,但无需激活/启动命令即可激活应用程序

您考虑过改用QuickTimePlayer播放流吗

tell application "QuickTime Player"
    open URL "http://www.a-1radio.com/listen.pls"
end tell
它应该打开所有iTunes格式,它在OsX上是默认的,它更“最小”,不会保存曲目

(我知道您指定要使用iTunes,所以这可能不是一个解决方案,但作为预装软件,值得一试)

编辑要将其隐藏,这似乎可行:

tell application "QuickTime Player"
    -- don't use launch or activate
    -- on my mac with launch I see a flicker of the window
    set numberOfWindows to (count windows)
    repeat with i from 1 to numberOfWindows
        close front window
    end repeat
end tell

-- may add some delay here if it still flickers the window
    -- delay 1

tell application "QuickTime Player"
    open URL "http://www.a-1radio.com/listen.pls"
    set visible of every window to false
end tell

tell application "System Events"
    set visible of process "QuickTime Player" to false
end tell

-- must be called after the open URL command or won't work (no idea why)
要关闭流,请退出或关闭窗口(如果计划重新打开,请关闭):

如果在打开url之前将其隐藏,它将不起作用(不知道为什么)。当然,窗口,即使不可见,仍然是打开的,因此如果有人单击dock图标,它将显示所有打开的窗口。
如果您不想停止以前的流,请删除顶部的第一个
repeat--end repeat
部分,但保留
将numberOfWindows设置为(count windows)
,这是无用的,但无需激活/启动命令即可激活应用程序

有趣的想法,我将对QuickTime开放。但是,每次我打开URL时,它都会打开一个新窗口。你知道怎么避免吗?理想情况下,根本不会显示任何可见的UI,但是可以接受dock中的QuickTime符号。丹尼尔编辑的代码中没有一个新的窗口,可以永远播放歌曲。现在看来,在我的Mac上你需要的是工作,但是执行时间可能会稍微改变,所以在一个更快的Mac上,它可能会显示一个秒或不隐藏它的窗口(不确定)考虑测试或者添加评论的延迟(减慢执行)。有趣的想法,我会对QuikTimes开放。但是,每次我打开URL时,它都会打开一个新窗口。你知道怎么避免吗?理想情况下,根本不会显示任何可见的UI,但是可以接受dock中的QuickTime符号。丹尼尔编辑的代码中没有一个新的窗口,可以永远播放歌曲。现在看来,在我的Mac上你需要的工作,但执行时间可能会稍微改变行为,所以在一个更快的Mac上,它可能会显示窗口一秒或不隐藏它(不确定)考虑测试或添加一个延迟的评论说(减慢执行)。