Hangouts are used by Google to provide streaming of live-events in youtube.
The problem with Video Embeded Field is that pasting a code of a live event result in streaming of the event from the beginning of the event for users, rather than starting from current time.
Setting "autostart" doesn't help.

Thi is not a problem of Google itself, as embedding this code on the same page (a textarea) works:
<iframe width="420" height="315" src="http://www.youtube.com/embed/3ks1uVrvS1k" frameborder="0" allowfullscreen></iframe>

This is instead the embedded code produced by the video_embed_field module:
<iframe width="500px" height="350px" src="//www.youtube.com/embed/3ks1uVrvS1k?width=500px&amp;height=350px&amp;theme=dark&amp;autoplay=1&amp;hd=1&amp;rel=0&amp;showinfo=0&amp;modestbranding=1&amp;iv_load_policy=1&amp;autohide=2&amp;start=0&amp;wmode=opaque" frameborder="0" allowfullscreen></iframe>

Is there an option that can be changed ?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sylvaticus’s picture

ok, I got it.. the problem is.. guess what, "start=0".

I can unset start from $settings in video_embed_field.handlers.inc but will I get problems somewhere else?
Can I use the api to do it on my own module ?

I tried to use this code but it is never executed:

function MY_OWN_MODULE_handle_youtube($url, $settings) {
  $output = array();
  $id = _video_embed_field_get_youtube_id($url);
  if (!$id) {
    // We can't decode the URL - just return the URL as a link
    $output['#markup'] = l($url, $url);
    return $output;
  }
  unset($settings['start']);
  $output['#markup'] = '<iframe width="' . $settings['width'] . '" height="' . $settings['height'] . '" src="//www.youtube.com/embed/' . $id . '?' . $settings_str . '" frameborder="0" allowfullscreen></iframe>';

  return $output;
}
sylvaticus’s picture

Category: support » bug

On a double tough I think that this is actually a small bug: the logic should be: if there is #t=.... => ok, handle it; but if there isn't any #t parameter there shouldn't be any 'start' parameter added to the embedded code (and not start=0).

Thank you :-)

randallknutson’s picture

Ran into this exact issue with a youtube live video. Patch attached to do what #2 says. Only set the start time when #t is there.

randallknutson’s picture

Priority: Normal » Major
Status: Active » Needs review
sylvaticus’s picture

Hello, the patch in #3 gives error if there is some s..t passed in the #t parameters.
Further, LIKE IN THE ORIGINAL, it does not consider the case that t is already given directly in seconds (e.g. #t=125 for 2 minutes and 5 seconds), like it seems the default now in youtube.

Hence here is a small rewrite that considers all the cases: live stream (no '#t=' defined), #t=125, #t=2m5s and #t=whatever.

function video_embed_field_handle_youtube($url, $settings) {
  $output = array();

  //Grab the minutes and seconds, and just convert it down to seconds
  if(preg_match('/#t=((?P<min>\d+)m)?((?P<sec>\d+)s)?((?P<tinsec>\d+))?/', $url, $matches)){
    if(isset($matches['tinsec'])){
      $settings['start'] = $matches['tinsec']; // url already in form #t=125 for 2 minutes and 5 seconds
    } else {
      // url in form #t=2m5s or with other useless data, this is why we still keep adding the default data..
      // give it some default data in case there is no #t=...
      $matches += array(
        "min" => 0,
        "sec" => 0,
      );
      $time = ($matches["min"] * 60) + $matches["sec"];
      $settings['start'] = $time;
    }
  }
  $id = _video_embed_field_get_youtube_id($url);
  if (!$id) {
    // We can't decode the URL - just return the URL as a link
    $output['#markup'] = l($url, $url);
    return $output;
  }
  // Construct the embed code
  $settings['wmode'] = 'opaque';
  $settings_str = _video_embed_code_get_settings_str($settings);

  $output['#markup'] = '<iframe width="' . $settings['width'] . '" height="' . $settings['height'] . '" src="//www.youtube.com/embed/' . $id . '?' . $settings_str . '" frameborder="0" allowfullscreen></iframe>';

  return $output;
}
randallknutson’s picture

Reroll of #3. (Sorry I didn't include the improvements)

  • plopesc committed 2b1b219 on 7.x-2.x authored by sylvaticus
    Issue #2009048 by randallknutson, sylvaticus: Google Hangouts (youtube)...
plopesc’s picture

Status: Needs review » Fixed

Hello,

I committed an apporach similar to #5 but adding more checking to ensure time is not set unless has a value > 0.

Thank you all for your patches and involvement.

Regards,

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.