Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 在apple脚本中播放自定义捆绑声音_Macos_Shell_Applescript - Fatal编程技术网

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

Macos 在apple脚本中播放自定义捆绑声音,macos,shell,applescript,Macos,Shell,Applescript,因此,我试图在applescript中使用shellscript“afplay”来播放我捆绑到应用程序资源中的.m4a文件。不完全确定它是如何工作的 经过一番搜索后得到了这个 set soundPath to POSIX path of (path to resource "Sound File.aiff") do shell script "afplay " & quoted form of soundPath 这不是我真正想要的 您真正想要什么?假设“Sound File.aif

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

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

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

do shell script "afplay " & quoted form of soundPath

这不是我真正想要的

您真正想要什么?假设“Sound File.aiff”位于应用程序包的资源文件夹中,那么这两行代码确实会播放声音。你说“这不是我真正想要的。”却没有说你想要什么!好。。我只需要一些能播放我编入剧本的声音的东西,但我太笨了:(谢谢!但是如何设置我捆绑到应用程序中的声音的路径?如果声音文件在应用程序捆绑包的resources文件夹中..这就是这行代码所指向的..只需将实际文件名更改为任何文件名。'将audioFile设置为resource“sound file.aiff”的路径'
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
*)