Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8257267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:08:28+00:00 2026-06-08T02:08:28+00:00

I am trying to make a sound when the user submits a chat, it

  • 0

I am trying to make a sound when the user submits a chat, it will also be heard on the other person’s end. Here is my code:

Enter Chat and press enter

<div><input id=input placeholder=you-chat-here /></div>
<code>Chat Output</code>
<div id=box></div>
<div id=pubnub pub-key=demo sub-key=demo></div>
<script src=http://cdn.pubnub.com/pubnub-3.1.min.js></script>
<script>(function(){
    var box = PUBNUB.$('box'), input = PUBNUB.$('input'), channel = 'chatlllll';
        PUBNUB.subscribe({
            channel : channel,
            callback : function(text) { 
                box.innerHTML = 
                  (''+text).replace( /[<>]/g, '' ) + '<br>' +      box.innerHTML; 
            }
        });
    PUBNUB.bind( 'keyup', input, function(e) {
       (e.keyCode || e.charCode) === 13 && PUBNUB.publish({
           playsound('http://www.aphpsite.comuv.com/sound/chat.wav')
           channel : channel, 
           message : input.value, 
           x : (input.value='')
       });
   });
})();</script>

This is what I have. I am having trouble adding the sound. This script is broken. So none of this works. I would like if someone could fix it.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:08:30+00:00Added an answer on June 8, 2026 at 2:08 am

    You are asking about PubNub and a Sample Chat Application with Sound Effect on Chat Message Arrival/Send. I’ve updated the example and provided an extra sound.js JavaScript HTML5 lib that will help with playing the sound effect. Note that I took your Sound WAV file and converted it to OGG and MP3 file formats as well in order to provide cross browser compatibility. Next I will paste the Complete and Working Source Code for the Chat with Sound Effects on Receiving of a message. Following the source code, I have pasted the URL Resources that you need such as sound.js and the audio files too.

    Try it LIVE! – http://pubnub-demo.s3.amazonaws.com/chat-with-sounds/chat.html

    See Source Code:

    <div><input id=input placeholder=chat-here></div>
    <code>Chat Output</code>
    <div id=box></div>
    <div id=pubnub pub-key=demo sub-key=demo></div>
    <script src=http://cdn.pubnub.com/pubnub-3.1.min.js></script>
    <script src=sound.js></script>
    <script>(function(){
        var box = PUBNUB.$('box'), input = PUBNUB.$('input'), channel = 'chatlllll';
        PUBNUB.subscribe({
            channel : channel,
            callback : function(text) { 
                // PLAY SOUND HERE
                sounds.play('chat');
    
                // UPDATE TEXT OUTPUT HERE
                box.innerHTML = 
                    (''+text).replace( /[<>]/g, '' ) +
                    '<br>' +
                    box.innerHTML; 
            }
        });
        PUBNUB.bind( 'keyup', input, function(e) {
    
           (e.keyCode || e.charCode) === 13 && PUBNUB.publish({
               channel : channel, 
               message : input.value, 
               x       : (input.value='')
           });
       });
    })();</script>
    

    Download Source Code on GitHub

    https://github.com/pubnub/pubnub-api/tree/master/app-showcase/chat-with-sounds – Click link to visit the PubNub GitHub Repository with Source Code for the Chat with Sound Demo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying make a login window where a user is prompted to enter their
I have an array of raw sound data samples, and I'm trying to make
I'm trying make an entity with doctrine that has three associations with other entities
Trying to make an xna game, where the user needs to tap to stop
I'm trying to make a HTML5 webapp that simply plays a sound over and
I'm trying to make a custom sound play on a status bar notification. The
I am trying to make a very precisely timed firing of a sound. I
So I'm trying to make a simple application that quizzes the user. It asks
When trying to make a sound when clicked on an ImageButton my application crashes
Hi I am trying to make car engine sound by using SimpleAudioEngine . i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.