Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Alex UA’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev
Status: Active » Postponed (maintainer needs more info)

This would be a nice addition to the module, though I'm not really sure how it would best be implemented. I'm guessing the only way to do this would be to look for the #t= hash and pulling out the value. But- have you tried using the #t= in the embedded code? Does it still work?

andrewsuth’s picture

+1

From: http://www.online-tech-tips.com/cool-websites/how-to-specify-a-starting-...

Now once you copy it, you have to modify it by adding &start=XX parameter to the end of the URL for the video in the source code. XX can be any positive integer and is the number of seconds to start after the beginning. Basically, we’re adding a YouTube parameter to the video so that it starts when we want it to.

There's also an example of the final output of the object on the site. This method works for me just fine.

andrewsuth’s picture

Category: bug » feature
Status: Postponed (maintainer needs more info) » Active
yannickoo’s picture

interesting...

Alex UA’s picture

Project: Embedded Media Field » Media: YouTube
Component: Embedded Video Field » Code

YouTube is no longer supported directly in Emfield, moving to the Media_YouTube issue queue.

eiland’s picture

subscribe

Pls’s picture

What has to be done to have this feature? I mean is this technically easy to implement or difficult? Thanks.

Bob Enyart’s picture

As of June 30, 2012, for me, this is not working:

In the YouTube window, instead of the video streaming, I get this: "An error occurred. Please try again later."

I'm a user. I can't figure out what version of Drupal our site is running. (BTW, it's http://prolifeprofiles.com)

Help :)

yannickoo’s picture

It's Drupal 6.25 (CHANGELOG.txt and the duplicate tag).

RobW’s picture

Version: 6.x-1.x-dev » 7.x-2.x-dev

Right now only the 7.x versions are under active development. This looks like a pretty simple regex and formatter addition -- let's try and get it into 7.x-2.x, and then if anyone backports it in a patch for 6.x I'll commit it.

RobW’s picture

The YouTube player parameter docs cover a start parameter that doesn't seem to work anymore. Although it's undocumented, it looks like the current parameter is t=XXhXXmXXs.

RobW’s picture

Title: Youtube embedding doesn't respect time start point (#t=4m56s) » Add support for time-specific urls, "t" or "start" parameter

There are a few ways I can see this working. The simplest would be to rewrite the regex in MediaInternetYouTubeHandler.inc to return the video id with the t parameter, then use regex in theme.inc to split them up again, since wmode=opaque has to be the first query string parameter.

Regex wizards welcome to offer regexes.

RobW’s picture

lapith’s picture

Status: Active » Needs review
FileSize
3.28 KB

Here is a pretty simple patch as a first attempt. As far as I can tell the end param is not supported directly through the browser (IE I can't add an end to a youtube link and have that work on their site, it only works on embeds).

For this to work simply append the t and end params to the youtube link. The t can be added automatically with the share button, the end will need to be added manually:

https://www.youtube.com/watch?v=[youtube_video]&t=[start_seconds]&end=[end_seconds]

lapith’s picture

Just a quick change of a function name.

lapith’s picture

Just a quick change of a function name.

Funksmaname’s picture

Any chance of a port to 6 please? :*(

yannickoo’s picture

Status: Needs review » Needs work
  1. +++ b/includes/MediaInternetYouTubeHandler.inc
    @@ -42,13 +42,35 @@ class MediaInternetYouTubeHandler extends MediaInternetBaseHandler {
    +    if(isset($uri)) {
    ...
    +      if($start_match) {
    ...
    +      if($end_match) {
    ...
    +      return file_stream_wrapper_uri_normalize($uri);
    
    +++ b/includes/themes/media_youtube.theme.inc
    @@ -25,6 +25,18 @@ function media_youtube_preprocess_media_youtube_video(&$variables) {
    +  if(array_key_exists('t', $parts)) {
    ...
    +  if(array_key_exists('end', $parts)) {
    

    Missing space after "if".

  2. +++ b/includes/MediaInternetYouTubeHandler.inc
    @@ -120,4 +142,27 @@ class MediaInternetYouTubeHandler extends MediaInternetBaseHandler {
    +   * Finds and validates portion of the embed code to be mapped to query string params.
    

    Maximal 80 characters in a comment line.

  3. +++ b/includes/themes/media_youtube.theme.inc
    @@ -25,6 +25,18 @@ function media_youtube_preprocess_media_youtube_video(&$variables) {
    +  //Add start time if indicated
    ...
    +  //Add start time if indicated
    

    Missing space after "//" and punctation mark.

Rob_Feature’s picture

Issue summary: View changes

Just an update here since I wanted to add this patch to the latest D7 version:

  • Patch doesn't apply anymore. I had to apply it manually
  • by default, copying urls from youtube now results in a youtu.be url pattern. This isn't covered properly in the $start_patterns used for the regex. You'll need to tweak that list so that it finds the proper url structure
  • Those patterns also don't take into account the video id in the url (this seems like a huge mistake, not sure how others were making this work in the patched form). I had to add a bit, so my final pattern that works looks like this: @youtu\.be/.+?\?t=([^"\& ]+)@I'

Hope that at least helps send folks in the right direction...

brulain’s picture

Hi,

Also needing YouTube time stamp : is #16 patch OK ?

Thanks

joseph.olstad’s picture

Rob_Feature, can you please roll up a new patch with your tweak, thanks!

to clarify, this is for the 7.x-2.x version?
or 7.x-3.x ?

cristianalcaraz’s picture

Hi,

I've created a patch in order to work with new Youtube URL pattern as mentioned by @Rob_Feature.
Also added a condition to check the parameter ?t= with the new format XhYmZs.

Hope you find this useful :)

joseph.olstad’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev

this is for 3.x right?

cristianalcaraz’s picture

Yes @joseph.olstad :)
Sorry for the late reply!

cboyden’s picture

Status: Needs work » Needs review
koosvdkolk’s picture

#22 does not work for the following YouTube URL

https://www.youtube.com/embed/uEy_NGDfo_8?start=10&end=20

koosvdkolk’s picture

Status: Needs review » Needs work
koosvdkolk’s picture

Status: Needs work » Needs review
FileSize
4.28 KB

I updated patch #22

solideogloria’s picture

The added code does not follow Drupal coding standards.

solariel’s picture

Here's a cleaned version of #28 with somewhat unified regulars.

solariel’s picture

Updated regulars to eliminate possible false positives and fixed warnings in the matchEmbedCode() method when partial time (ex. 1m2s) is passed.

joseph.olstad’s picture

latest patch failed to apply, needs a re-roll

cboyden’s picture

Re-rolled patch is attached.