Hi @Sam152,

it would be great to have option to enable thumbnails. As there was "Brightcove provider does not currently support thumbnails." exception inside provider class, I implemented it myself. Could you please review my patch? Thank you.

It provides simple UI for Brightcove API keys inserting (needs CMS Video Read permission) and then implements thumbnail download.

I'm using this approach in combination with "lazy load" formatter, but in this case, autoplay is not working. Any idea how to solve that? It's probably related to Chrome's autoplay restriction, but I'm curious if there is some workaround.

Best regards
Vit

Comments

kyberman created an issue. See original summary.

kyberman’s picture

Status: Active » Needs review
StatusFileSize
new8.16 KB
kyberman’s picture

To solve the autoplay issue, I added another feature into this patch (see interdiff). It adds config for "Autoplay player name" - if user fills this one and autoplay option is enabled for current formatter, configured player name overrides player name that was specified inside input URL. It allows user to create specific player for automatically played videos.

As a part of this new patch version, I merged patch https://www.drupal.org/files/issues/video_embed_brightcove-support_diffe..., so input player name could be respected.

kyberman’s picture

I improved settings page descriptions and changed all fields to be optional, because someone does need only "Autoplay player name", someone only thumbnails download.

kyberman’s picture

StatusFileSize
new12.63 KB

Another improvement is bringing into validation for API keys.

murrayw’s picture

Hi Sam, I have been working with Vit on this patch and I think that we have gotten it as far as we are going to in this round of development. Vit has captured all of the main points above pretty well. I will recap on what has been done:

- An admin screen with API fields has been added to handle the downloading of the thumbnails. These fields are optional and will not break any sites which do not want to populate these fields.
- We have extended this functionality to also handle lazy loading of Brightcove videos. Once again, the autoplay video ID is optional and will not break any sites which do not want to fill it in.

The lazy loading functionality was added into the patch because it would have been hard to do this in two patches because both needed to work with the admin screen.

We think the patch is a big improvement and opens the way for pages with many Brightcove videos on them: the thumbnails are shown as the preview and then lazyload when the thumbnail is clicked.

We will be using this patch in production and will report back any problems or fixes we have.

sam152’s picture

I haven't been following this issue, but have bookmarked it and will take a squiz in the morning. Thanks!

  • Sam152 committed 0a5617a on 8.x-1.x authored by kyberman
    Issue #2981221 by kyberman, murrayw: Support thumbnails
    
sam152’s picture

Status: Needs review » Fixed

Looking great, thanks for both working on this. While I have some feedback, this is a big improvement on the functionality. The module doesn't have a stable release, so I think we can continue to iterate on this stuff, as time allows.

Since more of the code in the module has been written by @kyberman than me at this point, I've also granted you permission to maintain the project. Feel free to push features/fixes and manage releases if you have capacity to do so.

Thanks!

  1. --- /dev/null
    +++ b/config/install/video_embed_brightcove.settings.yml
    
    +++ b/config/install/video_embed_brightcove.settings.yml
    @@ -0,0 +1,3 @@
    
    @@ -0,0 +1,3 @@
    +client_id: ''
    +client_secret: ''
    +autoplay_player: ''
    

    This configuration should have associated schema definitions.

  2. +++ b/src/Form/SettingsForm.php
    @@ -0,0 +1,145 @@
    +    // Check authentication if keys are provided.
    +    if (!empty($client_id) || !empty($client_secret)) {
    +      $auth_uri = 'https://oauth.brightcove.com/v4/access_token';
    +      $auth_string = base64_encode($client_id . ':' . $client_secret);
    +      $auth_options = [
    +        'headers' => [
    +          'Authorization' => 'Basic ' . $auth_string,
    +          'Content-Type' => 'application/x-www-form-urlencoded',
    +        ],
    +        'body' => 'grant_type=client_credentials',
    +      ];
    
    +++ b/src/Plugin/video_embed_field/Provider/Brightcove.php
    @@ -38,7 +92,60 @@ class Brightcove extends ProviderPluginBase {
    +    // Process authentication to get access token.
    +    $auth_uri = 'https://oauth.brightcove.com/v4/access_token';
    +    $auth_string = base64_encode($client_id . ':' . $client_secret);
    +    $auth_options = [
    +      'headers' => [
    +        'Authorization' => 'Basic ' . $auth_string,
    +        'Content-Type' => 'application/x-www-form-urlencoded',
    +      ],
    +      'body' => 'grant_type=client_credentials',
    +    ];
    +    $auth = $this->httpClient->request('POST', $auth_uri, $auth_options);
    +
    

    Here we repeat a lot of information, like the URL of the API, how to authorise with it, loading the credentials from configuration.

    This is a good candidate to split out into a seperate service. The service could have methods like canConnect and fetchRemoteThumbnail, which encapsulate the details of the API/auth within them.

  3. +++ b/video_embed_brightcove.routing.yml
    @@ -0,0 +1,9 @@
    +  requirements:
    +    _permission: 'administer site configuration'
    

    I think we should define our own permission for this. This is quite broad.

kyberman’s picture

Assigned: Unassigned » kyberman

Thank you Sam!

Nice to see this patch is merged into and that I can help with this module.

I'll review your suggestions soon, probably during next week and prepare some refactoring.

Best regards
Vit

Status: Fixed » Closed (fixed)

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

kyberman’s picture

Assigned: kyberman » Unassigned