Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sound on/off (0 mute 9 unmute) key commands #500

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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