mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-29 23:32:04 +02:00
Add append_playlist function
This commit is contained in:
@@ -17,6 +17,7 @@ class ClapperAppBase extends Gtk.Application
|
||||
});
|
||||
|
||||
this.doneFirstActivate = false;
|
||||
this.isFileAppend = false;
|
||||
}
|
||||
|
||||
vfunc_startup()
|
||||
@@ -79,11 +80,15 @@ class ClapperAppBase extends Gtk.Application
|
||||
|
||||
const [playlist, subs] = Misc.parsePlaylistFiles(urisArr);
|
||||
const { player } = this.active_window.get_child();
|
||||
const action = (this.isFileAppend) ? 'append' : 'set';
|
||||
|
||||
if(playlist && playlist.length)
|
||||
player.set_playlist(playlist);
|
||||
player[`${action}_playlist`](playlist);
|
||||
if(subs)
|
||||
player.set_subtitles(subs);
|
||||
|
||||
/* Restore default behavior */
|
||||
this.isFileAppend = false;
|
||||
}
|
||||
|
||||
_onFirstActivate()
|
||||
|
@@ -221,19 +221,33 @@ class ClapperPlayer extends GstClapper.Clapper
|
||||
if(this.state !== GstClapper.ClapperState.STOPPED)
|
||||
this.stop();
|
||||
|
||||
debug('new playlist');
|
||||
|
||||
this.playlistWidget.removeAll();
|
||||
this.canAutoFullscreen = true;
|
||||
|
||||
for(let source of playlist) {
|
||||
const uri = this._getSourceUri(source);
|
||||
this.playlistWidget.addItem(uri);
|
||||
}
|
||||
this._addPlaylistItems(playlist);
|
||||
|
||||
/* If not mapped yet, first track will play after map */
|
||||
if(this.windowMapped)
|
||||
this._playFirstTrack();
|
||||
}
|
||||
|
||||
append_playlist(playlist)
|
||||
{
|
||||
debug('appending playlist');
|
||||
this._addPlaylistItems(playlist);
|
||||
|
||||
if(
|
||||
!this.windowMapped
|
||||
|| this.state !== GstClapper.ClapperState.STOPPED
|
||||
)
|
||||
return;
|
||||
|
||||
if(!this.playlistWidget.nextTrack())
|
||||
debug('playlist append failed');
|
||||
}
|
||||
|
||||
set_subtitles(source)
|
||||
{
|
||||
const uri = this._getSourceUri(source);
|
||||
@@ -370,6 +384,7 @@ class ClapperPlayer extends GstClapper.Clapper
|
||||
case 'play':
|
||||
case 'pause':
|
||||
case 'set_playlist':
|
||||
case 'append_playlist':
|
||||
case 'set_subtitles':
|
||||
this[action](value);
|
||||
break;
|
||||
@@ -394,6 +409,16 @@ class ClapperPlayer extends GstClapper.Clapper
|
||||
}
|
||||
}
|
||||
|
||||
_addPlaylistItems(playlist)
|
||||
{
|
||||
for(let source of playlist) {
|
||||
const uri = this._getSourceUri(source);
|
||||
|
||||
debug(`added uri: ${uri}`);
|
||||
this.playlistWidget.addItem(uri);
|
||||
}
|
||||
}
|
||||
|
||||
_getSourceUri(source)
|
||||
{
|
||||
return (source.get_uri != null)
|
||||
|
Reference in New Issue
Block a user