【发布时间】:2014-04-22 14:46:00
【问题描述】:
我在 chrome 中运行 HTML5 音频播放器时遇到问题。它在 IE 9+ 和 Firefox 中运行良好。我已经编写了用于在 F7 和 F8 按键上转发和倒带音频播放器的 javascript 函数,它在 IE 和 FF 中运行良好,但由于某些原因它在 Chrome 中不起作用。以下是代码。
$(document).keydown(function (e) {
if (e.keyCode == 118) { rewindAudio(); return false; }
else if (e.keyCode == 119) { forwardAudio(); return false; }
}
// Rewinds the audio file by 30 seconds.
function rewindAudio() {
// Check for audio element support.
if (window.HTMLAudioElement)
{
try {
var oAudio = audioPlayerInFocus[0];
oAudio.currentTime -= 1.0;
}
catch (e) {
// Fail silently but show in F12 developer tools console
if (window.console && console.error("Error:" + e));
}
}
}
// Fast forwards the audio file by 1 seconds.
function forwardAudio() {
// Check for audio element support.
if (window.HTMLAudioElement) {
try {
var oAudio = audioPlayerInFocus[0
oAudio.currentTime += 1.0;
}
catch (e) {
// Fail silently but show in F12 developer tools console
if (window.console && console.error("Error:" + e));
}
}
}
我怀疑当前时间在 chrome 中没有改变。是否有任何语法错误或浏览器相关问题?请帮助我。谢谢。
【问题讨论】:
-
var oAudio = audioPlayerInFocus[0是一个语法难题。另外,请告诉我们audioPlayerInFocus是什么@
标签: javascript jquery asp.net-mvc google-chrome html5-audio