wip
This commit is contained in:
parent
59060d6636
commit
32b1c54fbc
|
@ -110,6 +110,7 @@ class Controller:
|
|||
def handle_rfid_event(self, tagid):
|
||||
if tagid == bytes.fromhex("0000000000"):
|
||||
if self.audio_player.is_playing():
|
||||
print("Got 000 rfid -> playing off animation")
|
||||
self._run_off_animation()
|
||||
self.audio_player.pause()
|
||||
self.mmstate.figure_removed()
|
||||
|
@ -142,10 +143,13 @@ class Controller:
|
|||
elif message.direction == 1:
|
||||
self.audio_player.change_volume(-volume_increment)
|
||||
elif isinstance(message, ButtonEvent):
|
||||
if message.button == "left" and message.event == "pressed":
|
||||
self.audio_player.previous()
|
||||
elif message.button == "right" and message.event == "pressed":
|
||||
self.audio_player.next()
|
||||
btn = message.button
|
||||
if btn == "left" and message.event == "pressed" and self.audio_player.is_playing():
|
||||
res = self.audio_player.previous()
|
||||
print(f"Prev {res}")
|
||||
elif btn == "right" and message.event == "pressed" and self.audio_player.is_playing():
|
||||
res = self.audio_player.nex()
|
||||
print(f"Next {res}")
|
||||
elif message.button == "rotary" and message.event == "pressed":
|
||||
hass_service(self.hass, "light", "toggle", entity_id="light.kinderzimmer_fluter")
|
||||
elif isinstance(message, TouchButtonPress):
|
||||
|
@ -174,14 +178,6 @@ class Controller:
|
|||
"turn_on",
|
||||
entity_id="light.kinderzimmer_fluter",
|
||||
**colors[message.touch_button])
|
||||
#if message.touch_button == TouchButton.RIGHT_FOOT:
|
||||
# asyncio.create_task(
|
||||
# self.hass.call_service("switch", "toggle", {"entity_id": "switch.tasmota06"}))
|
||||
# asyncio.create_task(
|
||||
# self.hass.call_service("light", "turn_on", {"entity_id": "light.arbeitszimmer_fluter"}))
|
||||
#elif message.touch_button == TouchButton.LEFT_FOOT:
|
||||
# asyncio.create_task(
|
||||
# self.hass.call_service("light", "turn_off", {"entity_id": "light.arbeitszimmer_fluter"}))
|
||||
|
||||
elif isinstance(message, TouchButtonRelease):
|
||||
figure = self.mmstate.current_figure
|
||||
|
@ -216,6 +212,7 @@ class Controller:
|
|||
self.mmstate.mouse_led_effect(mouse_eff)
|
||||
|
||||
def _run_off_animation(self):
|
||||
print("Running off animation")
|
||||
ring_eff = EffectReverseSwipe()
|
||||
self.mmstate.led_ring_effect(ring_eff)
|
||||
|
||||
|
|
|
@ -77,10 +77,10 @@ class AudioPlayer:
|
|||
|
||||
evm = self.media_player.event_manager()
|
||||
evm.event_attach(vlc.EventType.MediaPlayerStopped, self._callback)
|
||||
evm.event_attach(vlc.EventType.MediaListEndReached, self._callback)
|
||||
|
||||
evm2 = self.media_list_player.event_manager()
|
||||
evm2.event_attach(vlc.EventType.MediaListEndReached, self._callback)
|
||||
evm2.event_attach(vlc.EventType.MediaListPlayerPlayed, self._callback)
|
||||
evm2.event_attach(vlc.EventType.MediaListPlayerStopped, self._callback)
|
||||
|
||||
self.on_playlist_end_callback = None
|
||||
|
||||
|
@ -91,16 +91,25 @@ class AudioPlayer:
|
|||
result = vlc.MediaList()
|
||||
for e in files:
|
||||
result.add_media(self.instance.media_new(e))
|
||||
|
||||
evm = result.event_manager()
|
||||
evm.event_attach(vlc.EventType.MediaListEndReached,
|
||||
lambda e: print("Ml CB", str(vlc.EventType(e.type))))
|
||||
evm.event_attach(vlc.EventType.MediaListItemAdded,
|
||||
lambda e: print("Ml ia CB", str(vlc.EventType(e.type))))
|
||||
|
||||
return result
|
||||
|
||||
def set_playlist(self, media_list):
|
||||
self.media_list_player.set_media_list(media_list)
|
||||
print("Setting media list of length ", media_list.count())
|
||||
self.media_list_player.set_playback_mode(vlc.PlaybackMode.default)
|
||||
|
||||
def next(self):
|
||||
self.media_list_player.next()
|
||||
return self.media_list_player.next()
|
||||
|
||||
def previous(self):
|
||||
self.media_list_player.previous()
|
||||
return self.media_list_player.previous()
|
||||
|
||||
def play(self):
|
||||
self.media_list_player.play()
|
||||
|
@ -115,10 +124,11 @@ class AudioPlayer:
|
|||
self.media_list_player.pause()
|
||||
|
||||
def _callback(self, event, *args, **kwargs):
|
||||
|
||||
if True: # event.type == vlc.EventType.MediaPlayerEndReached:
|
||||
#print("End reached")
|
||||
eventStr = str(vlc.EventType(event.type))
|
||||
print(f"Got vlc event type {event.type} {eventStr} , event {event}")
|
||||
if event.type == vlc.EventType.MediaPlayerStopped:
|
||||
if self.on_playlist_end_callback:
|
||||
print("Calling playlist end cb")
|
||||
self.on_playlist_end_callback()
|
||||
#print("Callback from VLC", event, args, kwargs)
|
||||
#print(event.meta_type, event.obj, event.type)
|
||||
|
@ -128,7 +138,6 @@ class AudioPlayer:
|
|||
volume = self.volume_min
|
||||
if self.volume_max and volume > self.volume_max:
|
||||
volume = self.volume_max
|
||||
print("volume", volume)
|
||||
self.media_player.audio_set_volume(volume)
|
||||
|
||||
def set_volume_limits(self, vmin, vmax):
|
||||
|
|
Loading…
Reference in New Issue