mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 07:42:23 +02:00
Add audio and subtitle offset settings to prefs
This commit is contained in:
@@ -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: [
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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;
|
||||
|
@@ -33,6 +33,18 @@
|
||||
<summary>Unit to use with seeking value</summary>
|
||||
</key>
|
||||
|
||||
<!-- Audio -->
|
||||
<key name="audio-offset" type="d">
|
||||
<default>0</default>
|
||||
<summary>Offset time for audio tracks relative to video (milliseconds)</summary>
|
||||
</key>
|
||||
|
||||
<!-- Subtitles -->
|
||||
<key name="subtitle-offset" type="d">
|
||||
<default>0</default>
|
||||
<summary>Offset time for subtitle tracks relative to video (milliseconds)</summary>
|
||||
</key>
|
||||
|
||||
<!-- Tweaks -->
|
||||
<key name="render-shadows" type="b">
|
||||
<default>true</default>
|
||||
|
Reference in New Issue
Block a user