mediaelements.js コンポーネントの "features" 属性をオーバーライドする必要があります。シナリオは次のとおりです。 - 小さなコントロール (音量のみ) で最初のプロモーション ビデオを開始します。 - ビデオが終了すると、コンテンツ ビデオが開始され、より多くのコントロールを表示する必要があります。
これはコードです:
<video width="640" height="360" src="promo.mp4" type="video/mp4"
id="player1" poster="../media/echo-hereweare.jpg"
controls="controls" preload="true"></video>
<script>
$(function () {
promoVideo();
});
function promoVideo() {
$("#player1").mediaelementplayer({
features: ['volume'],
success: function(player, node) {
// add event listener
player.addEventListener('ended', function(e) {
contentVideo(e.target);
}, false);
}
});
}
function contentVideo(player) {
var contentVideoSrc = "content.mp4";
player.features = ['playpause','progress','fullscreen','current','duration'];
player.pause();
player.setSrc(contentVideoSrc);
player.play();
}
</script>
このコードでは、プロモーション ビデオが開始され、ボリューム コントロールのみが表示されます。終了すると、コンテンツ ビデオが正しく開始されますが、「features」属性で設定された他のコントロールは表示されません。この方法で機能を追加する必要もあります。
$("#player1").mediaelementplayer({
features: ['playpause','progress','fullscreen','current','duration']
});
この:
var player = new MediaElementPlayer(
"#player1"
,
{
features: ['playpause','progress','fullscreen','current','duration']
}
);
しかし、いずれにしてもうまくいきません。なにか提案を?
ありがとう!ジュゼッペ