Skip to content

Commit

Permalink
Sound on/off (0 mute 9 unmute) key commands
Browse files Browse the repository at this point in the history
+ apply @Kennyyy24 OMXControl.patch
  • Loading branch information
xk committed Nov 29, 2016
1 parent 12b472e commit 2d24019
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
6 changes: 6 additions & 0 deletions KeyConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ int convertStringToAction(string str_action)
return KeyConfig::ACTION_SHOW_SUBTITLES;
if(str_action == "HIDE_SUBTITLES")
return KeyConfig::ACTION_HIDE_SUBTITLES;
if(str_action == "MUTE")
return KeyConfig::ACTION_MUTE;
if(str_action == "UNMUTE")
return KeyConfig::ACTION_UNMUTE;

return -1;
}
Expand Down Expand Up @@ -128,6 +132,8 @@ map<int, int> KeyConfig::buildDefaultKeymap()
keymap['v'] = ACTION_STEP;
keymap['w'] = ACTION_SHOW_SUBTITLES;
keymap['x'] = ACTION_HIDE_SUBTITLES;
keymap['0'] = ACTION_MUTE;
keymap['9'] = ACTION_UNMUTE;

return keymap;
}
Expand Down
2 changes: 2 additions & 0 deletions KeyConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class KeyConfig
ACTION_CROP_VIDEO = 34,
ACTION_PAUSE = 35,
ACTION_PLAY = 36,
ACTION_MUTE = 37,
ACTION_UNMUTE = 38,
};

#define KEY_LEFT 0x5b44
Expand Down
12 changes: 4 additions & 8 deletions OMXControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,17 +695,15 @@ OMXControlResult OMXControl::handle_event(DBusMessage *m)
}
else if (dbus_message_is_method_call(m, DBUS_INTERFACE_PROPERTIES, "Mute"))
{
audio->SetMute(true);
dbus_respond_ok(m);
deprecatedMessage();
return KeyConfig::ACTION_BLANK;
return KeyConfig::ACTION_MUTE;
}
else if (dbus_message_is_method_call(m, DBUS_INTERFACE_PROPERTIES, "Unmute"))
{
audio->SetMute(false);
dbus_respond_ok(m);
deprecatedMessage();
return KeyConfig::ACTION_BLANK;
return KeyConfig::ACTION_UNMUTE;
}
else if (dbus_message_is_method_call(m, DBUS_INTERFACE_PROPERTIES, "Position"))
{
Expand Down Expand Up @@ -901,15 +899,13 @@ OMXControlResult OMXControl::handle_event(DBusMessage *m)
}
else if (dbus_message_is_method_call(m, OMXPLAYER_DBUS_INTERFACE_PLAYER, "Mute"))
{
audio->SetMute(true);
dbus_respond_ok(m);
return KeyConfig::ACTION_BLANK;
return KeyConfig::ACTION_MUTE;
}
else if (dbus_message_is_method_call(m, OMXPLAYER_DBUS_INTERFACE_PLAYER, "Unmute"))
{
audio->SetMute(false);
dbus_respond_ok(m);
return KeyConfig::ACTION_BLANK;
return KeyConfig::ACTION_UNMUTE;
}
else if (dbus_message_is_method_call(m, OMXPLAYER_DBUS_INTERFACE_PLAYER, "ListSubtitles"))
{
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ Key bindings to control omxplayer while playing:

1 decrease speed
2 increase speed
9 unmute
0 mute
< rewind
> fast forward
z show info
Expand Down Expand Up @@ -175,6 +177,8 @@ The list of valid [action]s roughly corresponds to the list of default key bindi
SEEK_BACK_LARGE
SEEK_FORWARD_LARGE
STEP
MUTE
UNMUTE

Valid [key]s include all alpha-numeric characters and most symbols, as well as:

Expand Down
10 changes: 10 additions & 0 deletions omxplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,16 @@ int main(int argc, char *argv[])
m_Volume / 100.0f));
printf("Current Volume: %.2fdB\n", m_Volume / 100.0f);
break;
case KeyConfig::ACTION_MUTE:
m_player_audio.SetMute(true);
DISPLAY_TEXT_SHORT("Sound OFF");
printf("Sound OFF\n");
break;
case KeyConfig::ACTION_UNMUTE:
m_player_audio.SetMute(false);
DISPLAY_TEXT_SHORT("Sound ON");
printf("Sound ON\n");
break;
default:
break;
}
Expand Down

0 comments on commit 2d24019

Please sign in to comment.