diff --git a/lazy_player/__init__.py b/lazy_player/__init__.py index 292283d..e7061b5 100644 --- a/lazy_player/__init__.py +++ b/lazy_player/__init__.py @@ -1,6 +1,7 @@ from __future__ import annotations import os +import sys from pathlib import Path from typing import Any, cast @@ -53,11 +54,14 @@ class MainWindow(Gtk.ApplicationWindow): # Setup GStreamer pipeline self.pipeline = Gst.Pipeline.new("video-player") - playbin = Gst.ElementFactory.make("playbin", "playbin") - video_sink = Gst.ElementFactory.make("gtk4paintablesink", "gtk4paintablesink") - if not playbin or not video_sink: - raise RuntimeError("Required GStreamer elements could not be created") + playbin = Gst.ElementFactory.make("playbin", "playbin") + if not playbin: + raise RuntimeError("Failed to create playbin element") + + video_sink = Gst.ElementFactory.make("gtk4paintablesink", "gtk4paintablesink") + if not video_sink: + raise RuntimeError("Failed to create gtk4paintablesink element") playbin.set_property("video-sink", video_sink) self.pipeline.add(playbin) @@ -235,5 +239,8 @@ class App(Gtk.Application): def main(): + if len(sys.argv) >= 2: + os.chdir(sys.argv[1]) + app = App() app.run(None)