Making the YouTube JS API work with iOS, dealing with embedSWF?

为君一笑 提交于 2019-12-08 06:43:20

Maybe you should try new YouTube iframe Player API? https://developers.google.com/youtube/iframe_api_reference

It works with mobile devices without thinking about Flash. Embedding example:

<script type="text/javascript" src="//www.youtube.com/iframe_api"></script>

function onYouTubePlayerAPIReady() {
    var videoBox = document.getElementById('video1');
    videoBox.ytplayer = new YT.Player(videoBox, {
        videoId: 'kXDiGtgPL6E',
        playerVars: {
            //controls: 0,
            wmode:'transparent'
        },
        height: '200',
        width: '320'
    });
}

I did this exact thing a few months ago for a project...

Javascript, very similar to what you have:

<script type="text/javascript" src="js/swfobject.js"></script>
        <script type="text/javascript">
            var flashvars = {};
                flashvars.youTubeVideo = "VitQwgsBq-w";
                flashvars.controllerAlign = "top";
                flashvars.queTo = "0";
                flashvars.controlBarAlpha = ".3";
            var params = {};
            var attributes = {};
                swfobject.embedSWF("images/youTubeLoader.swf", "youTubeDiv", "250px", "200px", "9.0.0", false, flashvars, params, attributes);
</script>

What swfobject.js is going to do is look for an HTML div named "youTubeDiv" and replace all of it's contents with an SWF youtube player

(i did this b/c the iframe solution had z-index issues with an HTML5 project i was working on)

Now the HTML:

    <div id="youTubeDiv">
            <iframe width="250px" height="200px" src="http://www.youtube.com/embed/VitQwgsBq-w" frameborder="0" allowfullscreen></iframe>
    </div>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!