最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Fancybox, play a youtube video with start time and autoplay - Stack Overflow

programmeradmin1浏览0评论

I'm using Fancybox to play a youtube video. Works as expected. Video pops up and plays great. However, I would like to use both AUTOPLAY and Start Time when my video is clicked.

Here is the URL I'm trying.

;amp;autoplay=1&t=0m47s

Autoplay works fine, but the start time is ignored.

Any suggestions?

Thanks!

I'm using Fancybox to play a youtube video. Works as expected. Video pops up and plays great. However, I would like to use both AUTOPLAY and Start Time when my video is clicked.

Here is the URL I'm trying.

http://www.youtube./watch?v=BwaKZ4r5fQM&autoplay=1&t=0m47s

Autoplay works fine, but the start time is ignored.

Any suggestions?

Thanks!

Share Improve this question edited Mar 12, 2015 at 22:30 Rick Freeman asked Mar 12, 2015 at 20:33 Rick FreemanRick Freeman 411 gold badge1 silver badge5 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

The easiest way to do is using fancybox media helpers so

1). Load the fancybox media helper js file :

<script type="text/javascript" src="{your correct path}/helpers/jquery.fancybox-media.js"></script>

2). Only set your youtube URL without any parameter like :

<a class="fancybox" href="http://www.youtube./watch?v=BwaKZ4r5fQM">Start YouTube in fancybox at 47 secs</a>

3). Enable the media helper in your fancybox custom initialization script and pass the youtube parameters using this format :

jQuery(document).ready(function ($) {
    $(".fancybox").fancybox({
        helpers: {
            media: true
        },
        youtube: {
            autoplay: 1, // enable autoplay
            start: 47 // set start time in seconds (embed)
        }
    }); // fancybox
}); // ready

NOTE : the media helper will convert the video URL in its embed format like :

http://www.youtube./embed/BwaKZ4r5fQM

... where the parameter t={mm}m{ss}s is not longer valid.

With youtube embedded player you can select the start time using the start parameter followed by the number in seconds of the wanted starting time (as we did in the fancybox initialization script)

发布评论

评论列表(0)

  1. 暂无评论