Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Playing Audio Using Keystrokes: Is It Possible?

Annabelle5893

Gold Coder
I'm wondering, how would I make an app that plays audio files using the keys on the number pad? Specifically, I want to make an app that triggers "Rotary Pulse 1" by pressing 1 on the numeric keypad, all the way up to "Rotary Pulse 0" on the 0 key. A dial tone will be toggled on by pressing the spacebar, which will begin with a "receiver pickup" noise. The dial tone turns off when digits are dialed via the numeric keypad. If you press the spacebar either when the dial tone is on, or after dialing a number, a "Receiver Hang Up" noise will be triggered. With the rotary dial sounds, the dial turning to the fingerhole is triggered at key down, and the release of the dial returning to the resting position will be triggered by releasing of the number corresponding to the fingerhole (1, 2, 3, 4, 5, 6, 7, 8, 9, 0). This will be accompanied by the internal sound of the dial pulses as heard in a telephone. What is the code I would use to make this audio app using HTML?
 
Hmmm. Let me see on my end if there are any errors that pop up when pressing keys. I didn't test that out. I think it may be that your file paths may be erroring out.
Out of curiosity, how would I loop a piece of audio? For example, if I want the ringing tone to loop until someone "answers" the phone by pressing a key, what would I write?
 
Out of curiosity, how would I loop a piece of audio? For example, if I want the ringing tone to loop until someone "answers" the phone by pressing a key, what would I write?
I do believe there is a 'loop' attribute for audio. If not, what you could do is use setInterval and have a condition check if your variable hasTelephoneBeenAnswered is set to true
 
I do believe there is a 'loop' attribute for audio. If not, what you could do is use setInterval and have a condition check if your variable hasTelephoneBeenAnswered is set to true
For example, the ringing tone would play in a continuous loop until you "answer the phone" by pressing Spacebar, which would toggle your computer's microphone so you can talk as though you're talking on the phone to someone.
 
Any updates?
Hi Annabelle,
I do apologize for the late reply. Been having some personal and family issues recently. I do have an update for you. I've managed to get through getting the ringtones to work properly. I only thing to do is to make sure they work with the appropriate buttons. I truly appreciate your patience. I will post the solution soon.
 
Hi Annabelle,
I do apologize for the late reply. Been having some personal and family issues recently. I do have an update for you. I've managed to get through getting the ringtones to work properly. I only thing to do is to make sure they work with the appropriate buttons. I truly appreciate your patience. I will post the solution soon.
Have you found the solution to make the keystrokes work?
 
I did. I am implementing the solution. I did run into an issue regarding the pausing of the audio files to allow another to play and then resume, but I also found a solution for that. Almost have the solution ready for you.
Hey Antero!
My computer was down for at least two months since we last talked about updates and solutions. I tried to perform a repair install of Windows 10, as I thought for some reason Windows was causing some accessibility bugs to occur, like missing characters in Microsoft Edge. My sighted friend, Markus, was able to fix it on June 4 by simply performing a System Restore. Now that it's up and running again, have you found the solution you were talking about yet?
 
Hey Antero!
My computer was down for at least two months since we last talked about updates and solutions. I tried to perform a repair install of Windows 10, as I thought for some reason Windows was causing some accessibility bugs to occur, like missing characters in Microsoft Edge. My sighted friend, Markus, was able to fix it on June 4 by simply performing a System Restore. Now that it's up and running again, have you found the solution you were talking about yet?
Hi there Annabelle,

Glad to hear your machine is now working properly. Please check your email, as I have provided a detailed update there for you.
 
Any new updates yet?
Hi Annabelle,

I do sincerely apologize for this late reply. It's been a very rough few weeks since our last communication. Everything from ending up in the hospital for a bit, to getting notification of a death in the family, to anxiety/depression has been hitting me like a brick wall. I do have great news for you today though 🙂 . I am attaching the zip file of your project in its current state. When you unzip it, please find the "Virtual Touchtone Phone_copy.html" file. When you run it, you will be met with the warning about the audio needing permission to run. Once you click on ok, you are able to autoplay sounds. It will start to ring after about 5 seconds afterwards. When you pick it up, you will hear the song from "The Phantom of the Opera" (to simulate talking, again for testing purposes) until you hang it up. If you pick before those 5 seconds are up, you will hear the tone to signify ready for dialing. The dial buttons also play their sounds. The only things I didn't touch on were, the dialing responses, the ACTS buttons functionalities. I tried to keep your code and logic as much as possible. Let me know what you think. Hoping you are doing alright 🙂
 

Attachments

Hi Annabelle,

