Support loading files using full or relative paths

This commit is contained in:
Rafostar
2020-09-08 08:58:43 +02:00
parent 689edd9cf3
commit 649ff7682c
3 changed files with 26 additions and 5 deletions

View File

@@ -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 |
| ------- | --- | ----- |

View File

@@ -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)

View File

@@ -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);