38
votes

Recently, one could use #t=2m0s or #t=120 to set start time for direct links:

http://www.youtube.com/watch?v=Fk2bUvrv-Uc#t=2m30s

as well as for embed videos:

<iframe width="420" height="315" \
src="http://www.youtube.com/embed/Fk2bUvrv-Uc#t=2m30s" \
frameborder="0" allowfullscreen></iframe>

Now it seems YouTube dropped #t start time support and the above doesn't work anymore. How can I now place reference to videos with particular start time?

8
+1 but not only for "embed videos" but for any URL reference. Your question could be made more general to cover all these cases, will be more easily googlable and will help more people :)Tomas

8 Answers

57
votes

Embed videos

Looks like a different parameter is used now - start=<number of seconds> (see this blog and documentation).

Example:

<iframe width="420" height="315" frameborder="0" allowfullscreen
        src="http://www.youtube.com/embed/Nc9xq-TVyHI?start=110&end=119"></iframe>

Direct links

For direct links, it is enough to simply replace # for &:

http://www.youtube.com/watch?v=Fk2bUvrv-Uc&t=2m30s
15
votes

You can use &t= instead of #t=

3
votes

YouTube dropped #t start time support for embed videos. Now we need ether directly use start=N&end=M parameters in seconds according to their new API, or write some extra code witch transforms our old #t=(n)m(n)s notation into new API-compatible style.

3
votes

I was able to get the video clip to work based on the start and end, but the exact code needs to be as follows:

?start=x&end=y

where x is the start time in seconds and y the end time in seconds

if the '?' isn't present it doesn't work. Also the code needs to be placed directly after the URL WITHOUT any space or it doesn't work.

1
votes

I had a large number of videos chapterised using this method with a JQuery plugin. I've adapted the plugin so that you can continue using the (n)m(n)s notation. You could change this fairly easily to grab the #t value from the URL instead of the data attribute that I'm storing it in.

(function( $ ) {    
    $.fn.videoChapters = function(iframeID) {
        if(typeof window.orig_video === 'undefined') {
            window.orig_video = [];
        }
        window.orig_video[iframeID] = $('#'+iframeID).clone();

        var chapterContainer = this;
        $(this).find('a').on('click', function(e) {
                e.preventDefault();
                $('#'+iframeID).remove();
                $(chapterContainer).prevAll('.video-iframe').first().find('h3').after(window.orig_video[iframeID]);

                var video = $('#'+iframeID);
                if(typeof window.video_source === 'undefined') {
                    window.video_source = [];
                }

                if(typeof window.video_source[iframeID] === 'undefined') {
                    window.video_source[iframeID] = $(video).attr('src');
                }
                /*  to use it with a normal anchor change this to something like the below, of course it will vary for URL
                 *  so it'd be better to use a regex, but I'll let someone else worry about that.
                 *
                 *   var str = $(e.target).attr('href').split('#t')[1];
                 *   var nstr = $(str).split("s")[0];
                 *   var mstr = $(nstr).split("m");
                 *   var min = Number(mstr[0]);
                 *   var sec = Number(mstr[1]);
                 *   
                 * */

                var seconds = $(e.target).data('seconds');

                /* youtube dropped old min/secs format, now we convert what's there to pure seconds */
                var splsec = seconds.split('m');
                var min = Number(splsec[0]);
                var sec = Number(splsec[1].split('s')[0]);

                min = min * 60;

                var total = min + sec; 

                var newSource = window.video_source[iframeID] + "?start="+total+"&autoplay=1&rel=0";
                $(video).attr('src', newSource);
        });

    };  
})( jQuery );
0
votes

The start and end time using iframe embed code doesn't work from my test. What works for me is this code:

From:

http://www.youtube.com/embed/[VIDEOID]

To:

http://www.youtube.com/v/[VIDEOID]&start=[SECONDS]&end=[SECONDS]

<object width="640" height="385">
<param name="movie" value="http://www.youtube.com/v/[VIDEOID]&start=100&end=500" />
<param name="allowscriptaccess" value="always" />
<embed src="http://www.youtube.com/v/[VIDEOID]&start=100&end=500" type="application/x-shockwave-flash" allowscriptaccess="always" width="640" height="385" />
</object>
0
votes

It seems to work (again?) with the #t= , at least for direct URLs. The stated URL: https://www.youtube.com/watch?v=Fk2bUvrv-Uc#t=2m30s works, that is: it jumps to 2min 30sec. I tested this on FF, Chrome, IE11. But probably better to use &t= , & is the common URL argument concatenating character.

0
votes

Use

/watch?v=<videoID>&t=<s>

with

<videoID>=id of the video
<t>=number of seconds to skip

Examples :

https://m.youtube.com/watch?t=58&v=9W35QxCZnK4

Video starts at 58 seconds or

https://www.youtube.com/watch?t=120&v=9W35QxCZnK4

Video starts at 2 minutes