424Games
02-22-2018
04:37 PM
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Audio from JavaScript doesn't play
I made something in JavaScript that is supposed to play audio from a URL when you click on a button. The audio works when I test the .HTML file directly from my computer, but the audio won't play when I use it on my website with the embed object. Does anyone know a fix for this? Here's how I have it set up.
<button onclick="playSound()">Play</button> <script> function playSound() { var url = ("https://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=3&client=tw-ob&q=Hello&tl=en") var audio = new Audio(url); audio.play(); } </script>
Reply
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report Inappropriate Content
1 REPLY 1
NJRFTF
02-22-2018
07:32 PM
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Reply
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report Inappropriate Content