import st3m.run, media from st3m.application import Application class App(Application): def __init__(self, app_ctx): super().__init__(app_ctx) self.path = "/sd/apps/paloma_blanca/output.mpg" # Exit per long-press RIGHT self._right_hold_ms = 0 def on_enter(self, vm): super().on_enter(vm) media.stop() media.load(self.path) media.play() def on_exit(self): media.stop() def think(self, ins, delta_ms): super().think(ins, delta_ms) # Media-Framework laufen lassen media.think(delta_ms) # DOWN: Play/Pause toggle if self.input.captouch.petals[5].whole.pressed: if media.is_playing(): media.pause() else: media.play() # Loop am Ende dur = media.get_duration() if dur > 0 and media.get_position() >= dur: media.seek(0.0) media.play() # EXIT: RIGHT long-press (800ms) if self.input.buttons.app.right.down: self._right_hold_ms += delta_ms if self._right_hold_ms > 800: self.vm.pop() else: self._right_hold_ms = 0 def draw(self, ctx): media.draw(ctx) if __name__ == "__main__": st3m.run.run_app(App)