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