[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4668: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3815)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4670: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3815)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4671: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3815)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4672: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3815)
XWidgetSoft Forum • View topic - Play 2 sounds/mute

XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently April 16th, 2024, 10:58 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Play 2 sounds/mute
PostPosted: February 23rd, 2016, 3:30 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
I need a litle help making this script..
I have two sounds (wav) and I want to use two right click options to play each one separately (on/off). Like this:

(right click options)
sound 1 on/off (checked/unchecked)
sound 2 on/off (checked/unchecked)

- When the sound 1 will play the sound 2 will mute. Conversely for the sound 2.
- 3rd option to mute both (all sounds)
- save ini for the sound status

Thanks in advance :)

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
 Post subject: Re: Play 2 sounds/mute
PostPosted: February 23rd, 2016, 5:51 am 
Offline
User avatar

Joined: July 29th, 2013, 9:13 am
Posts: 609
For the right click, you'll need to add three options to the default menu - Xwidget engine does not have the concept of context sensitive menus specific to the assigned object so you have to add the options to the default right click menu.



Note: Xwidget menu options cannot be built dynamically in code so you just have to create the menus statically by hand in the designer..

Then it is a matter of assigning a function to each menu option incorporating the command playsound. As the Xwidget engine cannot handle the playing of more than one sound simultaneously, playing one sound will automatically mute the other. In this case this suits your requirement. The third menu option can play a blank wav file to mute any currently running sound. When the mute option is chosen, subsequently decide either to avoid using the playsound command or simply play a null sound instead.

One method of saving your prefs is done by having a hidden layer containing hidden text or memo boxes - see my U-Boat widget for how I typically do it.

Each text box is named as a preference variable according to its function.
My hidden prefs layer is called: showWidgetPreferences
My text boxes are named as such: preferencesHintPrefValue - this naming convention allows easy conversion to a yahoo widget which uses the following naming convention : preferences.hintPref.value .

The function getprefs is called when the widget starts:

//===========================================
// this function runs on startup
//===========================================
function widgetOnLoad() {
getPrefs();
}

//=========================================================================
// this function sets the preference values to saved values
//=========================================================================
function getPrefs(){
preferenceshoffsetprefvalue.text = Getinivalue(widgetpath+"prefs.ini","prefs","preferenceshoffsetprefvalue","350");
preferencesvoffsetprefvalue.text = Getinivalue(widgetpath+"prefs.ini","prefs","preferencesvoffsetprefvalue","350");
preferenceswidgetTooltipvalue.text = Getinivalue(widgetpath+"prefs.ini","prefs","preferenceswidgetTooltipvalue","Double-Click on me to set the widget command");
preferencesimageCmdPrefvalue.text = Getinivalue(widgetpath+"prefs.ini","prefs","preferencesimageCmdPrefvalue","");
print("preferencesclockSizevalue.percent "+preferencesclockSizevalue.percent);
preferencessoundprefvalue.text = Getinivalue(widgetpath+"prefs.ini","prefs","preferencessoundprefvalue","enabled");
preferencesclockSizevalue.percent = Getinivalue(widgetpath+"prefs.ini","prefs","preferencesclockSizevalue","100");
preferencesLicenceHideValue.text = Getinivalue(widgetpath+"prefs.ini","prefs","preferencesLicenceHideValue",0);
preferencesMouseWheelPrefValue.text = Getinivalue(widgetpath+"prefs.ini","prefs","preferencesMouseWheelPrefValue","up");
preferencesHintPrefValue.text = Getinivalue(widgetpath+"prefs.ini","prefs","preferencesHintPrefValue","enabled");
preferencesclockFaceSwitchPrefvalue.text = Getinivalue(widgetpath+"prefs.ini","prefs","preferencesclockFaceSwitchPrefvalue","stopwatch");
preferenceswidgetLockLandscapeModePrefvalue .text = Getinivalue(widgetpath+"prefs.ini","prefs","preferenceswidgetLockLandscapeModePrefvalue","enabled");

print("preferencesHintPrefValue.text "+preferencesHintPrefValue.text);

if (preferencessoundprefvalue.text != "disabled") {
soundbutton.src="bellpushed.png"; // this in place of a checkbutton which I could not get to work correctly
} else {
soundbutton.src="bell.png";
}
PlaySound(soundbutton);
}
//=====================
//End function
//=====================

As soon as the above function is called it plays a sound according to the value set in one of the prefs.

