Page 1 of 1

sound in chat?

Posted: Thu Jul 31, 2014 5:44 am
by KaL
i try to insert a sound in the game like this:

Code: Select all

<?php 
echo "<embed src='clink_sound.mp3' autostart='true' loop='false'></embed>";
?>
it works for a module but i can't seem to get it to work for chat module.

any help pls.

Re: sound in chat?

Posted: Thu Jul 31, 2014 10:51 am
by Chris
This would require someone to load a plugin like Windows Media Player, VLC or quicktime within the browser. You would be better off resorting to the new HTML5 audio tag as this would use a browser native audio decoder.

http://www.w3schools.com/html/html5_audio.asp

Code: Select all

echo '<audio controls>
        <source src="clink_sound.mp3" type="audio/mpeg">
     </audio>';
 
May I ask, as I noticed the file name is "clink_sound.mp3", what is variable about it? Is it an audio someone places in the chat, or is it a sound when someone receives a message? In this case it would be better to play the sound through JavaScript as your DOM will become cluttered with audio objects.

Re: sound in chat?

Posted: Thu Jul 31, 2014 2:04 pm
by KaL
i just use that sound to send out alert every time someone chat, when the chat window is minimize. Yup! i even use Html 5 audio tag code you suggested but i can't seem to get it working. i even try to put the tag everywhere and still no result (trying to add in the javascript/ajax-chat_bar module). if you can look into the chat_bar module and tell me where should i add this script that would be great. thank you!


the location of this "clink.mp3" at the beginning of the directory where the "index.php" file is located. I figure this way i won't have any permission problem accessing it.

Re: sound in chat?

Posted: Sat Aug 02, 2014 12:53 pm
by a_bertrand
Did you managed to implement it?

Re: sound in chat?

Posted: Sun Aug 03, 2014 12:19 am
by KaL
Nope. I add the script to the chat_bar.js everywhere and it did not work. I tried the html5 audio tag and even the javascript audio script.

Re: sound in chat?

Posted: Mon Aug 04, 2014 9:15 am
by a_bertrand
Currently I'm totally overbooked (sadly), however I will do my best to squash a bit of time this week for this and come with something.