推 jjandy:我也想知道 06/17 12:14
推 EmptySmile:pygame.init() 06/17 12:42
→ EmptySmile:pygame.mixer.Sound(waveFile).play() 06/17 12:43
多謝 檔案讀進去了 但出現錯誤
以下是我的code
------------------------------------------------------
import pygame.mixer
import urllib2
import time
URL = ("http://163.20.58.2/edisk/demo/sound/0001.WAV")
response = urllib2.urlopen(URL)
waveFile = response.read()
pygame.mixer.init()
pygame.mixer.Sound(waveFile).play()
while pygame.mixer.get_busy():
time.sleep(0.1)
------------------------------------------------------
播放時出現error 在
time.sleep(0.1)
TypeError: argument 1 must be string without null bytes, not str
(見鬼...)
如果改成
------------------------------------------------------
while pygame.mixer.get_busy():
print ('playing...')
------------------------------------------------------
播放時會出現一個很短暫的高頻音 然後跳出
Exception exceptions.TypeError: 'argument 1 must be string
without null bytes, not str' in <module 'threading'
from 'C:\Python25\lib\threading.pyc'> ignored
※ 編輯: Maiyo 來自: 210.202.48.60 (06/17 14:24)
→ EmptySmile:...um...pygame不是很熟...只好等高手們來解了... 06/17 15:08
→ EmptySmile:您要不要試試看抓檔下來播放. 06/17 15:28
→ Maiyo:檔案在本地端播放一切正常 但需求是播放網路上的檔... 06/17 15:35
→ EmptySmile:我知道...我意思是python抓檔下來自己播放 06/17 15:40
→ Maiyo:呃... 這個會安裝GStreamer 如果我最後用py2exe包出檔案 06/17 17:10
→ Maiyo:有辦法在沒有安裝GStreamer的電腦上執行嗎? 06/17 17:10
→ Maiyo:如果要額外安裝別的軟體 還不如直接用java... /_\ 06/17 17:12