在Apple脚本中播放自定义捆绑声音

时间:2017-10-30 05:41:00

标签: macos shell applescript

所以我试图在applescript中使用shellscript“afplay”来播放我捆绑到app资源中的.m4a文件。不完全确定它是如何工作的。

经过一番搜索后得到了这个,

set soundPath to POSIX path of (path to resource "Sound File.aiff")

do shell script "afplay " & quoted form of soundPath

这不是我想要的。

1 个答案:

答案 0 :(得分:0)

playAudio() -- place this Line To call the handler to Play An Audio File.    

on playAudio()
    set audioFile to path to resource "Sound File.aiff"
    set theFile to POSIX path of audioFile
    do shell script "afplay  -q 1 -t 25 " & " " & quoted form of theFile
end playAudio



-- Command Line OPTIONS For Playing Audio Files
(*
afplay [option...] audio_file

Options: (may appear before or after arguments)
  {-v | --volume} VOLUME
    set the volume for playback of the file
  {-h | --help}
    print help
  { --leaks}
    run leaks analysis
  {-t | --time} TIME
    play for TIME seconds
  {-r | --rate} RATE
    play at playback rate
  {-q | --rQuality} QUALITY
    set the quality used for rate-scaled playback (default is 0 - low quality, 1 - high quality)
  {-d | --debug}
    debug print output
*)