Media: thePlatform mpx

Last updated on
30 August 2018

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

The Media: thePlatform mpx module (Media:tpMpx) integrates with the Media module to make your mpxPlayers and mpxMedia on thePlatform.com's mpx available in Drupal as File Entities.

This module requires an administrator account for mpx on thePlatform.com. Please refer to the module project page for Basic Installation and Compatibility details.

Note: It is recommended to create a separate user/login in mpx for use with Media:tpMpx in your Drupal site.

Usage

Embedding mpxPlayers and mpxMedia

In the 1.x and 2.x branches, mpxPlayers and mpxMedia will appear in the Library tab of the Media Browser, but additionally Media:tpMpx also creates two more Media Browser tabs:

  • mpxPlayers: Select an mpxPlayer to embed.
  • mpxMedia: Select an mpxMedia to embed, and additionally select which mpxPlayer to display it with. Use the "Search" textbox to filter the mpxMedia by title or description.

These tabs were removed in the 3.x branch for performance reasons. For help on configuring the Media Browser to appear in a WYSIWYG toolbar, refer to http://drupal.org/node/1882314

Sync

mpxPlayers and mpxMedia are treated like regular Drupal File Entities, except they cannot be created or edited via Drupal: they must always be created/updated from within mpx on thePlatform.com and then imported via Media:tpMpx's Sync process.

The Media:tpMpx Sync process updates all mpxPlayers and mpxMedia with the latest versions in thePlatform, and it also creates new Drupal File Entities for:

  • Any new mpxPlayer created within the Import Account.
  • Any new mpxMedia added within the Import Account.

The Sync process can be run for mpxPlayers and mpxMedia instantly or scheduled for cron at Administration >Configuration > Media > Media: thePlatform mpx settings.

mpxPlayers and mpxFeeds

In MPX, mpxPlayers are associated with a mpxFeed. This mpxFeed defines what mpxMedia the mpxPlayer is able to play. If a mpxMedia object is not contained in the mpxFeed that a mpxPlayer is associated with, the mpxPlayer will not be able to render that mpxMedia.

Therefore, any mpxPlayers to be used in your Drupal site for rendering single mpxMedia Files should be configured with a mpxFeed that displays all published mpxMedia, so the mpxPlayer will be able to render the published mpxMedia on your site. Note that if a mpxPlayer is created without setting a mpxFeed, it will not be able to render any mpxMedia.

Inactive mpxPlayers / mpxMedia

Each mpxPlayer and mpxMedia has a Status field, which defaults to “Active” (1). If an existing mpxPlayer or mpxMedia is not returned upon Sync, Media:tpMpx sets its status to “Inactive” (0). As long as the mpxPlayer or mpxMedia was not deleted in mpx, it will still render correctly within the Drupal content it is embedded in; the “inactive” field is just a flag to indicate that it is no longer active within the mpx account on thePlatform.

If an “Inactive” mpxPlayer or mpxMedia is made active again in thePlatform, Media:tpMpx will set its status back to “Active” upon next Sync.

Deleting mpxPlayers / mpxMedia

Do not delete a player that is referenced by any mpxMedia in the Drupal Media Library without first deleting all mpxMedia Files in the Drupal Media Library referencing the the player. Otherwise, the mpxMedia will no longer render.

Note that if a mpxPlayer is deleted from the Drupal Media Library, it will still be re-imported upon Sync if the mpxPlayer is still active in the account on thePlatform.

If mpxMedia is deleted from the Drupal Media Library, it will NOT be re-imported upon Sync if the mpxMedia is still active in the account on thePlatform. This is because mpxMedia uses thePlatform's Data Service and notifications to sync. If you need to re-import mpxMedia which has been deleted from the Drupal media library, re-save your Import Account in Admin > Media > Media: thePlatform mpx settings. Upon the next sync, Media:tpMpx will import all mpxMedia in the Import Account instead of just looking for updates.

Import Log

Media:tpMpx keeps a log of all settings and import processes within a table, mpx_log. This table can be used to view the history of any mpxPlayer or mpxMedia: it logs when each was inserted, updated, activated, or re-activated. It also logs when changes have been made to Media:tpMpx settings. (The mpx_log table was removed in the 3.x branch.)

Architecture

Markup

