试图通过 QtWeKit 获取 HTML5 中音频标签事件的钩子。为此,我创建了一个示例应用程序,它只通过 QwebView 加载一个 html 文件。
html 文件包含一个 HTML5 音频标签。
<audio id="audio_with_local_controls" controls>
<source src="nokia-tune.mp3" type="audio/mp3" />
</audio>
在脚本方面,我正在尝试获取音频标签播放、暂停和结束事件的挂钩。
/// 音频标签事件。
var aid = document.getElementById('audio_with_local_controls');
function onplay_(){
console.log('onplay');
alert('onplay');
}
function oncanplay_(){
console.log('oncanplay');
alert('oncanplay');
}
function onpause_(){
console.log('onpause');
alert('onpause');
}
console.log(aid);
aid.onplay = onplay_;
aid.oncanplay = oncanplay_;
aid.onpause = onpause_;
aid.onprogress = function onprogress_(){ alert('onprogress'); }
aid.onended = function onended_(){ alert('onended'); }
aid.onabort = function onabort_(){ alert('onabort'); }
当我在代码中上下尝试时,代码序列可能没有意义。Chrome 能够捕获这些钩子。但是 QWebView 对此保持沉默,没有任何内容被捕获。是不是 QWebView 不支持这个?还是我写错了什么?