首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过Objective-C获取iTunes轨迹的当前时间?

如何通过Objective-C获取iTunes轨迹的当前时间?
EN

Stack Overflow用户
提问于 2012-07-25 02:28:59
回答 2查看 816关注 0票数 0

我目前使用的是一些脚本接口(ScriptingBridge?)生成的iTunes头文件。我可以得到当前正在播放的歌曲的名称

代码语言:javascript
复制
[[iTunes currentTrack] name];

但是我似乎不能得到歌曲播放的当前时间。我现在没有使用Applescript。

编辑:明确通过ScriptingBridge生成。我用以下命令生成了标题

代码语言:javascript
复制
sdef /Applications/iTunes.app | sdp -fh --basename iTunes
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-07-25 04:33:33

找到了: iTunes playerPosition

票数 3
EN

Stack Overflow用户

发布于 2012-07-25 04:01:44

这是AppleScript;我知道您没有使用它,但是我不知道如何使用Scripting Bridge来实现它。据我所知,该方法应该类似但更接近objective-c语法。

代码语言:javascript
复制
tell application "iTunes"
set this_time to time of current track as string
set elapsed_seconds to player position
set this_elapsed_minutes to round elapsed_seconds / 60 rounding down
set this_elapsed_seconds to elapsed_seconds mod 60
if {1, 2, 3, 4, 5, 6, 7, 8, 9, 0} contains this_elapsed_seconds then
set this_elapsed_seconds to "0" & (this_elapsed_seconds as string)
end if
end tell    

return (this_elapsed_minutes & ":" & this_elapsed_seconds & " of " & this_time) as text --
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11637067

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档