XWidgetSoft Forum https://www.bbs.xwidget.com/ |
|
Clock/hours sound https://www.bbs.xwidget.com/viewtopic.php?f=7&t=3345 |
Page 1 of 1 |
Author: | Jimking [ July 6th, 2013, 3:25 am ] |
Post subject: | Clock/hours sound |
I have a Cuckoo Clock widget and I want to assign the sounds (ticktack and the 12 notifications sounds for the hours) I have already the 13 sounds in mp3 but I need help with the script code (or not needed?) For example: 1mp3 file> play at 1:00 2mp3 file>play at 2:00 etc Also an image that will appear at the same time with the sounds (the open window with the bird) And of course how create the right click options to switch on/off the sounds... Thank you! |
Author: | kenneth112 [ July 13th, 2013, 3:44 am ] |
Post subject: | Re: Clock/hours sound |
xwidget support "WAV" audio formats only,you must transcoding the mp3 file Code: function datetimecore1OnUpdate(Sender) { var d = new date()//create a date object var hour = d.getHours(); //get hours var minute = d.getMinutes;//get minutes var second = d.getSeconds();//get seconds if(minute==0&&second==0&&menuitem1.checked)//judge the integral point & menuitem1 checked { playsound(eval(hour)+".wav");//playsound image1.visible = true; //image appear sleep(3000);//image appears duration ,unit is millisecond image1.visible = false; //image disappear } } function menuitem1OnClick(Sender) { Sender.checked = !Sender.checked; } afte"//" is the code comments |
Author: | Jimking [ July 13th, 2013, 5:15 am ] |
Post subject: | Re: Clock/hours sound |
WOW! 1000 thanks kenneth112! ![]() Yes I saw that supports wav files but this is the easy part.. I need more clarifications: Quote: after"//" is the code comments 1) So I have to delete this parts? ![]() 2) This code is for one hour, so I have to repeat this ,changing the values, for 12 times? 3) Also the clock has two rotators (hour/minute) and an image below for the shake animation (tictac) So this part: Quote: var d = new date()//create a date object is useless? Or the code must be like this... 4) How assign or where I have to put the sounds? |
Author: | kenneth112 [ July 13th, 2013, 6:24 am ] |
Post subject: | Re: Clock/hours sound |
the code is used JS Object ,not the xwidget core.so it does not matter with your design. var d = new date() it's not useless |
Author: | Jimking [ July 13th, 2013, 6:30 am ] |
Post subject: | Re: Clock/hours sound |
I understand kenneth! But what about the 1,2 and 4 questions...? |
Author: | kenneth112 [ July 13th, 2013, 12:28 pm ] |
Post subject: | Re: Clock/hours sound |
jimking wrote: I understand kenneth! But what about the 1,2 and 4 questions...? 1)//is the code comments by javascript,you don't need to delete them,you can write any thing after //,it is a dedicated programmer notes 2) the code is 24 hours a cycle ,once per hour ,you must have 24 wav files and their name is 0.wav 1.wav 2.wav……23.wav if you want to chang the 12 hours a cycle ,use this code Code: function datetimecore1OnUpdate(Sender) { var d = new date()//create a date object var hour = d.getHours(); //get hours if(hour>=12) { hour = hour - 12; } else if(hour ==0) { hour = 12; } var minute = d.getMinutes;//get minutes var second = d.getSeconds();//get seconds if(minute==0&&second==0&&menuitem1.checked)//judge the integral point & menuitem1 checked { playsound(eval(hour)+".wav");//playsound image1.visible = true; //image appear sleep(3000);//image appears duration ,unit is millisecond image1.visible = false; //image disappear } } function menuitem1OnClick(Sender) { Sender.checked = !Sender.checked; } used this code ,you only need 12 wav files 4) put the wav files in your widget root directory |
Author: | kenneth112 [ July 13th, 2013, 12:37 pm ] |
Post subject: | Re: Clock/hours sound |
Code: image1.visible = true; //image appear sleep(3000);//image appears duration ,unit is millisecond image1.visible = false; //image disappear in this code ,cuckoo image components whose name I assume is image1,if the image components' name is cuckoo or something else ,you must change your components name. |
Author: | Jimking [ July 13th, 2013, 1:15 pm ] |
Post subject: | Re: Clock/hours sound |
Really appreciated your help! I'll try to follow your Instructions and I hope that will make it work! . Sorry for all these questions but this kind of script is new for me.. Thank u |
Author: | kenneth112 [ July 13th, 2013, 1:30 pm ] |
Post subject: | Re: Clock/hours sound |
jimking wrote: Really appreciated your help! I'll try to follow your Instructions and I hope that will make it work! . Sorry for all these questions but this kind of script is new for me.. Thank u i forgot one thing , the 12 hour a cycle code wav name is 1.wav 2.wav …… 12.wav |
Author: | Jimking [ July 13th, 2013, 1:37 pm ] |
Post subject: | Re: Clock/hours sound |
Ok! One more thing.. About the right click menu (sound On/Off) is enough create the menuitem1, add the "menuitem1OnClick" code (without select any code) and check the "checked" option? For the tictac consecutive sound? I would like to add this sound too with the other when the widget load and disable/enable all the sounds together.. |
Author: | kenneth112 [ July 13th, 2013, 2:18 pm ] |
Post subject: | Re: Clock/hours sound |
check the checked option as you like ,if you checked ,by default sound on,not checked ,by default sound off. What’s the meaning tictac consecutive ? if you want to control other things by this checked ,add the judgment like this code Code: if(menuitem1.checked) { playsound("abc.wav") } the code means if the menuitem1 is checked ,play the abc.wav file |
Author: | Jimking [ July 13th, 2013, 3:10 pm ] |
Post subject: | Re: Clock/hours sound |
Quote: What’s the meaning tictac consecutive ? I mean that I have one more .wav file that reproduce the tictac sound and I would like to match it with the shake animation. So I would like to make it this sound work with the other sounds everytime that the widget load, turn off with the other and play/loop continuously... Quote: var d = new date()//create a date object When I press Debug to test the widget appears a script error (Runtime Error: the "Date" is not set) The widget has these components: image3: the tictac with shake animation clock: the clock background image hourrotator minuterotator center: an image for the middle of the clock hands image1: the bird's image |
Author: | meme [ July 13th, 2013, 3:54 pm ] |
Post subject: | Re: Clock/hours sound |
Try var d = new Date();//create a date object |
Author: | Jimking [ July 13th, 2013, 4:08 pm ] |
Post subject: | Re: Clock/hours sound |
This works meme! Thanks! ![]() The error disappeared. One damm ;and change everything! I don't know though why when uncheck the right click option the tictac sound keeps playing... ![]() I found it. The tictac sound that I use has duration 59sec. The Xwidget loads the sound, so you have to wait until all the sound plays and then stops! CRAZY! So I cut the tictac sound to 6sec and this is ok... |
Author: | Jimking [ July 13th, 2013, 4:19 pm ] |
Post subject: | Re: Clock/hours sound |
The sounds and the funtion of the bird still not work... ![]() I did all that kenneth said, I put the 1-12 wav files to the widget's folder, I use the 12h script code but nothing.. The bird image appears from the begging and no sounds play... Damm... Also the "image appears duration" should be variable with the bell sound / hour. The value is 3000 msec and this will be good for 3:00 hours but for the rest no.. That's why I thought that needs a script code x12 times and change the msec value each time. |
Author: | Jimking [ July 13th, 2013, 4:43 pm ] |
Post subject: | Re: Clock/hours sound |
Here is the widget for test it by yourself... I became a headache for you guys. Sorry! ![]() |
Author: | kenneth112 [ July 13th, 2013, 7:40 pm ] | ||
Post subject: | Re: Clock/hours sound | ||
my code has some problem,it's OK now.
|
Author: | meme [ July 13th, 2013, 11:22 pm ] |
Post subject: | Re: Clock/hours sound |
On my computer the hands of the clock did not indicate the time in the download from kenneth112 until I changed the datetimecore1 Format Code Data Tags to %HourPercent and %MinutePercent. Is that only on my computer ? The bird appears and sounds plays OK, but if sound in not checked the bird does not appear, the bird only appears if menuitem1 is checked, is that what you intended ? |
Author: | Jimking [ July 14th, 2013, 12:27 am ] |
Post subject: | Re: Clock/hours sound |
kenneth112 wrote: my code has some problem,it's OK now. Thank you VERYYYY MUCH for spend all this time and help me!!! ![]() meme wrote: On my computer the hands of the clock did not indicate the time in the download from kenneth112 until I changed the datetimecore1 Format Code Data Tags to %HourPercent and %MinutePercent. Is that only on my computer ? The bird appears and sounds plays OK, but if sound in not checked the bird does not appear, the bird only appears if menuitem1 is checked, is that what you intended ? About the %codes "issue" is because Tony makes some changes to the Designer to add suport for Android. I and kenneth112 I suppose we use a patch version of the Designer. When Tony will post the final version the codes will work ok! ![]() About the second part I prefer that the bird appears even with the sound off... I tried and I fixed it!!! Now the bird appears even with the sound off! ![]() I will test it some more and I will post the final version of the widget today! Maybe I will find a more calm and discreet sound for the tictac...I'll see.. |
Author: | Jimking [ July 14th, 2013, 3:07 am ] |
Post subject: | Re: Clock/hours sound |
posted: ![]() viewtopic.php?f=11&t=3366 Thanks again kenneth!!! |
Page 1 of 1 | All times are UTC - 8 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |