Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. 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.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" 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?
 
Like I mentioned before... that column of alarm clocks you got there is blocking the error messages, thus there is some information that cannot be determined from the error message due to the clocks appearing in front of it. Can you please either move them out of sight, or hide them so that the console can be seen properly?
Here's a better version. At least I hope so!
1703569508345.png
 
So regarding that permissions issue... I found this, which you can use for future referencehttps://stackoverflow.com/questions/57504122/browser-denying-javascript-play
I copied then pasted the link you gave me in the address bar. When I pressed enter, one of the answers to the question led me to this link. Test Sounds API
When I saved that HTML page and reviewed its source code in "HTML Help Workshop", which is the place where I make my HTML files, it says the audio files on that page are .m4a files. Could it be that because mine are .ogg files, it doesn't work in any browser to try and play them? I'm confused on this one! What does the kind of file have to do with not being able to play sounds, I wonder?
 
I copied then pasted the link you gave me in the address bar. When I pressed enter, one of the answers to the question led me to this link. Test Sounds API
When I saved that HTML page and reviewed its source code in "HTML Help Workshop", which is the place where I make my HTML files, it says the audio files on that page are .m4a files. Could it be that because mine are .ogg files, it doesn't work in any browser to try and play them? I'm confused on this one! What does the kind of file have to do with not being able to play sounds, I wonder?
You might want to get an mp3 version of those files you are using
 
I'm trying to convert it to MP3, but Audacity says it's missing the "LameEnc.dll" file. I could have sworn I had that one in the list of files that comes with Audacity! If it's not there, is there a direct link to a download that's free of malware and viruses?
 
I'm trying to convert it to MP3, but Audacity says it's missing the "LameEnc.dll" file. I could have sworn I had that one in the list of files that comes with Audacity! If it's not there, is there a direct link to a download that's free of malware and viruses?
So I did some research about this issue, and it turns out that this is attributed to having an outdated version of Audacity. Simple solution: uninstall your current version, and just re-download audacity which will give you the latest version, which will have the dll already built in.
 
Can you also post the html code? I was looking at a potential issue with the audio tag attributes, and want to see what you have
Sure! Here ya go!
Code:
<html>
<div role="switch" aria-labelledby="id-label">
  <label for="Hookswitch Status"
  <button type="button"
          role="switch"
  id="hookswitch">Hookswitch Status: 
    <span class="hookStatus off">
    </span>
  </label>
  </button>
</div>
<audio id="dialTone" src="file:///M:/Documents/Virtual%20Phone/Call%20Progress%20Tones/Dial%20Tone/USA%20Dial%20Tone.mp3"></audio>
<audio id="busyTone" src="file:///M:/Documents/Virtual%20Phone/Call%20Progress%20Tones/Busy%20Tone/USA%20Busy%20Tone.mp3"></audio>
<audio id="RingbackTone" src="file:///M:/Documents/Virtual%20Phone/Call%20Progress%20Tones/Ringback%20Tone/USA%20Ringback%20Tone.mp3"></audio>
<audio id="TimeoutHowler" src="file:///M:/Documents/Virtual%20Phone/Call%20Progress%20Tones/Receiver%20Off%20Hook%20Tone/USA%20Receiver%20Off%20Hook%20Tone.mp3"></audio>
<audio id="RingingTone" src="file:///M:/Documents/Virtual%20Phone/Call%20Progress%20Tones/Ringing%20Tone/Princess%20702B%20Bell%20Ring.mp3"></audio>
<audio id="DTMFToneDial1" src="file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%201.mp3"</audio>
<audio id="DTMFToneDial2" src="file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%202.mp3"</audio>
<audio id="DTMFToneDial3" src="file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%203.mp3"</audio>
<audio id="DTMFToneDial4" src="file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%204.mp3"</audio>
<audio id="DTMFToneDial5" src="file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%205.mp3"</audio>
<audio id="DTMFToneDial6" src="file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%206.mp3"</audio>
<audio id="DTMFToneDial7" src="file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%207.mp3"</audio>
<audio id="DTMFToneDial8" src="file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%208.mp3"</audio>
<audio id="DTMFToneDial9" src="file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%209.mp3"</audio>
<audio id="DTMFToneDialStar" src="file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%20Star.mp3"</audio>
<audio id="DTMFToneDial0" src="file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%200.mp3"</audio>
<audio id="DTMFToneDialPound" src="file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%20Pound.mp3"</audio>
<audio id="OneSlotUSAPayphoneNickelTone" src="file:///M:/Documents/Virtual%20Phone/Payphone%20Coin%20Tones/One-Slot%20Payphone/USA%20Payphone%20Nickel%20Tone.mp3"></audio>
<audio id="OneSlotUSAPayphoneDimeTone" src="file:///M:/Documents/Virtual%20Phone/Payphone%20Coin%20Tones/One-Slot%20Payphone/USA%20Payphone%20Dime%20Tone.mp3"></audio>
<audio id="OneSlotUSAPayphoneQuarterTone" src="file:///M:/Documents/Virtual%20Phone/Payphone%20Coin%20Tones/One-Slot%20Payphone/USA%20Payphone%20Quarter%20Tone.mp3"></audio>
<audio id="OneSlotUSAPayphoneHalfDollarTone" src="file:///M:/Documents/Virtual%20Phone/Payphone%20Coin%20Tones/One-Slot%20Payphone/USA%20Payphone%20Half%20Dollar%20Tone.mp3"></audio>
<audio id="OneSlotUSAPayphoneDollarTone" src="file:///M:/Documents/Virtual%20Phone/Payphone%20Coin%20Tones/One-Slot%20Payphone/USA%20Payphone%20Dollar%20Tone.mp3"></audio>
<div id="DTMF" style="display: block;">
<center><p class="TONETYPE">DTMF DIALING TONES</p></center>
<button type="button" id="DTMF1">1</button>
<button type="button" id="DTMF2">2</button>
<button type="button" id="DTMF3">3</button>
<button type="button" id="DTMF4">4</button>
<button type="button" id="DTMF5">5</button>
<button type="button" id="DTMF6">6</button>
<button type="button" id="DTMF7">7</button>
<button type="button" id="DTMF8">8</button>
<button type="button" id="DTMF9">9</button>
<button type="button" id="DTMFStar">Star</button>
<button type="button" id="DTMF0">0</button>
<button type="button" id="DTMFPound">Pound</button>
</div>
<div id="ACTS" style="display: block;">
<center><p class="TONETYPE">1-SLOT COIN DEPOSIT SOUNDS</p></center>
<button type="button" id="ACTS5">$0.05</button>
<button type="button" id="ACTS10">$0.10</button>
<button type="button" id="ACTS25">$0.25</button>
<button type="button" id="ACTS50">$0.50</button>
<button type="button" id="ACTS100">$1.00</button>
</div>
</html>
 
Back
Top Bottom