Using jquery to dynamically load Vimeo videos

喜你入骨 提交于 2019-12-20 15:23:09

问题


I would like to create a function that would allow me to embed my Vimeo videos on my website and run it like a YouTube playlist i.e. when a video link is clicked, rather than reloading the page it only reloads the video. So for example, this being a film website, I have a trailer for the project as well as a few promo clips, I would like to be able to show all of those by simply having the user click a link which loads a new video. How would I do this?


回答1:


this should work too.

$('#some_video_container').html('<iframe src="http://player.vimeo.com/video/12345?
                                 title=1&amp;byline=1&amp;portrait=1" width="643"
                                 height="360" frameborder="0"></iframe>');



回答2:


Here you go.

$.getJSON('http://www.vimeo.com/api/oembed.json?url=' + encodeURIComponent('http://vimeo.com/7100569') + '&width=300&callback=?', function(data){
        $('#some_video_container').html(data.html);
});



回答3:


Checkout oembed. The best provider I know of is http://embed.ly

The official JQuery Embed.ly plugin is here: https://github.com/embedly/embedly-jquery




回答4:


I've also used Vimeo Playlist, found here: http://luwes.co/labs/vimeo-playlist/

You can set where you want the playlist list (on top, bottom or side of the video). Overall it's pretty easy to set up. You just put your video urls in an array in the script:

<div id="player"></div>
<script src="http://luwes.co/vimeowrap.js/vimeowrap.js"></script>
<script src="http://luwes.co/vimeowrap.js/vimeowrap.playlist.js"></script>
<script>
    vimeowrap('player').setup({
        urls: [
            'https://vimeo.com/user3709818',
            'https://vimeo.com/user3709818'
        ],
        plugins: {
            'playlist':{}
        }
    });
</script>


来源:https://stackoverflow.com/questions/6805297/using-jquery-to-dynamically-load-vimeo-videos

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!