When rendered, a mpxPlayer / mpxMedia is wrapped in a div of class media-mpx-wrapper and id media-mpx-wrapper-[MPX_ID].

  • mpxPlayer: [MPX_ID] is the “pid” field in the mpx_player table. This corresponds to the mpxPlayer’s public id field in thePlatform.
  • mpxMedia: [MPX_ID] is the “guid” field field in the mpx_video table. This corresponds to the mpxMedia's guid field in thePlatform.

mpxPlayer CSS

CSS specific to #mpx-[MPX_ID] is included in the head element of the Drupal pages that the mpxPlayer / mpxMedia appears on. This inline CSS is generated from the mpxPlayer’s CSS in thePlatform, and includes any custom inline or external CSS you have added to the mpxPlayer via thePlatform.

mpxPlayer Javascript

Javascript specific to the mpxPlayer / mpxMedia is included in the head element of the Drupal pages that the mpxPlayer / mpxMedia appears on. If you’ve added additional inline or external Javascript links into your mpxPlayer from within mpx, Media:tpMpx will include this as well.

Media:tpMpx adds a “tp:scopes” attribute into various elements inside the mpxPlayer’s HTML, with a value of the [MPX_ID]. Each mpxPlayer / mpxMedia is rendered with a unique scope variable in order to allow multiple mpxPlayers / mpxMedia to display correctly (and function independently) on a page.

Data Structure

mpxPlayers

Media:tpMpx maintains a record for each imported mpxPlayer in a table called mpx_player to store mpxPlayer data, and also creates a single File Entity in file_managed with URI: mpx://p/[id], where [id] is the mpxPlayer’s id field in mpx_player.

If the mpxPlayer’s File Entity is deleted from the Drupal Media Library, mpxMedia deletes the corresponding record from mpx_player as well.

mpxMedia

Media:tpx maintains a record for each imported mpxMedia in a table called mpx_video to store mpxMedia data, and also creates a File Entity in file_managed with URI: mpx://m/[guid]/p/[fid], where [guid] is the mpxMedia’s guid field in mpx_video and [fid] is the fid in file_managed for the selected mpxPlayer to use to render the mpxMedia.

The mpx_video.fid field contains the fid of the first File Entity created in file_managed for this mpxMedia. Storing the mpxPlayer's fid in the URI means we can have multiple File Entities in file_managed that reference a single mpxMedia record. For example:

mpxMedia “Funny Cat Video” has a guid value AbC123. When we first import it into the Drupal Media Library, we set its Default mpxPlayer to “Single Clip Player”, which has fid 64. So the first imported File Entity into file_managed has a URI: mpx://m/AbC123/p/64.

We want to embed “Funny Cat Video” with a different mpxPlayer, an imported mpxPlayer “Blue mpxPlayer”, with fid 89. Media:tpMpx checks to see if a fid exists in file_managed with URI mpx://m/AbC123/p/89.

  • If it doesn’t exist, it creates a new File Entity and embeds the new fid into the node we’re editing.
  • If it does exist, it embeds the existing fid into the node.

If a mpxMedia File Entity is deleted from the Drupal Media Library, Media:tpMpx checks file_managed to see if any other File Entities reference the mpxMedia:

  • If there are other Files that reference the mpxMedia, it updates the mpx_video record with the 1st fid it finds.
  • Otherwise it deletes the mpx_video record.

Additional Configuration

Cron

If mpxPlayers and/or mpxMedia are set to Sync when cron runs, Media:tpMpx will import all mpxPlayers and/or mpxMedia into the Drupal Media Library. Media:tpMpx is set to Sync both mpxPlayers and mpxMedia on Cron by default.

Permissions

Media:tpMpx creates the following permissions which can be granted at People > Permissions:

  • Administer mpx Account
  • Sync mpxPlayers manually
  • Sync mpxMedia manually

Users with “administer media” will be able to access the Media Browser with the additional “mpxPlayers” and “mpxMedia” tabs. These users will only be able to access the “Sync” forms on the Administration > Content > Media > mpxPlayer/mpxMedia pages if they have the required permissions as specified above.

Uninstalling Media:tpMpx

If you want to uninstall Media:tpMpx and remove all of your mpx Media File Entities, delete your mpx Media File Entities first before un-installing the module. Otherwise, Drupal will not know how to handle the mpx:// file URI, and will not allow you to delete the Media File Entities.

Help improve this page

Page status: No known problems

You can: