だから私はこのようなもので、YouTubeのビデオを再生するこのコードを持っています:
// The "main method" of this sample. Called when someone clicks "Run".
function loadPlayer() {
// The video to load
var videoID = "XjMQmXAJ3y4"
// Lets Flash from another domain call JavaScript
var params = { allowScriptAccess: "always"};
// The element id of the Flash embed
var atts = { id: "ytPlayer" };
// All of the magic handled by SWFObject (http://code.google.com/p/swfobject/)
swfobject.embedSWF("http://www.youtube.com/v/" + videoID +
"&enablejsapi=1&playerapiid=player1",
"videoDiv", 800, 600, "8", null, null, params, atts);
ビデオを画面全体に表示することはできますか (幅 100%、高さ 100%)。
また、ビデオを自動再生できるかどうか疑問に思っていますか?
--
編集: 自動再生の問題は修正されましたが、画面全体の幅と高さの問題は残っています。次のコードを実装しようとしましたが、役に立ちませんでした:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script>
$(window).height(); // returns height of browser viewport
$(document).height(); // returns height of HTML document
$(window).width(); // returns width of browser viewport
$(document).width(); // returns width of HTML document
</script>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load("swfobject", "2.1");
</script>
<script type="text/javascript">
var locationToRedirect = "http://URL.com";
function EventListener(ev)
{
if(!ev)
{
window.location.href = locationToRedirect;
}
else if(ev == 5)
{
ytpl = document.getElementById("ytPlayer");
ytpl.playVideo();
}
}
function onYouTubePlayerReady(playerId) {
ytplayer = document.getElementById("ytPlayer");
ytplayer.addEventListener("onStateChange", "EventListener");
}
// The "main method" of this sample. Called when someone clicks "Run".
function loadPlayer() {
// The video to load
var videoID = "XjMQmXAJ3y4"
// Lets Flash from another domain call JavaScript
var params = { allowScriptAccess: "always"};
// The element id of the Flash embed
var atts = { id: "ytPlayer" };
// All of the magic handled by SWFObject (http://code.google.com/p/swfobject/)
swfobject.embedSWF("http://www.youtube.com/v/" + videoID +
"&enablejsapi=1&playerapiid=player1&autoplay=1",
"videoDiv", screen.height, screen.width, "8", null, null, params, atts);
}
function _run() {
loadPlayer();
}
google.setOnLoadCallback(_run);
</script>