1

我使用的是html5media庫,該庫使用Flowplayer Flash Player爲不支持視頻標籤的瀏覽器自動替換頁面上的HTML5視頻標籤。這發生在IE和一些較舊的瀏覽器上。檢測頁面上的Flowplayer並添加事件監聽器

我需要檢測頁面上是否存在Flowplayer,並向用戶開始播放視頻時觸發JavaScript函數的每個實例添加事件偵聽器。這可能通過jQuery? Flowplayer的Player對象的API描述爲here;一些例子:

/* Set common clip properties and event listeners 
* in run-time 
*/ 

// register event listener with common clip 
$f("player").onStart(function() { 
    alert("Playing"); 
}); 

// this does the same thing 
$f("player").getCommonClip().onStart(function() { 
    alert("Playing"); 
}); 

// if you want to register a listener to a specific clip *only* 
$f("player").getClip(1).onStart(function() { 
    alert("Playing"); 
}); 

你如何附加一個事件偵聽器在onStart事件到的Flowplayer的每個實例,如果它存在在網頁上?謝謝。

回答

0

應該可以通過在這裏所描述的configureFlowplayer回調設置你的處理程序了:http://wiki.github.com/etianen/html5media/custom-flash-players

它最終應該看起來像這樣在config參數是他們使用的是配置的Flowplayer東西。我沒有測試過這個代碼,但是這應該讓你知道你需要做什麼:

<script> 
html5media.configureFlowplayer = function(tag, element, config) { 
    config.onStart = function(){alert("playing");} 
} 
</script>