Rename project to "Clapper"

This commit is contained in:
Rafostar
2020-08-30 20:05:58 +02:00
parent 2b0ad406e5
commit ceb8930a88
3 changed files with 11 additions and 8 deletions

53
src/player.js Normal file
View File

@@ -0,0 +1,53 @@
const { GLib, GObject, Gst, GstPlayer } = imports.gi;
var GtkPlayer = GObject.registerClass(
class GtkPlayer extends GstPlayer.Player
{
_init()
{
let gtkglsink = Gst.ElementFactory.make('gtkglsink', null);
let glsinkbin = Gst.ElementFactory.make('glsinkbin', null);
glsinkbin.sink = gtkglsink;
let dispatcher = new GstPlayer.PlayerGMainContextSignalDispatcher();
let renderer = new GstPlayer.PlayerVideoOverlayVideoRenderer({
video_sink: glsinkbin
});
super._init({
signal_dispatcher: dispatcher,
video_renderer: renderer
});
this.loop = GLib.MainLoop.new(null, false);
this.widget = gtkglsink.widget;
this.state = GstPlayer.PlayerState.STOPPED;
this.connect('state_changed', this._onStateChanged.bind(this));
this.connect('uri_loaded', this._onUriLoaded.bind(this));
this.widget.connect('destroy', this._onWidgetDestroy.bind(this));
}
_onStateChanged(player, state)
{
this.state = state;
if(
this.state === GstPlayer.PlayerState.STOPPED
&& this.loop.is_running()
)
this.loop.quit();
}
_onUriLoaded()
{
this.play();
this.loop.run();
}
_onWidgetDestroy()
{
if(this.state !== GstPlayer.PlayerState.STOPPED)
this.stop();
}
});