Inv*_*tax 2 javascript javascript-events mediaelement.js
我有以下简单的代码启动mediaelement音频插件:
$('audio,video').mediaelementplayer({
audioWidth: 300,
audioHeight: 30
});
Run Code Online (Sandbox Code Playgroud)
我需要跟踪playing事件; 我没试过就试过以下代码:
var player = document.getElementsById('player2');
player.playing = function(e) {
alert('OMG! You played a song!');
}
Run Code Online (Sandbox Code Playgroud)
试试这个:
# using jquery (on, bind, etc)...
$('#player1').bind('playing', function(e) {
console.log('bind - playing')
});
# addEventListener
var player = document.getElementById('player1');
player.addEventListener('playing', function(e) {
console.log('addEventListener - playing') ;
});
Run Code Online (Sandbox Code Playgroud)
好的,我知道了...
$('audio,video').mediaelementplayer({
audioWidth: 300,
audioHeight: 30,
success: function(mediaElement, domObject) {
mediaElement.addEventListener('loadeddata', function() {
console.log('addEventListener - loadeddata')
}, false);
},
error: function() {
//alert('Error setting media!');
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5449 次 |
| 最近记录: |