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

I'm using Fancybox to play a youtube video.Works as expected.Video pops up and plays great.Ho

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)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745476697a4629379.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信