macOS 11.3で追加されたAVFAudio.frameworkを用いてオーディオ再生を行うAppleScriptです。
実行にはmacOS 11.3以降が必要です。オーディオファイル以外(ムービーなど)を渡すと終了します。
AppleScript名:AVFAudio test 1 |
— – Created by: Takaaki Naganoya – Created on: 2021/02/23 — – Copyright © 2021 Piyomaru Software, All Rights Reserved — use AppleScript version "2.7" — macOS 11.3 or later use framework "Foundation" use framework "AppKit" use framework "AVFAudio" use scripting additions set posixPath to POSIX path of (choose file with prompt "Choose an Audio file:") set theURL to current application’s |NSURL|’s fileURLWithPath:posixPath set aPlayer to current application’s AVAudioPlayer’s alloc()’s initWithContentsOfURL:theURL |error|:(missing value) if aPlayer = missing value then return aPlayer’s play() delay 30 aPlayer’s |stop|() |
More from my site
(Visited 232 times, 1 visits today)