mute vs volume

Discuss your Lua playlist, album art and interface scripts.
Chalisque
New Cone
New Cone
Posts: 4
Joined: 20 Dec 2015 00:33

mute vs volume

Postby Chalisque » 23 Jan 2023 22:52

In the normal VLC gui volume control (and via menus), we can both mute audio and adjust the volume. It is possible to have nonzero volume but mute engaged (resulting in no audio), and zero volume but mute disengaged (resulting in no audio).

If mute is engaged via the GUI, I can't find the command or lua function to toggle the mute on and off. (Also it does not appear to be able to control this via the HTTP interface either.)

Is there some reason why this is not possible, or is it just something I've missed?

Chalisque
New Cone
New Cone
Posts: 4
Joined: 20 Dec 2015 00:33

Re: mute vs volume

Postby Chalisque » 23 Jan 2023 23:22

It would seem to only take a few extra lines in modules/lua/libs/volume.c in order to enable this.

I've not yet tried building VLC from source as it seems a bit of an undertaking. Having had a dig around the source, one quick hack would be to add something like the following to volume.c (or else add an extra lua module for controlling mute) (I note that the qt gui

(This should be viewed as a sketch of the desired code -- I've not compiled this, let alone tested it.)

Code: Select all

static int get_muted() { vlc_playlist_t *playlist = vlclua_get_playlist_internal(L); vlc_player_t *player = vlc_playlist_GetPlayer(playlist); return vlc_player_aout_IsMuted(player); } static int set_mute(int muted) { vlc_playlist_t *playlist = vlclua_get_playlist_internal(L); vlc_player_t *player = vlc_playlist_GetPlayer(playlist); vlc_player_Lock( player ); vlc_player_aout_Mute( player, muted ); vlc_player_Unlock( player ); } static int vlclua_get_mute(lua_State *L) { long muted = get_muted(); lua_pushnumber(L, muted); } static int vlclua_volume_set_mute(lua_State *L) { int i_mute = luaL_checkinteger(L, 1); set_mute(!!i_mute); } static int vlclua_toggle_mute(lua_State *L) { int muted = !get_muted(); set_mute(muted); } /***************************************************************************** * *****************************************************************************/ static const luaL_Reg vlclua_volume_reg[] = { { "get", vlclua_volume_get }, { "set", vlclua_volume_set }, { "up", vlclua_volume_up }, { "down", vlclua_volume_down }, { "get_mute", vlclua_get_mute }, { "set_mute", vlclua_set_mute }, { "toggle_mute", vlclua_toggle_mute }, { NULL, NULL } };


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 2 guests