Author Topic: [solved] global video-sound-mute switch via layout options  (Read 5180 times)

verion

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 861
    • View Profile
    • new projects
[solved] global video-sound-mute switch via layout options
« on: December 13, 2015, 02:48:23 PM »
I would like to provide a global switch via layout options that will mute video sound (for every video in layout).
Below you will find my code.


Code: [Select]
//define layout option entry
class UserConfig {
</ label="Mute video snaps sound", help="yes = sound disabled, no = sound enabled", options="yes,no" /> mute_videoSnaps="no";
}



//when mute sound = YES in layout options - define variable "videoSound" (that will be used globally)
//that will mute sound
if ( my_config["mute_videoSnaps"] == "yes")
{
 local videoSound = Vid.NoAudio;
}


//video an cab screen
local cabScreen = fe.add_artwork ("snap", 300, 300, 400, 300);
cabScreen.video_flags = videoSound;

Unfortunately - this is not working :(

If I hard code
local videoSound = Vid.NoAudio;
it is working correctly.
But when I try to make this happend via layout options - no go.

---

I'll just add that I know that video sound can be disabled globally in AM (in SOUND options) - but I want it to be disabled for particular layout, not for all layouts.
« Last Edit: December 14, 2015, 10:04:04 AM by verion »

raygun

  • Administrator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
Re: [help] global video-sound-mute switch via layout options
« Reply #1 on: December 13, 2015, 03:00:15 PM »
Hey verion, it looks like your videoSound local is going out of scope right after you set it.  Either declare it outside of the curly brackets or declare it in the root table and that should fix things for you.

cheers

verion

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 861
    • View Profile
    • new projects
Re: [help] global video-sound-mute switch via layout options
« Reply #2 on: December 14, 2015, 10:03:37 AM »
Thanks for your help.
Your comment actually made me reading about squirrel just to understand what you are saying. Well... more karma for me :)

I'm pasting the corrected (working) code in case someone wants to copy-paste it.

Code: [Select]
if ( my_config["mute_videoSnaps"] == "yes")
{
::videoSound <- Vid.NoAudio;
}
if ( my_config["mute_videoSnaps"] == "no")
{
::videoSound <- Vid.Default;
}

Code: [Select]
//video an cab screen
local cabScreen = fe.add_artwork ("snap", 300, 300, 400, 300);
cabScreen.video_flags = videoSound;

---