Skip to main content

Brightcove Video Connect for Drupal 8 - Part 1: Architecture summary and Technical approach for development

Senior Developer, Drupal Architect
May 08, 2016

In this multi-part blog series, we will be covering the various aspects of the new Brightcove Video Connect module for Drupal 8. This first part consists of an Architecture summary and the Technical details surrounding the config and content entities.

Part 1: Architecture summary
Part 2: Installation & Configuration
Part 3: Video & Playlist Management
Part 4: Including Videos & Playlists in Drupal content

Architecture summary

The Drupal 8 version of the Brightcove Video Connect module was rewritten from scratch in order to take advantage of the architectural changes in Drupal 8, especially the new Entity Data Model. Drupal 8 core and its contrib modules handle many of the functions that had to be custom-written for the Drupal 7 module. This new Drupal 8 module actively utilizes the Inline Entity Form module and there is support for Entity Browser, therefore fitting nicely into Drupal 8’s entity system architecture. Since Drupal 8 core also includes well rounded Views support out of the box, most of the module development was attributed to the module’s data synchronization via Brightcove’s API.

Designed around the new entity system in Drupal 8, the new Brightcove module seamlessly integrates video publishing into the Drupal editorial workflow and interface. This alleviates the fragmented editorial experience typically associated with 3rd party video hosting services.

Technical details

The Drupal 8 version of the Brightcove Video Connect module sports a number of config and content entities. The three major building blocks are:

  • API Client config entity: holds all the data needed to connect to the Brightcove API utilizing the PHP wrapper library.

  • Brightcove Video content entity: a required entity reference to the API Client config entity, all the data that is supported by the Brightcove API and the PHP wrapper library but the video file itself, and possibly other Drupal-only fields as this entity type is (Drupal-) fieldable.

  • Brightcove Playlist content entity: a required entity reference to the API Client config entity, all the data that is supported by the Brightcove API and the PHP wrapper library, a multiple-value entity reference field to Brightcove Videos in case of a manual playlist, and possibly other Drupal-only fields as this entity type is also (Drupal-) fieldable.

There are various other smaller content entities, but they’re mostly hidden from the user, such as:

  • Custom field content entity: this stores the definitions about the custom fields for each API Client. These fields are dynamically generated on the Video entity’s form, and handled through API calls, like the default value, description or the saved value. The custom field values are also stored on the Video entity.

  • Player content entity: Stores some minimal information about the player config, like width and height. These values are applied to the player display if possible.

  • Text Track entity: Holds all metadata about the text tracks, after the ingestion the uploaded file is removed.

Synchronization of content between Brightcove and Drupal is a two-way thing.

  • When a change is made to a Brightcove-related Drupal entity on the Drupal site/side, the module pushes those changes to Brightcove immediately.

  • The module has a built-in mechanism to “download” changes from the Brightcove site to the Drupal site, which may occur by three different triggers.

    • First of all, the module uses Drupal’s cron system to download changes from Brightcove to Drupal when the last change dates are different on any given content entity. When all changes have been downloaded to the Drupal site, the synchronization starts over again.

    • Secondly, the site administrator can initiate finishing the current synchronization in a batch process, initiate a completely new synchronization, or stop the currently running one from the admin interface (see below).

    • Thirdly, when the user wants to edit a Brightcove-related content entity on the Drupal site and the last change date of that entity is newer at Brightcove, a message is shown to the user with a link that downloads the latest data from Brightcove to Drupal before the user makes changes to it. It also checks if the video was deleted from Brightcove Studio, in this case the user can delete the local version or recreate it (however the video file won’t be available).

  • For more detailed information about the content synchronization from Brightcove to Drupal, see the comment for the _brightcove_initiate_sync() function in the code.

For various tasks, several already-existing Drupal (contrib) modules are used.

  • The Time Formatter module is nothing more than displaying a number of seconds (either an integer or a float) in fancy formats like “16h58m17s”.

  • The Entity Browser module can be used eg. for selecting videos for a manual playlist.

  • The Inline Entity Form module is used for creating and storing informations about the text tracks, currently only new text tracks can be created or deleted, but it is not possible to edit them for now through Drupal.


Part 2: Installation & Configuration
Part 3: Video & Playlist Management
Part 4: Including Videos & Playlists in Drupal content


The new Drupal 8 module was developed by Tamás Nagy and me, CSÉCSY László.
Jan Mashat was the project manager and László Brindza was responsible for testing.

László has been a backend developer since he met Drupal in 2007. He has experience in HTML, PHP, MySQL, Git, Linux server administration, mentoring, and even a slight touch of jQuery. His main interests are interoperability, architectural discovery, gardening, music score engraving and volunteer church work.

Newsletter

Articles on devportals, DX and API docs, event recaps, webinars, and more. Sign up to be up to date with the latest trends and best practices.

 

Subscribe