如何在图像点击上玩vimeo播放器? [英] how can i play vimeo player on image click?

查看:70
本文介绍了如何在图像点击上玩vimeo播放器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种情况我想在我的网站上添加一个vimeo播放器,在播放器上方我需要显示一个图像。当点击图像我想要vimeo播放器播放。
到现在为止我做了一点,我设法让页面上的vimeo播放器点击图像。但现在我需要手动播放它。任何人告诉我如何在图像点击上自动播放它?
i已经完成了一些代码我在这里粘贴它

i have a situation i want to add a vimeo player in to my site,and above the player i need to show an image. when image is clicked i want vimeo player to play. till now i have done a little in which i managed to get vimeo player on page on image click.but now i need to mannually play it. any one tell me how i can autoplay it on image click? i have already done some code nd i am pasting it here

<script type="text/javascript">

    function imgClick() {
        var video = '<iframe src="http://player.vimeo.com/video/36302746?title=0&amp;byline=0&amp;portrait=0" width="400" height="225" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""> </iframe>';
        document.getElementById("vPlayer").innerHTML = video;
    }

</script>


推荐答案

iframe不只是在innerHtml上添加它的文本,您需要将其添加为元素。因此,ether将其创建为元素,以太将其添加为标记,并在html代码上准备就绪,并且只需更改它的src和可见性。以下是如何在onfly上创建它。

The iframe is not just text to add it on innerHtml, you need to add it as element. So ether create it as element, ether add it as tag all ready on your html code, and just change the src and visibility of it. Here is how you can create it onfly.

function imgClick() {    
        var ifrm = document.createElement("IFRAME"); 
           ifrm.setAttribute("src", "http://player.vimeo.com/video/36302746?title=0&amp;byline=0&amp;portrait=0"); 
           ifrm.style.width = "400px"; 
           ifrm.style.height = "224px"; 
           // add rest of your values
           ifrm.frameborder = 0;
           document.getElementById("vPlayer").appendChild(ifrm); 
        return false;        
}

我测试此代码并正常工作。从您的图片中调用它为 onclick =return imgClick();

I test this code and working. Call it from your image as onclick="return imgClick();"

这篇关于如何在图像点击上玩vimeo播放器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