I do sincerely apologize for this late reply. It's been a very rough few weeks since our last communication. Everything from ending up in the hospital for a bit, to getting notification of a death in the family, to anxiety/depression has been hitting me like a brick wall. I do have great news for you today though 🙂 . I am attaching the zip file of your project in its current state. When you unzip it, please find the "Virtual Touchtone Phone_copy.html" file. When you run it, you will be met with the warning about the audio needing permission to run. Once you click on ok, you are able to autoplay sounds. It will start to ring after about 5 seconds afterwards. When you pick it up, you will hear the song from "The Phantom of the Opera" (to simulate talking, again for testing purposes) until you hang it up. If you pick before those 5 seconds are up, you will hear the tone to signify ready for dialing. The dial buttons also play their sounds. The only things I didn't touch on were, the dialing responses, the ACTS buttons functionalities. I tried to keep your code and logic as much as possible. Let me know what you think. Hoping you are doing alright 🙂
I got it to play the tones by pressing the buttons, but why won't the keyboard shortcuts do the same? Also, I'm doin' OK. I've been recovering from a nasty ear infection. You won't believe it, but it actually started with a mosquito bite in my ear! Not just on my ear, but in my ear! My ear canal was swollen shut for a few days, so my hearing was next to nothing in my left ear. It's returning slowly but surely. The doctor told me it was a bacterial infection. I've been taking Cortisporin eardrops for the last few days. This is the tenth day, and my hearing only seems to be 95% in that ear. I've been trying to get it to pop so my hearing will be 100% again. When I breathe through my nose, on the left side, it literally sounds like what you'd hear when you blow into a microphone. I think it's a clogged eustachian tube. It's been so painful! I even had a moment where when I would chew, my ear would hurt. Fortunately that's not happening any longer. Could you have chosen some jazz music instead? Since I don't like opera.
 
I got it to play the tones by pressing the buttons, but why won't the keyboard shortcuts do the same? Also, I'm doin' OK. I've been recovering from a nasty ear infection. You won't believe it, but it actually started with a mosquito bite in my ear! Not just on my ear, but in my ear! My ear canal was swollen shut for a few days, so my hearing was next to nothing in my left ear. It's returning slowly but surely. The doctor told me it was a bacterial infection. I've been taking Cortisporin eardrops for the last few days. This is the tenth day, and my hearing only seems to be 95% in that ear. I've been trying to get it to pop so my hearing will be 100% again. When I breathe through my nose, on the left side, it literally sounds like what you'd hear when you blow into a microphone. I think it's a clogged eustachian tube. It's been so painful! I even had a moment where when I would chew, my ear would hurt. Fortunately that's not happening any longer. Could you have chosen some jazz music instead? Since I don't like opera.
OUUUCH! Yeah, I feel the pain. It's been a while since I had an ear infection, but the last time I had one was a few years ago, and I literally spent the entire week in bed crying from the pain. Also, attached you will find the updated version of the project. number buttons are now working and changed the music file to a smoother jazz 🙂
 

Attachments

OUUUCH! Yeah, I feel the pain. It's been a while since I had an ear infection, but the last time I had one was a few years ago, and I literally spent the entire week in bed crying from the pain. Also, attached you will find the updated version of the project. number buttons are now working and changed the music file to a smoother jazz 🙂
I looooooooooooooove that jazz tune! It sounds soothing. I was hoping the Pound key would be assigned to Numpad - as well as the # key. Also, which key is Keycode 107, and what is this
Code:
                            console.log('testing');
                            break;
 
I looooooooooooooove that jazz tune! It sounds soothing. I was hoping the Pound key would be assigned to Numpad - as well as the # key. Also, which key is Keycode 107, and what is this
Code:
                            console.log('testing');
                            break;
all the numbers, star and pound have already been assigned. It is the same keycode regardless of whether you press the numbers above qwerty on the keyboard, or the numberpad. We could definitely assign the pound to the - sign, just keep in mind what I just mentioned: it will be assigned to both the - sign above qwerty and the - sign in the numpad because it is the same keycode when you press it, should I go ahead and make that change for you?
 
all the numbers, star and pound have already been assigned. It is the same keycode regardless of whether you press the numbers above qwerty on the keyboard, or the numberpad. We could definitely assign the pound to the - sign, just keep in mind what I just mentioned: it will be assigned to both the - sign above qwerty and the - sign in the numpad because it is the same keycode when you press it, should I go ahead and make that change for you?
Yes, please do! Also, do the spacebar and the Enter key trigger the hookswitch? I'm confused!
 
They currently don't, but I can make that change as well if that is how you want it to function.
That would be amazing! Though I want the spacebar and Enter to do different things. The Spacebar would "answer" the phone when it rings, and the Enter key would toggle the dial tone. Did you ever figure out how to incorporate the off hook tone?
 
That would be amazing! Though I want the spacebar and Enter to do different things. The Spacebar would "answer" the phone when it rings, and the Enter key would toggle the dial tone. Did you ever figure out how to incorporate the off hook tone?
What exactly do you mean by 'toggle the dial tone'? As far as off-hook tone, yes, just didn't get a chance to implement it. I will also add that for this next update
 

New Threads

Buy us a coffee!

Back
Top Bottom