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',
widget: Prefs.SubtitlesPage,
},
{
title: 'Network',
widget: Prefs.NetworkPage,
}
]
},

View File

@@ -88,6 +88,7 @@ class ClapperPlayerBase extends GstPlayer.Player
'seeking-mode',
'audio-offset',
'subtitle-offset',
'play-flags',
];
for(let key of settingsToSet)
@@ -256,6 +257,16 @@ class ClapperPlayerBase extends GstPlayer.Player
root[action + '_css_class'](brightClass);
debug(`${action} brighter sliders`);
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:
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 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(
class ClapperGStreamerPage extends PrefsBase.Grid
{

View File

@@ -127,6 +127,17 @@ class ClapperPrefsGrid extends Gtk.Grid
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)
{
let label = this.getLabel(text + ':');
@@ -188,6 +199,8 @@ class ClapperPrefsGrid extends Gtk.Grid
let checkButton = new Gtk.CheckButton({
label: text || null,
});
if(setting)
settings.bind(setting, checkButton, 'active', this.flag);
return checkButton;
@@ -204,6 +217,18 @@ class ClapperPrefsGrid extends Gtk.Grid
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)
{
if(name)

View File

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