protected function YouTube::getTimeIndex in Video Embed Field 8
Same name and namespace in other branches
- 8.2 src/Plugin/video_embed_field/Provider/YouTube.php \Drupal\video_embed_field\Plugin\video_embed_field\Provider\YouTube::getTimeIndex()
Get the time index for when the given video starts.
Return value
int The time index where the video should start based on the URL.
1 call to YouTube::getTimeIndex()
- YouTube::renderEmbedCode in src/
Plugin/ video_embed_field/ Provider/ YouTube.php - Render embed code.
File
- src/
Plugin/ video_embed_field/ Provider/ YouTube.php, line 49
Class
- YouTube
- A YouTube provider plugin.
Namespace
Drupal\video_embed_field\Plugin\video_embed_field\ProviderCode
protected function getTimeIndex() {
preg_match('/[&\\?]t=((?<hours>\\d+)h)?((?<minutes>\\d+)m)?(?<seconds>\\d+)s?/', $this
->getInput(), $matches);
$hours = !empty($matches['hours']) ? $matches['hours'] : 0;
$minutes = !empty($matches['minutes']) ? $matches['minutes'] : 0;
$seconds = !empty($matches['seconds']) ? $matches['seconds'] : 0;
return $hours * 3600 + $minutes * 60 + $seconds;
}