camera: always fullscreen, fix inverted vo logic, fixes #839
This commit is contained in:
parent
e4d5cd65ce
commit
1f5a090bfd
@ -29,12 +29,12 @@ class CameraPanel(ScreenPanel):
|
|||||||
self.content.add(box)
|
self.content.add(box)
|
||||||
self.content.show_all()
|
self.content.show_all()
|
||||||
self.url = self.ks_printer_cfg.get("camera_url", "http://127.0.0.1/webcam/?action=stream").replace('"', '')
|
self.url = self.ks_printer_cfg.get("camera_url", "http://127.0.0.1/webcam/?action=stream").replace('"', '')
|
||||||
logging.debug(f"Camera URL: {self.url}")
|
|
||||||
# wayland has no primary monitor with that we can detect it
|
# wayland has no primary monitor with that we can detect it
|
||||||
self.wayland = Gdk.Display.get_default().get_primary_monitor() is None
|
self.wayland = Gdk.Display.get_default().get_primary_monitor() is None
|
||||||
# gpu output driver doesn't work on a pi3 and the autoselected sdl doesn't size correctly
|
# gpu output driver doesn't work on a pi3 and the autoselected sdl doesn't size correctly
|
||||||
# consider adding a software switch to enable the gpu backend if set by the user
|
# consider adding a software switch to enable the gpu backend if set by the user
|
||||||
self.vo = 'x11' if self.wayland else 'wlshm'
|
self.vo = 'wlshm' if self.wayland else 'x11'
|
||||||
|
logging.debug(f"Camera URL: {self.url} vo: {self.vo} wayland: {self.wayland}")
|
||||||
|
|
||||||
def activate(self):
|
def activate(self):
|
||||||
self.play()
|
self.play()
|
||||||
@ -45,6 +45,9 @@ class CameraPanel(ScreenPanel):
|
|||||||
self.mpv = None
|
self.mpv = None
|
||||||
|
|
||||||
def play(self, fs=None):
|
def play(self, fs=None):
|
||||||
|
if self.mpv:
|
||||||
|
self.mpv.terminate()
|
||||||
|
self.mpv = None
|
||||||
# Create mpv after show or the 'window' property will be None
|
# Create mpv after show or the 'window' property will be None
|
||||||
self.mpv = mpv.MPV(
|
self.mpv = mpv.MPV(
|
||||||
log_handler=self.log,
|
log_handler=self.log,
|
||||||
@ -53,32 +56,29 @@ class CameraPanel(ScreenPanel):
|
|||||||
)
|
)
|
||||||
# On wayland mpv cannot be embedded at least for now
|
# On wayland mpv cannot be embedded at least for now
|
||||||
# https://github.com/mpv-player/mpv/issues/9654
|
# https://github.com/mpv-player/mpv/issues/9654
|
||||||
if fs or self.wayland:
|
# if fs or self.wayland:
|
||||||
self.mpv.fullscreen = True
|
self.mpv.fullscreen = True
|
||||||
|
|
||||||
@self.mpv.on_key_press('MBTN_LEFT' or 'MBTN_LEFT_DBL')
|
@self.mpv.on_key_press('MBTN_LEFT' or 'MBTN_LEFT_DBL')
|
||||||
def clicked():
|
def clicked():
|
||||||
self.mpv.quit(0)
|
self.mpv.quit(0)
|
||||||
else:
|
# else:
|
||||||
self.mpv.wid = f'{self.da.get_property("window").get_xid()}'
|
# self.mpv.wid = f'{self.da.get_property("window").get_xid()}'
|
||||||
|
#
|
||||||
@self.mpv.on_key_press('MBTN_LEFT' or 'MBTN_LEFT_DBL')
|
# @self.mpv.on_key_press('MBTN_LEFT' or 'MBTN_LEFT_DBL')
|
||||||
def clicked():
|
# def clicked():
|
||||||
self._screen.show_popup_message(self.url, level=1)
|
# self._screen.show_popup_message(self.url, level=1)
|
||||||
self.mpv.play(self.url)
|
self.mpv.play(self.url)
|
||||||
if fs or self.wayland:
|
# if fs or self.wayland:
|
||||||
try:
|
try:
|
||||||
self.mpv.wait_for_playback()
|
self.mpv.wait_for_playback()
|
||||||
except mpv.ShutdownError:
|
except mpv.ShutdownError:
|
||||||
logging.info('Exiting Fullscreen')
|
logging.info('Exiting Fullscreen')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
self.mpv.terminate()
|
self.mpv.terminate()
|
||||||
self.mpv = None
|
self.mpv = None
|
||||||
if self.wayland:
|
self._screen._menu_go_back()
|
||||||
self._screen._menu_go_back()
|
|
||||||
else:
|
|
||||||
self.play()
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def log(loglevel, component, message):
|
def log(loglevel, component, message):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user