//=========================================================================
// this function saves the preferences to an ini file for later use
//=========================================================================
function SavePrefs()
{
print ("Saving Prefs ");
Setinivalue(widgetpath+"prefs.ini","prefs","preferenceshoffsetprefvalue",preferenceshoffsetprefvalue.text);
Setinivalue(widgetpath+"prefs.ini","prefs","preferencesvoffsetprefvalue",preferencesvoffsetprefvalue.text);
Setinivalue(widgetpath+"prefs.ini","prefs","preferenceswidgetTooltipvalue",preferenceswidgetTooltipvalue.text);
//print("preferencesimageCmdPrefvalue.text "+preferencesimageCmdPrefvalue.text);
Setinivalue(widgetpath+"prefs.ini","prefs","preferencesimageCmdPrefvalue",preferencesimageCmdPrefvalue.text);
Setinivalue(widgetpath+"prefs.ini","prefs","preferencessoundprefvalue",preferencessoundprefvalue.text);
Setinivalue(widgetpath+"prefs.ini","prefs","preferencesclockSizevalue",preferencesclockSizevalue.percent);
Setinivalue(widgetpath+"prefs.ini","prefs","preferencesLicenceHideValue",preferencesLicenceHideValue.text);
Setinivalue(widgetpath+"prefs.ini","prefs","preferencesMouseWheelPrefValue",preferencesMouseWheelPrefValue.text);
Setinivalue(widgetpath+"prefs.ini","prefs","preferencesHintPrefValue",preferencesHintPrefValue.text);
Setinivalue(widgetpath+"prefs.ini","prefs","preferencesclockFaceSwitchPrefvalue",preferencesclockFaceSwitchPrefvalue.text);
Setinivalue(widgetpath+"prefs.ini","prefs","preferenceswidgetLockLandscapeModePrefvalue",preferenceswidgetLockLandscapeModePrefvalue.text);


print("preferencesHintPrefValue.text "+preferencesHintPrefValue.text);

}
//=====================
//End function
//=====================


This shows how I get settings from an ini file and how I save them too. Sometimes I have to create the ini file manually the first time they are used. My hidden prefs layer can be made visible on request so I have a nice and pretty underlying image that holds the text boxes and descriptions. This allows you to view all the fields and change the preferences they hold manually. I make the preferences layer visible from the right click menu using a menu option named "Show Preferences" that runs this command showWidgetPreferences.visible = true; to make the layer and all the contained objects visible.



This is taken directly from the style of the konfabulator/Yahoo widget engine that has built-in functionality to provide a GUI for the storage and handling of preferences. I have my own radio boxes showing here as I had problems making the Xwidget engine's radio buttons work the way I wanted them to.


Top
 Profile  
 
 Post subject: Re: Play 2 sounds/mute
PostPosted: February 23rd, 2016, 6:31 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Are you sure that it needs to be so complicated...? :?
Because as you know, in java there are more than one ways to assign the same function..

I was thinking like more simple like I did (with help) for this widget:
http://jimking.deviantart.com/art/Cucko ... -385323459

Please take a look at the script.

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
 Post subject: Re: Play 2 sounds/mute
PostPosted: February 23rd, 2016, 8:00 am 
Offline
User avatar

Joined: July 29th, 2013, 9:13 am
Posts: 609


Top
 Profile  
 
 Post subject: Re: Play 2 sounds/mute
PostPosted: February 23rd, 2016, 8:07 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
The fact yereverluvinuncleber is that before ask for help I tried some things.. The script that I used in the "Cuckoo Clock" widget is only for one sound. I tried to edit it but at the end I had only errors..
Also I tested yesterday and the "Xwidget engine cannot handle the playing of more than one sound simultaneously, playing one sound will automatically mute the other." not works exactly like this because appears to be a conflit with more than one sounds and with the wrong script, the sound appears corrupted when you don't mute or completely stop the second one.

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
 Post subject: Re: Play 2 sounds/mute
PostPosted: February 23rd, 2016, 8:48 am 
Offline
User avatar

Joined: July 29th, 2013, 9:13 am
Posts: 609
Ah OK.

Do you remember my bug that I raised where playing more than one sound produced strange results? On my two laptop PCs, playing one sound stopped another from playing. Send me the script that is causing distortion and I'll check it here. If it does the same then we may have more of a sound bug.

I suggest that you try playing a blank sound instead. See if that helps. I used that trick sometimes when I had a sound overrun. I'd have to see/try your script in order to help any further.


Top
 Profile  
 
 Post subject: Re: Play 2 sounds/mute
PostPosted: February 25th, 2016, 3:12 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: Google [Bot] and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

Powered by phpBB® Forum Software © phpBB Group