mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 07:42:23 +02:00
Use custom getUriProtocol function
Gst.Uri.get_protocol function is very simple. It just splits string by ":" and return the first part. We can do the same in JS and by doing that we do not have to initialize GStreamer just to get this function.
This commit is contained in:
@@ -140,6 +140,13 @@ function getFileFromLocalUri(uri)
|
||||
return file;
|
||||
}
|
||||
|
||||
/* JS replacement of "Gst.Uri.get_protocol" */
|
||||
function getUriProtocol(uri)
|
||||
{
|
||||
const arr = uri.split(':');
|
||||
return (arr.length > 1) ? arr[0] : null;
|
||||
}
|
||||
|
||||
function encodeHTML(text)
|
||||
{
|
||||
return text.replace(/&/g, '&')
|
||||
|
@@ -141,7 +141,7 @@ class ClapperPlayer extends GstClapper.Clapper
|
||||
{
|
||||
this.customVideoTitle = null;
|
||||
|
||||
if(Gst.Uri.get_protocol(uri) !== 'file') {
|
||||
if(Misc.getUriProtocol(uri) !== 'file') {
|
||||
const [isYouTubeUri, videoId] = YouTube.checkYouTubeUri(uri);
|
||||
|
||||
if(!isYouTubeUri)
|
||||
@@ -256,7 +256,7 @@ class ClapperPlayer extends GstClapper.Clapper
|
||||
|
||||
/* Check local file existence */
|
||||
if(
|
||||
Gst.Uri.get_protocol(uri) === 'file'
|
||||
Misc.getUriProtocol(uri) === 'file'
|
||||
&& !Misc.getFileFromLocalUri(uri)
|
||||
)
|
||||
return;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
const { Gdk, GLib, GObject, Gst, Gtk, Pango } = imports.gi;
|
||||
const { Gdk, GLib, GObject, Gtk, Pango } = imports.gi;
|
||||
const Debug = imports.src.debug;
|
||||
const Misc = imports.src.misc;
|
||||
|
||||
const { debug, warn } = Debug;
|
||||
|
||||
@@ -245,7 +246,7 @@ class ClapperPlaylistItem extends Gtk.ListBoxRow
|
||||
this.isLocalFile = false;
|
||||
|
||||
let filename;
|
||||
if(Gst.Uri.get_protocol(uri) === 'file') {
|
||||
if(Misc.getUriProtocol(uri) === 'file') {
|
||||
filename = GLib.path_get_basename(
|
||||
GLib.filename_from_uri(uri)[0]
|
||||
);
|
||||
|
Reference in New Issue
Block a user