mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 16:02:00 +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:
@@ -57,8 +57,12 @@ class ClapperPlayer extends GstPlayer.Player
|
||||
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._playlist = [];
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -83,6 +87,22 @@ class ClapperPlayer extends GstPlayer.Player
|
||||
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)
|
||||
{
|
||||
this.seek(position * 1000000000);
|
||||
@@ -115,6 +135,14 @@ class ClapperPlayer extends GstPlayer.Player
|
||||
this.loop.quit();
|
||||
}
|
||||
|
||||
_onStreamEnded(player)
|
||||
{
|
||||
this._trackId++;
|
||||
|
||||
if(this._trackId < this._playlist.length)
|
||||
this.set_media(this._playlist[this._trackId]);
|
||||
}
|
||||
|
||||
_onUriLoaded()
|
||||
{
|
||||
this.play();
|
||||
|
Reference in New Issue
Block a user