Support opening folders with media files

D&D folder with videos onto Clapper window to play them as video playlist. If folder contains exactly one video and subtitle file, then that video will be played with subtitles automatically applied.
This commit is contained in:
Rafał Dzięgiel
2021-04-20 18:44:53 +02:00
parent 0ab0b66825
commit 2e892c923b
4 changed files with 107 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
const { Gio, GLib, GObject, Gtk } = imports.gi;
const Debug = imports.src.debug;
const FileOps = imports.src.fileOps;
const Menu = imports.src.menu;
const Misc = imports.src.misc;
@@ -59,9 +60,18 @@ class ClapperAppBase extends Gtk.Application
);
}
_openFiles(files)
async _openFilesAsync(files)
{
const [playlist, subs] = Misc.parsePlaylistFiles(files);
const urisArr = [];
for(let file of files) {
/* If file is not a dir its URI will be returned in an array */
const uris = await FileOps.getDirFilesUrisPromise(file).catch(debug);
if(uris && uris.length)
urisArr.push(...uris);
}
const [playlist, subs] = Misc.parsePlaylistFiles(urisArr);
const { player } = this.active_window.get_child();
if(playlist && playlist.length)