diff --git a/README.md b/README.md index 5281091f..87b96fe7 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ A GNOME media player built using [GJS](https://gitlab.gnome.org/GNOME/gjs) and powered by [GStreamer](https://gstreamer.freedesktop.org) with [OpenGL](https://www.opengl.org) rendering. Can also be used as a pre-made widget for [GTK](https://www.gtk.org) apps. ### WORK IN PROGRESS -This is still early WIP. Many features are not implemented yet and quite a few are still unstable. Right now Clapper can only play single file from URI. So if you want to test it, start it from terminal like this: +This is still early WIP. Many features are not implemented yet and quite a few are still unstable. Right now Clapper can only play single file. So if you want to test it, start it from terminal like this: ```shell -clapper file:///path/to/video.mkv +clapper video.mp4 ``` ## Requirements Clapper uses `GStreamer` bindings from `GI` repository, so if your repo ships them as separate package, they must be installed first. @@ -38,7 +38,7 @@ On some older GPUs you might need to export `GST_VAAPI_ALL_DRIVERS=1` environmen Other acceleration methods (supported by `GStreamer`) should also work, but I have not tested them due to lack of hardware. ## Performace Comparison -Here is the average **CPU** and **RAM** usage (lower is better) when playing the same H.264 1080p video in Clapper and [Totem](https://wiki.gnome.org/Apps/Videos) (GNOME Videos) with **VA-API enabled** on an old AMD APU: +Here is the average **CPU** and **RAM** usage (lower is better) when playing the same H.264 1080p video in Clapper and [Totem](https://wiki.gnome.org/Apps/Videos) (GNOME Videos) with **VA-API available** on an old AMD APU: | Player | CPU | RAM | | ------- | --- | ----- | diff --git a/clapper_src/app.js b/clapper_src/app.js index 57544e70..e82913d7 100644 --- a/clapper_src/app.js +++ b/clapper_src/app.js @@ -249,7 +249,7 @@ var App = GObject.registerClass({ if(!this.playlist.length) return; - this.player.set_uri(this.playlist[0]); + this.player.set_media(this.playlist[0]); } _onPlayerStateChanged(self, state) diff --git a/clapper_src/player.js b/clapper_src/player.js index b9f63cb5..8c364afd 100644 --- a/clapper_src/player.js +++ b/clapper_src/player.js @@ -1,4 +1,4 @@ -const { GLib, GObject, Gst, GstPlayer } = imports.gi; +const { Gio, GLib, GObject, Gst, GstPlayer } = imports.gi; const Debug = imports.clapper_src.debug; const GSTPLAYER_DEFAULTS = { @@ -62,6 +62,27 @@ class ClapperPlayer extends GstPlayer.Player this.widget.connect('destroy', this._onWidgetDestroy.bind(this)); } + set_media(source) + { + if(Gst.uri_is_valid(source)) { + debug(`setting source URI: ${source}`); + return this.set_uri(source); + } + + debug(`parsing source: ${source}`); + let uri = Gst.filename_to_uri(source); + + if(!uri) + return debug('parsing to URI failed'); + + debug(`parsed source to URI: ${uri}`); + + if(!Gio.file_new_for_uri(uri).query_exists(null)) + return debug(`file does not exist: ${source}`, 'LEVEL_WARNING'); + + this.set_uri(uri); + } + seek_seconds(position) { this.seek(position * 1000000000);