【问题标题】:AppleScriptObjC: Can't create AVMIDIPlayer objectAppleScriptObjC:无法创建 AVMIDIPlayer 对象
【发布时间】:2018-03-29 01:29:25
【问题描述】:

我在处理一些 AppleScript ObjC 代码时遇到了一些问题。问题似乎出在我初始化 AVMIDIPlayer 对象时(第三行重复)。它返回 -1 错误 (AVAudioEngineManualRenderingStatusError)。然后下一行失败,因为 Nil 对象没有任何方法。

以下是相关位:

property NSURL : a reference to current application's NSURL
property AVMIDIPlayer : a reference to current application's AVMIDIPlayer
on open (filelist)
    repeat with each_item in filelist
        set myfile to quoted form of POSIX path of each_item as string
        set myMIDIFile to (NSURL's fileURLWithPath:myfile)
        set {myMIDIPlayer, theError} to (AVMIDIPlayer's alloc()'s initWithContentsOfURL:myMIDIFile soundBankURL:none |error|:(reference))
        myMIDIPlayer's prepareToPlay()
        myMIDIPlayer's play(myHandler)

【问题讨论】:

    标签: applescript applescript-objc


    【解决方案1】:

    问题原因是quoted form of

    do shell script 行中使用它来转义包含空格和特殊字符的字符串,别处。

    set myfile to POSIX path of each_item -- no coercion: POSIX path is string
    

    并处理theError?

    【讨论】:

    • 谢谢。我还必须进行一些其他调整,但这似乎有所帮助。
    猜你喜欢
    • 1970-01-01
    • 2015-03-19
    • 2013-10-22
    • 2017-10-01
    • 2013-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多