发挥在iTunes流,而不将其添加到库/播放列表 [英] play a stream in iTunes without adding it to the library / playlist
问题描述
我控制通过AppleScript的iTunes和我从一个HTTP服务器播放流。在code我使用看起来像这样:
I am controlling iTunes via AppleScript and I am playing streams from an HTTP server. The code I'm using looks like this:
tell application "iTunes"
open location "your_url_here"
play
end tell
它工作正常,但我想避免这些URL中的iTunes资料库或播放列表,显示了算账。有没有窍门,以实现这一目标?
It works fine, but I would like to avoid those URLs to show up in the iTunes library or any playlist afterwards. Is there a trick to achieve that?
推荐答案
你有没有使用QuickTimePlayer播放的流,而不是考虑?
Have you considered using QuickTimePlayer to play the stream instead?
tell application "QuickTime Player"
open URL "http://www.a-1radio.com/listen.pls"
end tell
应打开所有iTunes的格式,它作为在OSX默认情况下,它更最小,将不保存曲目。
It should open all the iTunes formats, it comes as a default on OsX, it is more "minimal", won't save tracks.
(我知道你指定要使用iTunes所以这可能不是一个解决方案,但作为preinstalled软件这是值得一试)
(I know you specified you want to use iTunes so this might not be a solution, but being preinstalled software it was worth a try)
修改:要拥有它隐藏的,这似乎工作:
EDIT To have it hidden, this seems to work:
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)
要关闭该流而退出或关闭窗口(只是接近,如果你打算重新打开):
To close the stream either quit or close windows (just close if you plan to reopen):
tell application "QuickTime Player"
-- here you can either:
-- close all (will leave app open and hidden)
set numberOfWindows to (count windows)
repeat with i from 1 to numberOfWindows
close front window
end repeat
-- or:
quit -- or just quit (will close app so will need to hide again next time)
end tell
如果您打开URL之前隐藏它,它不工作(不知道为什么)。当然,窗口,即使看不见,仍然是开放的,所以如果有人点击该停靠图标,它会显示所有打开的窗口。
如果你不希望停止previous流删除第一个重复 - 重复结束
部分顶部,但离开集numberOfWindows以(计视窗)
这是无用的,但激活应用程序而无需激活/启动命令
If you hide it before opening the url, it doesn't work (no idea why). Of course the window, even if invisible, is still open so if someone clicks on the dock icon it will show all the open windows.
If you don't want to stop previous streams remove the first repeat -- end repeat
part at the top, but leave the set numberOfWindows to (count windows)
that is useless but activates the app without needing a activate/launch command
这篇关于发挥在iTunes流,而不将其添加到库/播放列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!