mirror of
https://github.com/Rafostar/clapper.git
synced 2025-09-01 00:41:58 +02:00
Convenient ways of opening external subtitles
Play video with external subtiles by: * selecting and opening both video+subs from file chooser/manager * dropping subtitles file on player window * opening subtiles from file chooser/manager while video plays * send their file path/uri to player via WebSocket message
This commit is contained in:
30
src/misc.js
30
src/misc.js
@@ -5,6 +5,9 @@ const { debug } = Debug;
|
||||
|
||||
var appName = 'Clapper';
|
||||
var appId = 'com.github.rafostar.Clapper';
|
||||
var subsMimes = [
|
||||
'application/x-subrip',
|
||||
];
|
||||
|
||||
var clapperPath = null;
|
||||
var clapperVersion = null;
|
||||
@@ -96,6 +99,33 @@ function getFormattedTime(time, showHours)
|
||||
return parsed + `${minutes}:${seconds}`;
|
||||
}
|
||||
|
||||
function parsePlaylistFiles(filesArray)
|
||||
{
|
||||
let index = filesArray.length;
|
||||
let subs = null;
|
||||
|
||||
while(index--) {
|
||||
const file = filesArray[index];
|
||||
const filename = (file.get_basename)
|
||||
? file.get_basename()
|
||||
: file.substring(file.lastIndexOf('/') + 1);
|
||||
|
||||
const [type, isUncertain] = Gio.content_type_guess(filename, null);
|
||||
|
||||
if(subsMimes.includes(type)) {
|
||||
subs = file;
|
||||
filesArray.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* We only support single video
|
||||
* with external subtitles */
|
||||
if(subs && filesArray.length > 1)
|
||||
subs = null;
|
||||
|
||||
return [filesArray, subs];
|
||||
}
|
||||
|
||||
function encodeHTML(text)
|
||||
{
|
||||
return text.replace(/&/g, '&')
|
||||
|
Reference in New Issue
Block a user