diff --git a/src/misc.js b/src/misc.js index 03783c88..999b28bb 100644 --- a/src/misc.js +++ b/src/misc.js @@ -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, '&') diff --git a/src/player.js b/src/player.js index 083ec9c3..1e5ca55e 100644 --- a/src/player.js +++ b/src/player.js @@ -60,10 +60,8 @@ class ClapperPlayer extends PlayerBase return; } - let file = Gio.file_new_for_uri(uri); - if(!file.query_exists(null)) { - debug(`file does not exist: ${file.get_path()}`, 'LEVEL_WARNING'); - + const file = Misc.getFileFromLocalUri(uri); + if(!file) { if(!this.playlistWidget.nextTrack()) debug('set media reached end of playlist'); @@ -160,6 +158,13 @@ class ClapperPlayer extends PlayerBase { const uri = this._getSourceUri(source); + /* Check local file existence */ + if( + Gst.Uri.get_protocol(uri) === 'file' + && !Misc.getFileFromLocalUri(uri) + ) + return; + this.set_subtitle_uri(uri); this.set_subtitle_track_enabled(true);