WAV file only playing on certain computers in ie 8

浪尽此生 提交于 2019-12-12 02:59:59

问题


I have a simple HTML file with Javascript calling a function to play a wav file. It's very basic and works just fine on one of my computers. I press a key on the keyboard and the wav file plays just fine. I run the same file on a different computer and I get a javascript error that says: "Unspecified error." It seems to act like the file I'm trying to play doesn't exist. I haven't attached my code becuase it works flawlessly on the other computer so I'm thinking maybe this is just a internet options problem? I can't find anywhere that tells me what setting controls the wav file settings.

Thanks for reading.

<script type="text/javascript">
function play() { 

var myCurrentTraffic = document.getElementById('trafficItemBox').value;
var playTrafficItem = myCurrentTraffic + ".wav";

embed = document.createElement("embed"); 
embed.setAttribute("src", playTrafficItem); 
embed.setAttribute("hidden", true); 
embed.setAttribute("autostart", true); 
document.body.appendChild(embed); 
} 
</script>

</head>

<body>

<button onclick="play();">PLAY</button>

<input type="text" id="trafficItemBox" value="0"></input>

This code seems to work on all my computers, so now my situation is a little different. I have 2 wav files, "0.wav" and "1.wav". I have created some other code that every time I push my "Play" key (which I'm using the ` key) it increases the 'trafficItemBox' value by 1, which in turn becomes the new wav file number. So the file starts playing 0.wav, then will play 1.wav and so on all the way up to my final wav file.

The problem now is that the document.body.appendChild(embed) part takes the focus away from my site, so I have to click the mouse back into the body of the site to gain focus again so that I can continue to click the "play" key to make the next file play. I can't figure out how to just bring focus back to the document so I can just click the "play" key continuously. THANKS!

来源:https://stackoverflow.com/questions/10267316/wav-file-only-playing-on-certain-computers-in-ie-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!