Skip to content

Commit

Permalink
develop #comment Add functionality to increase/decrease subtitle's de…
Browse files Browse the repository at this point in the history
…lay.

 - Fix displayed video shifting time on the buttons (10 mins to 5 mins).
  • Loading branch information
Luc Sinet committed Feb 23, 2019
1 parent 6de62d4 commit fe8198c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
7 changes: 7 additions & 0 deletions OpenCast/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from dbus import DBusException

from omxplayer import keys
from omxplayer.player import (
OMXPlayer,
OMXPlayerDeadError,
Expand Down Expand Up @@ -123,6 +124,12 @@ def toggle_subtitle(self):
else:
self._exec_command('hide_subtitles')

def increase_subtitle_delay(self):
self._exec_command('action', keys.INCREASE_SUBTITLE_DELAY)

def decrease_subtitle_delay(self):
self._exec_command('action', keys.DECREASE_SUBTITLE_DELAY)

def change_volume(self, increase):
with self._cv:
volume = self._volume
Expand Down
4 changes: 4 additions & 0 deletions OpenCast/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ def _subtitle(self):
logger.debug("Subtitle command received: {}".format(action))
if action == 'toggle':
self._controller.toggle_subtitle()
elif action == 'increase':
self._controller.shift_subtitle(True)
elif action == 'decrease':
self._controller.shift_subtitle(False)

def _running(self):
return 1
Expand Down
6 changes: 6 additions & 0 deletions OpenCast/video_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ def play_pause_video(self):
def toggle_subtitle(self):
self._player.toggle_subtitle()

def shift_subtitle(self, increase):
if increase:
self._player.increase_subtitle_delay()
else:
self._player.decrease_subtitle_delay()

def change_volume(self, increase):
self._player.change_volume(increase)
logger.debug("[controller] change player volume, increase: {}"
Expand Down
8 changes: 8 additions & 0 deletions static/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,12 @@ $(function() {
$("#toggle-subtitle-btn").click(function() {
mkRequest("/subtitle?action=toggle")
});

$("#inc-subtitle-delay").click(function() {
mkRequest("/subtitle?action=increase")
});
$("#dec-subtitle-delay").click(function() {
mkRequest("/subtitle?action=decrease")
});

});
15 changes: 13 additions & 2 deletions views/remote.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@
<div class='button-line'>
<button id="long-backward-btn" class="button-left btn btn-info" type="button" title="Long skip backwards">
<span class="glyphicon glyphicon-backward pull-left"></span>
<span class="tb">-10 minutes</span>
<span class="tb">-5 minutes</span>
</button>
<button id="long-forward-btn" class="button-right btn btn-info" type="button" title="Long skip backwards">
<span class="tb">+10 minutes</span>
<span class="tb">+5 minutes</span>
<span class="glyphicon glyphicon-forward pull-right"></span>
</button>
</div>
Expand All @@ -87,6 +87,17 @@
</button>
</div>

<div class='button-line'>
<button id="dec-subtitle-delay" class="button-left btn btn-primary" type="button" title="Decrease delay">
<span class="glyphicon glyphicon-backward pull-left"></span>
<span class="tb">Decrease delay</span>
</button>
<button id="inc-subtitle-delay" class="button-right btn btn-primary" type="button" title="Increase delay">
<span class="tb">Increase delay</span>
<span class="glyphicon glyphicon-forward pull-right"></span>
</button>
</div>

<!-- History and playlist management -->
<div class='button-line'>
<button id="history-btn" class="btn btn-warning button-large" type="button" title="History" onClick="showHistory()">
Expand Down

0 comments on commit fe8198c

Please sign in to comment.