Implement Display events
This commit is contained in:
19
events.py
19
events.py
@@ -8,6 +8,8 @@ import display
|
||||
|
||||
import numpy as np
|
||||
|
||||
import pyglet.image
|
||||
|
||||
class Event:
|
||||
def __init__(self, at='start'):
|
||||
self._at = timings.Timing(at)
|
||||
@@ -46,10 +48,25 @@ class Event:
|
||||
pass
|
||||
|
||||
class Display(Event):
|
||||
def __init__(self, media, *args, **kwargs):
|
||||
def __init__(self, media, background=None, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self._media = media
|
||||
self._background = background
|
||||
self._image = pyglet.image.load(self._media)
|
||||
self._image.anchor_x = self._image.width // 2
|
||||
self._image.anchor_y = self._image.height // 2
|
||||
|
||||
def start(self):
|
||||
self._audiencecontent.new_content(display.DisplayImage(self._image, self._background))
|
||||
print("Started displaying image")
|
||||
|
||||
def stop(self):
|
||||
self._audiencecontent.new_content(display.DisplayContent())
|
||||
print("Stopped displaying image")
|
||||
|
||||
def notify(self, message, *args, **kwargs):
|
||||
if message == 'newdisplay':
|
||||
self._eventrunner.finished(self)
|
||||
|
||||
class Playback(Event):
|
||||
def __init__(self, media, device=None, channels=[1,2], tempo=None, beats=None, leadin=0, loop=False, gain=0, *args, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user