diff --git a/clapper_src/dialogs.js b/clapper_src/dialogs.js
index 80144bfc..c22d7c2c 100644
--- a/clapper_src/dialogs.js
+++ b/clapper_src/dialogs.js
@@ -158,6 +158,19 @@ class ClapperPrefsDialog extends Gtk.Dialog
}
]
},
+ {
+ title: 'Playback',
+ pages: [
+ {
+ title: 'Audio',
+ widget: Prefs.AudioPage,
+ },
+ {
+ title: 'Subtitles',
+ widget: Prefs.SubtitlesPage,
+ }
+ ]
+ },
{
title: 'Advanced',
pages: [
diff --git a/clapper_src/playerBase.js b/clapper_src/playerBase.js
index 2d4aec3f..47b4830f 100644
--- a/clapper_src/playerBase.js
+++ b/clapper_src/playerBase.js
@@ -82,6 +82,8 @@ class ClapperPlayerBase extends GstPlayer.Player
{
let settingsToSet = [
'seeking-mode',
+ 'audio-offset',
+ 'subtitle-offset',
];
for(let key of settingsToSet)
@@ -176,6 +178,8 @@ class ClapperPlayerBase extends GstPlayer.Player
_onSettingsKeyChanged(settings, key)
{
+ let value;
+
switch(key) {
case 'seeking-mode':
let isSeekMode = (typeof this.set_seek_mode !== 'undefined');
@@ -219,6 +223,16 @@ class ClapperPlayerBase extends GstPlayer.Player
root[action + '_css_class'](cssClass);
}
break;
+ case 'audio-offset':
+ value = Math.round(settings.get_double(key) * -1000000);
+ this.set_audio_video_offset(value);
+ debug(`set audio-video offset: ${value}`);
+ break;
+ case 'subtitle-offset':
+ value = Math.round(settings.get_double(key) * -1000000);
+ this.set_subtitle_video_offset(value);
+ debug(`set subtitle-video offset: ${value}`);
+ break;
default:
break;
}
diff --git a/clapper_src/prefs.js b/clapper_src/prefs.js
index b2865a4d..84ee475a 100644
--- a/clapper_src/prefs.js
+++ b/clapper_src/prefs.js
@@ -56,6 +56,30 @@ class ClapperBehaviourPage extends PrefsBase.Grid
}
});
+var AudioPage = GObject.registerClass(
+class ClapperAudioPage extends PrefsBase.Grid
+{
+ _init()
+ {
+ super._init();
+
+ this.addTitle('Synchronization');
+ this.addSpinButton('Offset (milliseconds)', -1000, 1000, 'audio-offset', 25);
+ }
+});
+
+var SubtitlesPage = GObject.registerClass(
+class ClapperSubtitlesPage extends PrefsBase.Grid
+{
+ _init()
+ {
+ super._init();
+
+ this.addTitle('Synchronization');
+ this.addSpinButton('Offset (milliseconds)', -5000, 5000, 'subtitle-offset', 25);
+ }
+});
+
var GStreamerPage = GObject.registerClass(
class ClapperGStreamerPage extends PrefsBase.Grid
{
diff --git a/clapper_src/prefsBase.js b/clapper_src/prefsBase.js
index 4bbc4b8b..5fac2c07 100644
--- a/clapper_src/prefsBase.js
+++ b/clapper_src/prefsBase.js
@@ -112,10 +112,10 @@ class ClapperPrefsGrid extends Gtk.Grid
return this.addToGrid(label, widget);
}
- addSpinButton(text, min, max, setting)
+ addSpinButton(text, min, max, setting, precision)
{
let label = this.getLabel(text + ':');
- let widget = this.getSpinButton(min, max, setting);
+ let widget = this.getSpinButton(min, max, setting, precision);
return this.addToGrid(label, widget);
}
@@ -162,11 +162,14 @@ class ClapperPrefsGrid extends Gtk.Grid
return comboBox;
}
- getSpinButton(min, max, setting)
+ getSpinButton(min, max, setting, precision)
{
+ precision = precision || 1;
+
let spinButton = new Gtk.SpinButton(this.widgetDefaults);
spinButton.set_range(min, max);
- spinButton.set_increments(1, 2);
+ spinButton.set_digits(precision % 1 === 0 ? 0 : 3);
+ spinButton.set_increments(precision, 1);
settings.bind(setting, spinButton, 'value', this.flag);
return spinButton;
diff --git a/data/com.github.rafostar.Clapper.gschema.xml b/data/com.github.rafostar.Clapper.gschema.xml
index 5deace13..74b449ab 100644
--- a/data/com.github.rafostar.Clapper.gschema.xml
+++ b/data/com.github.rafostar.Clapper.gschema.xml
@@ -33,6 +33,18 @@
Unit to use with seeking value
+
+
+ 0
+ Offset time for audio tracks relative to video (milliseconds)
+
+
+
+
+ 0
+ Offset time for subtitle tracks relative to video (milliseconds)
+
+
true