Check if local subtitle file exists before loading it

Otherwise GStreamer will error out and playback will stop. Non-existing subtitle file is common on Flatpak when user tries to open/drop a file from a folder that container does not have access to.
This commit is contained in:
Rafał Dzięgiel
2021-04-09 10:55:06 +02:00
parent a3f78432f8
commit a39c67e5e7
2 changed files with 22 additions and 4 deletions

View File

@@ -126,6 +126,19 @@ function parsePlaylistFiles(filesArray)
return [filesArray, subs];
}
function getFileFromLocalUri(uri)
{
const file = Gio.file_new_for_uri(uri);
if(!file.query_exists(null)) {
debug(`file does not exist: ${file.get_path()}`, 'LEVEL_WARNING');
return null;
}
return file;
}
function encodeHTML(text)
{
return text.replace(/&/g, '&')