我試圖讓使用Python + PyObjC一個簡單的音樂流應用以下this blogPyObjC - 流媒體音樂與NSSound
import Foundation
from AppKit import NSSound
sound = NSSound.alloc()
url = Foundation.NSURL.URLWithString_("http://206.217.213.235:8050/")
sound.initWithContentsOfURL_byReference_(url, True)
sound.play()
,也未能
>>> sound.play()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: cannot access attribute 'play' of NIL 'NSSound' object
爲什麼?