Re: Pyglet help
@magurp244
i've dealt with it a bit. Tried to seek sirtain position and it worked fine. However i wanted to try seek back and forward it didn't work. in fact, i should bind it to scaduel interval but, i couldn't make sure since duration property gives the total duration. code is below:
import pyglet
from pyglet.window import key
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('test.mp3',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()
get_duration = self.music.duration
print(get_duration)
#draw screen
self.draw()
def draw(self):
self.clear()
def on_key_press(self,symbol,modifiers):
forward = float(20)
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.RIGHT and self.player.time < 0.0:
self.player.seek(get_duration - 10.0)
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