mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 00:11:59 +02:00
Support for multiple media files
This enables support for starting media player with more than one file path specified. When a file playback finishes, next is loaded automatically.
This commit is contained in:
@@ -264,10 +264,8 @@ var App = GObject.registerClass({
|
|||||||
this.player.widget.disconnect(this.playerDrawSignal);
|
this.player.widget.disconnect(this.playerDrawSignal);
|
||||||
this.emit('ready', true);
|
this.emit('ready', true);
|
||||||
|
|
||||||
if(!this.playlist.length)
|
if(this.playlist.length)
|
||||||
return;
|
this.player.set_playlist(this.playlist);
|
||||||
|
|
||||||
this.player.set_media(this.playlist[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onPlayerStateChanged(self, state)
|
_onPlayerStateChanged(self, state)
|
||||||
|
@@ -57,8 +57,12 @@ class ClapperPlayer extends GstPlayer.Player
|
|||||||
this.widget = gtkglsink.widget;
|
this.widget = gtkglsink.widget;
|
||||||
this.state = GstPlayer.PlayerState.STOPPED;
|
this.state = GstPlayer.PlayerState.STOPPED;
|
||||||
|
|
||||||
this.connect('state_changed', this._onStateChanged.bind(this));
|
this._playlist = [];
|
||||||
this.connect('uri_loaded', this._onUriLoaded.bind(this));
|
this._trackId = 0;
|
||||||
|
|
||||||
|
this.connect('state-changed', this._onStateChanged.bind(this));
|
||||||
|
this.connect('uri-loaded', this._onUriLoaded.bind(this));
|
||||||
|
this.connect('end-of-stream', this._onStreamEnded.bind(this));
|
||||||
this.widget.connect('destroy', this._onWidgetDestroy.bind(this));
|
this.widget.connect('destroy', this._onWidgetDestroy.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +87,22 @@ class ClapperPlayer extends GstPlayer.Player
|
|||||||
this.set_uri(uri);
|
this.set_uri(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_playlist(playlist)
|
||||||
|
{
|
||||||
|
if(!Array.isArray(playlist))
|
||||||
|
return;
|
||||||
|
|
||||||
|
this._trackId = 0;
|
||||||
|
this._playlist = playlist;
|
||||||
|
|
||||||
|
this.set_media(this._playlist[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
get_playlist()
|
||||||
|
{
|
||||||
|
return this._playlist;
|
||||||
|
}
|
||||||
|
|
||||||
seek_seconds(position)
|
seek_seconds(position)
|
||||||
{
|
{
|
||||||
this.seek(position * 1000000000);
|
this.seek(position * 1000000000);
|
||||||
@@ -115,6 +135,14 @@ class ClapperPlayer extends GstPlayer.Player
|
|||||||
this.loop.quit();
|
this.loop.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onStreamEnded(player)
|
||||||
|
{
|
||||||
|
this._trackId++;
|
||||||
|
|
||||||
|
if(this._trackId < this._playlist.length)
|
||||||
|
this.set_media(this._playlist[this._trackId]);
|
||||||
|
}
|
||||||
|
|
||||||
_onUriLoaded()
|
_onUriLoaded()
|
||||||
{
|
{
|
||||||
this.play();
|
this.play();
|
||||||
|
Reference in New Issue
Block a user