MediaDrop was designed to make it straightforward to fully integrate new audio/video players into the display system.
While MediaDrop supports 9 Flash and/or HTML5 players out of the box (including the popular JWPlayer, Flowplayer, and Sublime Video Players, as well as several players customized to display embedded material from third-party websites), we recognize that some users may want to incorporate different players.
To this end, we have designed the playback system around a well-defined API. All of MediaDrop’s default players implement this API.
Players have 3 parts.
When a Media object is selected to be rendered, a list of StorageURIs is generated from that object’s MediaFiles. Each enabled Player is then asked, in order, if it can use any of the available StorageURIs. The first Player that can play one of the StorageURIs is rendered. This logic is contained in mediadrop.lib.players.media_player().
Players can optionally define a dict of editable properties in their default_data dict if they also provide a subclass of mediadrop.forms.admin.players.PlayerPrefsForm whose display and save_data methods can map the form values to and from the data dict. Players that do this will have links, in MediaDrop’s admin backend, to a page where an admin can use the rendered form to edit the Player instance. An example of a player that has this feature is mediadrop.lib.players.YoutubeFlashPlayer.
Any new player class will need to be imported and registered like so:
from mediadrop.lib.players import AbstractPlayer class MyPlayer(AbstractPlayer): """ Implement all abstract properties and abstract methods here ... """ AbstractPlayer.register(MyPlayer)
See the players in mediadrop/lib/players.py for examples.
This managing class inherits from goog.ui.Component. It must implement the MediaDrop-specific getSize() and setSize().
See the files in mediadrop/public/scripts/mcore/players/ for examples.
Player Base Class that all players must implement.
Initialize the player with the media that it will be playing.
Return the desired viewable height + the height of the controls.
Return the desired viewable width + any extra for the player.
Test all the given URIs to see if they can be played by this player.
This is a class method, not an instance or static method.
|Parameters:||uris (list) – A collection of StorageURI tuples to test.|
|Returns:||Boolean result for each of the given URIs.|
An optional default data dictionary for user preferences.
A unicode display name for the class, to be used in the settings UI.
Return a subset of the uris for this player.
This allows for easy filtering of URIs by feeding any number of kwargs to this function. See mediadrop.lib.uri.pick_uris().
A unicode string identifier for this class.
Each player has a client-side component to provide a consistent way of initializing and interacting with the player. For more information see mediadrop/public/scripts/mcore/players/.
Render the XHTML markup for this player instance.
|Parameters:||error_text – Optional error text that should be included in the final markup if appropriate for the player.|
|Return type:||unicode or genshi.core.Markup|
|Returns:||XHTML that will not be escaped by Genshi.|
A flag that allows us to mark the few players that can’t be resized.
Setting this to False ensures that the resize (expand/shrink) controls will not be shown in our player control bar.
Display the form with default values from the given player.
If the value dict is not fully populated, populate any missing entries with the values from the given player’s _data dict.
Map validated field values to PlayerPrefs.data.
Since form widgets may be nested or named differently than the keys in the mediadrop.lib.storage.StorageEngine._data dict, it is necessary to manually map field values to the data dictionary.
If some post-validation error is detected in the user input. This will trigger the same error handling behaviour as with the @validate decorator.