Add progressive video download option

Buffer download whole network video during playback to allow fast seeking for online media. Can be disabled in prefs (enabled by default).
This commit is contained in:
Rafostar
2020-12-08 20:31:45 +01:00
parent 6ea210ff12
commit 8dfede27ac
5 changed files with 69 additions and 13 deletions

View File

@@ -196,6 +196,10 @@ class ClapperPrefsDialog extends Gtk.Dialog
{ {
title: 'Subtitles', title: 'Subtitles',
widget: Prefs.SubtitlesPage, widget: Prefs.SubtitlesPage,
},
{
title: 'Network',
widget: Prefs.NetworkPage,
} }
] ]
}, },

View File

@@ -88,6 +88,7 @@ class ClapperPlayerBase extends GstPlayer.Player
'seeking-mode', 'seeking-mode',
'audio-offset', 'audio-offset',
'subtitle-offset', 'subtitle-offset',
'play-flags',
]; ];
for(let key of settingsToSet) for(let key of settingsToSet)
@@ -256,6 +257,16 @@ class ClapperPlayerBase extends GstPlayer.Player
root[action + '_css_class'](brightClass); root[action + '_css_class'](brightClass);
debug(`${action} brighter sliders`); debug(`${action} brighter sliders`);
break; break;
case 'play-flags':
const initialFlags = this.pipeline.flags;
const settingsFlags = settings.get_int(key);
if(initialFlags === settingsFlags)
break;
this.pipeline.flags = settingsFlags;
debug(`changed play flags: ${initialFlags} -> ${settingsFlags}`);
break;
default: default:
break; break;
} }

View File

@@ -1,4 +1,4 @@
const { GObject, Gtk, Pango } = imports.gi; const { GObject, Gst, Gtk, Pango } = imports.gi;
const Misc = imports.clapper_src.misc; const Misc = imports.clapper_src.misc;
const PrefsBase = imports.clapper_src.prefsBase; const PrefsBase = imports.clapper_src.prefsBase;
@@ -85,6 +85,18 @@ class ClapperSubtitlesPage extends PrefsBase.Grid
} }
}); });
var NetworkPage = GObject.registerClass(
class ClapperNetworkPage extends PrefsBase.Grid
{
_init()
{
super._init();
this.addTitle('Client');
this.addPlayFlagCheckButton('Progressive download buffering', Gst.PlayFlags.DOWNLOAD);
}
});
var GStreamerPage = GObject.registerClass( var GStreamerPage = GObject.registerClass(
class ClapperGStreamerPage extends PrefsBase.Grid class ClapperGStreamerPage extends PrefsBase.Grid
{ {

View File

@@ -127,6 +127,17 @@ class ClapperPrefsGrid extends Gtk.Grid
return this.addToGrid(widget); return this.addToGrid(widget);
} }
addPlayFlagCheckButton(text, flag)
{
let checkButton = this.addCheckButton(text);
let playFlags = settings.get_int('play-flags');
checkButton.active = ((playFlags & flag) === flag);
checkButton.connect('toggled', this._onPlayFlagToggled.bind(this, flag));
return checkButton;
}
addFontButton(text, setting) addFontButton(text, setting)
{ {
let label = this.getLabel(text + ':'); let label = this.getLabel(text + ':');
@@ -188,7 +199,9 @@ class ClapperPrefsGrid extends Gtk.Grid
let checkButton = new Gtk.CheckButton({ let checkButton = new Gtk.CheckButton({
label: text || null, label: text || null,
}); });
settings.bind(setting, checkButton, 'active', this.flag);
if(setting)
settings.bind(setting, checkButton, 'active', this.flag);
return checkButton; return checkButton;
} }
@@ -204,6 +217,18 @@ class ClapperPrefsGrid extends Gtk.Grid
return fontButton; return fontButton;
} }
_onPlayFlagToggled(flag, button)
{
let playFlags = settings.get_int('play-flags');
if(button.active)
playFlags |= flag;
else
playFlags &= ~flag;
settings.set_int('play-flags', playFlags);
}
_onClose(name) _onClose(name)
{ {
if(name) if(name)

View File

@@ -6,10 +6,6 @@
<default>false</default> <default>false</default>
<summary>Automatically enter fullscreen when first file is loaded</summary> <summary>Automatically enter fullscreen when first file is loaded</summary>
</key> </key>
<key name="close-auto" type="b">
<default>false</default>
<summary>Automatically close the app after playback finishes</summary>
</key>
<key name="volume-initial" type="s"> <key name="volume-initial" type="s">
<default>"restore"</default> <default>"restore"</default>
<summary>Mode used for startup volume value</summary> <summary>Mode used for startup volume value</summary>
@@ -18,13 +14,9 @@
<default>100</default> <default>100</default>
<summary>Custom initial volume value in percentage after startup</summary> <summary>Custom initial volume value in percentage after startup</summary>
</key> </key>
<key name="dark-theme" type="b"> <key name="close-auto" type="b">
<default>true</default> <default>false</default>
<summary>Enable to force the app to use dark theme variant</summary> <summary>Automatically close the app after playback finishes</summary>
</key>
<key name="brighter-sliders" type="b">
<default>true</default>
<summary>Enable to make all sliders/bars brighter</summary>
</key> </key>
<!-- Behaviour --> <!-- Behaviour -->
@@ -58,6 +50,14 @@
</key> </key>
<!-- Tweaks --> <!-- Tweaks -->
<key name="dark-theme" type="b">
<default>true</default>
<summary>Enable to force the app to use dark theme variant</summary>
</key>
<key name="brighter-sliders" type="b">
<default>true</default>
<summary>Enable to make all sliders/bars brighter</summary>
</key>
<key name="render-shadows" type="b"> <key name="render-shadows" type="b">
<default>true</default> <default>true</default>
<summary>Enable rendering window shadows (only if theme has them)</summary> <summary>Enable rendering window shadows (only if theme has them)</summary>
@@ -68,6 +68,10 @@
<default>'[{"apply":false,"name":"vah264dec","rank":300}]'</default> <default>'[{"apply":false,"name":"vah264dec","rank":300}]'</default>
<summary>Custom values for GStreamer plugin ranking</summary> <summary>Custom values for GStreamer plugin ranking</summary>
</key> </key>
<key name="play-flags" type="i">
<default>1687</default>
<summary>Set PlayFlags for playbin</summary>
</key>
<!-- Other --> <!-- Other -->
<key name="window-size" type="s"> <key name="window-size" type="s">