Answer the question
In order to leave comments, you need to log in
Pyglet How to play next audio file?
Hey! Faced a problem with audio playback in pyglet.
Problem: When I downloaded and played the 1st file and after 5 seconds I try to download the 2nd file and play it, nothing comes out!
The code:
import pyglet
from time import sleep
player = pyglet.media.Player()
Music_Path ="C:\\file.mp3"
file = pyglet.media.load(Music_Path)
player.queue(file)
player.play()
sleep(5)
Music_Path2 ="C:\\file2.mp3"
file2 = pyglet.media.load(Music_Path2)
player.queue(file2)
player.play()
sleep(6)
Answer the question
In order to leave comments, you need to log in
Found a solution!
import pyglet
from time import sleep
player = pyglet.media.Player()
Music_Path ="C:\\file.mp3"
file = pyglet.media.load(Music_Path)
player.queue(file)
player.play()
sleep(5)
player.on_eos() # ВОТ ФУНКЦИЯ ДЛЯ ВОСПРОИЗВЕДЕНИЯ СЛЕДУЮЩИХ ФАЙЛОВ(но точнее я её так использовал)
Music_Path2 ="C:\\file2.mp3"
file2 = pyglet.media.load(Music_Path2)
player.queue(file2)
player.play()
sleep(6)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question