XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently May 10th, 2025, 10:51 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 20 posts ] 
Author Message
 Post subject: Clock/hours sound
PostPosted: July 6th, 2013, 3:25 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
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!

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


Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 3:44 am 
Offline
User avatar

Joined: June 10th, 2012, 6:06 am
Posts: 17
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

_________________
facebook:http://www.facebook.com/ZhaoKenneth
weibo:http://weibo.com/102030456
twitter:http://twitter.com/colawings
DeviantArt:http://kenneth117.deviantart.com/


Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 5:15 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
WOW! 1000 thanks kenneth112! :D
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?

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


Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 6:24 am 
Offline
User avatar

Joined: June 10th, 2012, 6:06 am
Posts: 17
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

_________________
facebook:http://www.facebook.com/ZhaoKenneth
weibo:http://weibo.com/102030456
twitter:http://twitter.com/colawings
DeviantArt:http://kenneth117.deviantart.com/


Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 6:30 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
I understand kenneth! But what about the 1,2 and 4 questions...?

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


Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 12:28 pm 
Offline
User avatar

Joined: June 10th, 2012, 6:06 am
Posts: 17
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

_________________
facebook:http://www.facebook.com/ZhaoKenneth
weibo:http://weibo.com/102030456
twitter:http://twitter.com/colawings
DeviantArt:http://kenneth117.deviantart.com/


Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 12:37 pm 
Offline
User avatar

Joined: June 10th, 2012, 6:06 am
Posts: 17
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.

_________________
facebook:http://www.facebook.com/ZhaoKenneth
weibo:http://weibo.com/102030456
twitter:http://twitter.com/colawings
DeviantArt:http://kenneth117.deviantart.com/


Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 1:15 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
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

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


Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 1:30 pm 
Offline
User avatar

Joined: June 10th, 2012, 6:06 am
Posts: 17
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

_________________
facebook:http://www.facebook.com/ZhaoKenneth
weibo:http://weibo.com/102030456
twitter:http://twitter.com/colawings
DeviantArt:http://kenneth117.deviantart.com/


Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 1:37 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
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..

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


Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 2:18 pm 
Offline
User avatar

Joined: June 10th, 2012, 6:06 am
Posts: 17
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

_________________
facebook:http://www.facebook.com/ZhaoKenneth
weibo:http://weibo.com/102030456
twitter:http://twitter.com/colawings
DeviantArt:http://kenneth117.deviantart.com/


Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 3:10 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
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

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


Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 3:54 pm 
Offline

Joined: June 18th, 2012, 12:07 am
Posts: 268
Try
var d = new Date();//create a date object


Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 4:08 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
This works meme! Thanks! 8-)
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...

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


Last edited by Jimking on July 13th, 2013, 4:33 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 4:19 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
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.

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


Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 4:43 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Here is the widget for test it by yourself...

I became a headache for you guys. Sorry! :oops:

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


Last edited by Jimking on July 14th, 2013, 6:15 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 7:40 pm 
Offline
User avatar

Joined: June 10th, 2012, 6:06 am
Posts: 17
my code has some problem,it's OK now.


Attachments:
cuckoo_clock.rar [2.36 MiB]
Downloaded 597 times

_________________
facebook:http://www.facebook.com/ZhaoKenneth
weibo:http://weibo.com/102030456
twitter:http://twitter.com/colawings
DeviantArt:http://kenneth117.deviantart.com/
Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 13th, 2013, 11:22 pm 
Offline

Joined: June 18th, 2012, 12:07 am
Posts: 268
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 ?


Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 14th, 2013, 12:27 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
kenneth112 wrote:
my code has some problem,it's OK now.

Thank you VERYYYY MUCH for spend all this time and help me!!! :D

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! :D
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..

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


Last edited by Jimking on July 14th, 2013, 3:08 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Clock/hours sound
PostPosted: July 14th, 2013, 3:07 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
posted: :D
viewtopic.php?f=11&t=3366

Thanks again kenneth!!!

_________________
...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  [ 20 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users 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:  

Powered by phpBB® Forum Software © phpBB Group