現在、このブログに貼ってあるほとんどの動画は、JW FLV Media Playerを用いている。しかも、以前互換性をぶちこわすというふざけた変更があったので、用心のために、SWFObjectの外にも、さらに自前のJavascriptを使って書き換えている。以下のコードを使っている。
<script type='text/javascript'>
function player(id, width, height, file, image)
{
swfobject.embedSWF("player.swf", id, String(width), String(height+20), "9.0.0", null,
{//flashvars
volume: "100",
showdownload : "true",
type : "video",
fullscreen : "true",
image : image,
file : file,
link : file
},
{//params
allowscriptaccess : "always",
allowfullscreen : "true",
quality: "best",
wmode: "direct"
} ) ;
}
</script>
このようにしておけば、将来の変更にも十分耐えることができる。実際、これを、以下のように変更すれば、HTML5のvideo elementに、今すぐ変更できる。しかも、実際の記事は書き換えなくて良い。
<script type='text/javascript'>
function player(id, width, height, file, image)
{
var v = document.createElement("video");
v.setAttribute("width", String(width));
v.setAttribute("height", String(height));
v.setAttribute("controls", "controls");
v.setAttribute("poster", image);
v.setAttribute("src", file);
var n = document.getElementById(id);
n.parentNode.replaceChild(v, n);
}
</script>
問題は、現在、Chromeしかまともにvideo要素をサポートしていないことだ。さてどうしよう。
No comments:
Post a Comment