Hi, I'd like to customize video player accordingly to the provider features, like autoplay and such. Do you know any way to do it? Thanks

Comments

devin carlson’s picture

Status: Active » Fixed

The oEmbed protocol itself only defines the maxwidth, maxheight and format parameters but each provider may support additional custom parameters. So you may be able to do some customization, depending on whether a provider accepts a parameter for autoplay, play chrome colour, etc. Otherwise you can try to parse the response and alter the HTML or you may be better off with a single provider module such as Media: YouTube, Media: Vimeo, etc which will generally provide more customization as they work with provider-specific APIs.

You can implement hook_media_oembed_request_alter() to alter the request to the oEmbed endpoint and hook_media_oembed_response_alter() to alter the response.

Status: Fixed » Closed (fixed)

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

codesidekick’s picture

Here's an example with youtube...

/**
 * Implements hook_media_oembed_response_alter().
 */
function custom_media_oembed_response_alter(&$response) {
  if ($response['provider_name'] == 'YouTube') {
    // Use the highest resolution youtube thumbnail when generating images.
    $response['thumbnail_url'] = str_replace('hqdefault', 'maxresdefault', $response['thumbnail_url']);

    // Use 720p default quality with autoplay in lightboxes.
   $response['html'] = str_replace('?feature=oembed', '?autoplay=1&vq=hd720', $response['html']);
  }
}

It's terrible but a limitation of how oembed works.

thejimbirch’s picture

codesidekick++ Thanks, that is great.