http://mediaelementjs.com/
MediaElement.jsサーバ上の動画やYoutubeなどにある動画をHTML5のvideoタグで表示できるjsライブラリ.
これを使ってYoutubeを再生してみたが,なぜかループが止まらない.
サイトに記載されていたoptionの
useful for <audio> player loopsでもダメだった.(そもそもこれはaudio用みたい
loop: false,
そこで,audio,videoで作られたmediaelement要素に対し,次のようなEventListenerを付与した.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('audio,video').mediaelementplayer({ | |
success: function (player, node) { | |
$('#' + node.id + '-mode').html('mode: ' + player.pluginType); | |
//終了したら,停止 | |
player.addEventListener('ended', function () { | |
// Player is ready | |
player.stop(); | |
}, false); | |
}, | |
}); |
なお,3行目の処理はサンプルファイルに書かれているものなのでそちらを参照.