Vimeo默认为html5嵌入

时间:2015-09-17 12:32:50

标签: javascript html5 vimeo vimeo-api vimeo-player

您好,我正在尝试视频自动播放和静音。但在移动设备上,它不会因闪光而显示。

这是我的代码。

<div id="vimeo"> </div>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>

<script type="text/javascript">
        function vimeo_player_loaded() {
        moogaloop3 = document.getElementById('vimeo');
        moogaloop3.api_setVolume(0);
        }
        var flashvars = {
        'clip_id': '138036294', // <--vimeo video ID
         'server': 'vimeo.com',
        'show_title': 0,
        'show_byline': 0,
        'show_portrait': 0,
        'fullscreen': 0,
        'autoplay': 1,
        'js_api': 1,
        'js_onload': 'vimeo_player_loaded'
        }
        var parObj = {
        'swliveconnect':true,
        'fullscreen': 1,
        'allowscriptaccess': 'always',
        'allowfullscreen':true
        };
        var attObj = {}
        attObj.id="vimeo";
        swfobject.embedSWF("http://www.vimeo.com/moogaloop.swf", "vimeo", "343", "193", "9.0.28", '',flashvars,parObj, attObj );
        </script> 

我如何将其默认为html5?

1 个答案:

答案 0 :(得分:1)

使用

找到另一种方法
<div id="vimeo"> <div>

 <script>
 // URL of the video
    var videoUrl = 'http://www.vimeo.com/76979871';

    var endpoint = 'http://www.vimeo.com/api/oembed.json';
    var callback = 'embedVideo';
    var url = endpoint + '?url=' + encodeURIComponent(videoUrl)+ '&autoplay=true' + '&callback=' + callback + '&width=420';
    function embedVideo(video) {
        document.getElementById('vimeo').innerHTML = unescape(video.html);
    }
    function init() {
        var js = document.createElement('script');
        js.setAttribute('type', 'text/javascript');
        js.setAttribute('src', url);
        document.getElementsByTagName('head').item(0).appendChild(js);
    }


    window.onload = init;