2
ので、私はコードを持っている:スレッドモジュールの質問
def Listen(filepath):
def play(filepath):
def play_music(music_file):
"""
stream music with mixer.music module in blocking manner
this will stream the sound from disk while playing
"""
clock = pygame.time.Clock()
pygame.mixer.music.load(music_file)
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
# check if playback has finished
clock.tick(30)
# pick a MP3 or MIDI music file you have ...
# (if not in working folder, use full path)
music_file = filepath
#music_file = "ChancesAre.mid"
# set up the mixer
freq = 44100 # audio CD quality
bitsize = -16 # unsigned 16 bit
channels = 2 # 1 is mono, 2 is stereo
buffer = 2048 # number of samples (experiment to get right sound)
pygame.mixer.init(freq, bitsize, channels, buffer)
# optional volume 0 to 1.0
pygame.mixer.music.set_volume(1.0)
play_music(music_file)
thread.start_new_thread(play,(filepath))
をし、私はエラーを取得:私はこのエラーを取得する理由
File "C:\Users\Desktop\WhaleTunes.py", line 59, in Listen
thread.start_new_thread(play,(filepath))
<type 'exceptions.TypeError'>: 2nd arg must be a tuple
誰でも知っていますか?
なぜタプルでなければならないのか分かりませんか? –
@salks:したがって、引数がゼロ、arg、または複数のargをとる関数の間に特別なケースはありません。あなたは常にタプルを渡します。 – FogleBird
明らかにメソッド/関数 'start_new_thread'が要求しているためです。 – Santa