Re: Pyglet help
@33
i have joined it like this, something went wrong.
import os.path
import glob
import pyglet
from pyglet.window import key
types = [".mp3", ".wav", ".flac", ".mp4", ".mpg", ".avi", ".m4a"]
types = str(types)
playlist = []
path = input("Enter the path to your music folder.")
letter = input("Name of the song? ")
print(os.getcwd())
#list directories
with os.scandir(path) as it:
for entry in it:
if not entry.name.startswith('.') and entry.is_file():
name = os.path.splitext(str(os.path.split(entry)[1]))
if letter in name[0].lower():
if name[1].lower() in types:
playlist += [name[0]+name[1]]
class Prototype(pyglet.window.Window):
def __init__(self):
super(Prototype, self).__init__(640, 480, resizable=False, fullscreen=False, caption="Test")
self.clear()
self.music = pyglet.media.StaticSource(pyglet.media.load('name[0]',streaming=False))
self.player = pyglet.media.Player()
pyglet.clock.schedule_interval(self.update, .01)
def update(self,dt):
if self.player.playing == False:
self.player.queue(self.music)
self.player.play()
#draw screen
self.draw()
def draw(self):
self.clear()
def on_key_press(self,symbol,modifiers):
if symbol == key.UP and self.player.volume < 2.0:
self.player.volume += 0.1
print(self.player.volume)
if symbol == key.DOWN and self.player.volume > 0.0:
self.player.volume -= 0.1
print(self.player.volume)
if symbol == key.LEFT:
print(self.player.time)
if self.player.time - 10.0 < 0.0:
self.player.seek(0.0)
else:
self.player.seek(self.player.time - 10.0)
print(self.player.time)
if symbol == key.RIGHT:
print(self.player.time)
get_duration = self.music.duration
if self.player.time + 10.0 > get_duration:
self.player.seek(get_duration)
else:
self.player.seek(self.player.time + 10.0)
print(self.player.time)
if symbol == key.ESCAPE:
self.close()
if __name__ == '__main__':
window = Prototype()
pyglet.app.run()
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector