• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ Contributions (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

[0.x] Sound on logon ...

Post a bug fix, a new feature, a theme ...

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
9 posts • Page 1 of 1

Postby Shimodax » Tue Aug 08, 2006 1:27 am

Hi!

One of the things I wanted to have, was a sound when a user logs in. We have only a few users, and the idea is that when you're the first user, you can leave the chat open and will hear when someone else drops in.

What you need is a line with a sound file in the html page:

<embed src="bell.wav" autostart="false" width="0" height="0" name="logon" enablejavascript="true">

(bell.wav obviously needs to be on your server in the same path as the chat page)



In parseAndPost look for
var fromtoday = msgs[mid][6];
var oldmsg = msgs[mid][7];
and add
var connectmsg = false;

Also look for
if (cmd == 'cmd_notice' || cmd == 'cmd_me')

and change into
if (cmd == 'cmd_notice' || cmd == 'cmd_me') {
line += '<span class="<?php echo $prefix; ?>words">* '+ this.parseMessage(words) +'</span> ';
if ( oldmsg != 1 && words.indexOf('is connected') != -1) {
connectmsg = 1;
}
}

and finally at the end of parseAndPost add

if (connectmsg == 1) {
document.logon.Play();
}


This is for the 0.9 version and possibly language specific (checking for he "is connected" message). May possibly be done more elegant (for example with a sound switch), but maybe someone can use it.


Markus
Shimodax
New member
 
Posts: 3
Joined: Tue Aug 08, 2006 1:06 am
Top

Postby phpfreechat » Mon Aug 14, 2006 9:19 am

Interesting contribution.
To have cleaner / multilanguage code I think I need to add sementic on the generated 'notices'. For example : add a flag to the command response.
So in parseAndPost if will be possible to know which kind of notice is going to be shown just by testing this flag.

I will think about that for the 1.x branche.
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby AkS » Tue Aug 22, 2006 12:23 am

nice job, but i'm not sure if the sound will be played for each msg added in the chat or just logon ?

otherwise, i don't understand in which file we must add this code .. where is "parseAndPost" ??

thx
Last edited by AkS on Tue Aug 22, 2006 1:08 am, edited 1 time in total.
AkS
New member
 
Posts: 5
Joined: Thu Aug 10, 2006 3:37 pm
Top

Postby phpfreechat » Tue Aug 22, 2006 8:18 am

in themes/default/templates/pfcclient.js.tpl.php
(be carfull it's only for 0.x releases)
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby AkS » Tue Aug 29, 2006 1:52 am

thanks
is there a possible update for 1.0 releases ?
i have tried it with 1.0b4 but no error and no sound .. can u explain when the sound is supposed to be played ?-

edit: it seems to be the document.logon.Play() which doesn't work here..
i tried to replace it by document.getElementById('logon').Play(); and also in a EvalSound('logon') function without success ..
I am under Opera or IE but there is no changes at all

any idea ?
Last edited by AkS on Tue Aug 29, 2006 3:34 am, edited 1 time in total.
AkS
New member
 
Posts: 5
Joined: Thu Aug 10, 2006 3:37 pm
Top

Postby NetAndif » Tue Aug 29, 2006 12:44 pm

With a small modification of this code we get the function 'window to top when a user connects'.

Just changed the code
Code: Select all
   if (connectmsg == 1) {
        document.logon.Play();
    }

to
Code: Select all
   if (connectmsg == 1) {
        setTimeout('self.focus()',100);
    }

Thanks
Last edited by NetAndif on Tue Aug 29, 2006 12:46 pm, edited 1 time in total.
NetAndif
Member
 
Posts: 21
Joined: Wed May 24, 2006 8:21 pm
Top

Postby Rubke » Tue Aug 29, 2006 9:38 pm

no sound here, internet explorer and firefox..
when i do a search on the parseAndPost function i only found 1 occurence.. strange
is it obsolete in 1.04, because any changes i made didn't do anything ?
Last edited by Rubke on Tue Aug 29, 2006 11:56 pm, edited 1 time in total.
Rubke
New member
 
Posts: 5
Joined: Wed Aug 09, 2006 10:39 pm
Top

Postby NetAndif » Wed Aug 30, 2006 6:03 pm

Unfortunately i don't know the code changes in 1.x, but i think there is another problem. The embed tag didn't work here. Maybe object has to be used, too. At least, Firefox presented me that 'plugin not installed' sign. IE didn't play sound, too. Then i tried it with my my self.focus function above, which did work.
After a little testing, i found out that IE needs MS Media Player, and FF needs Realplayer or Quicktime installed to play sound.

You can insert a test button below the embed tag inside your html to verify if javascript is working and the sound can be played:

Code: Select all
<input type="button" value="play" onclick="document.logon.Play();alert('sound should play');"/>

However, it still didn't play in my case.
NetAndif
Member
 
Posts: 21
Joined: Wed May 24, 2006 8:21 pm
Top

Postby cebronx » Wed Sep 06, 2006 5:58 pm

Is there a "Sound on logon" script for PFC 1.X? If someone has an idea of how to set it up please help out here. It gets boring in the chat room when you are writting and then no one knows that your writitng...Can anyone help thanks...
Luis
cebronx
Member
 
Posts: 32
Joined: Mon Aug 28, 2006 3:22 am
Location: Bronx, NY
  • Website
Top


Post a reply
9 posts • Page 1 of 1

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 13 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
cron
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub