Skip to content

Add media player providers support in @textpattern CMS through oui_player v2+

License

Notifications You must be signed in to change notification settings

NicolasGraph/oui_provider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oui_provider

Introduction

Extension base oui_player v2+.
See oui_player for more informations.

Supported extensions

As known at the last plugin release…

Plugin requirements

oui_player’s minimum requirements:

Plugin management

Installation

From the admin interface

Follow the below instructions before or after installing the wanted oui_player extensions:

  1. Download the compiled plugin file or the source to compile a customized file.
  2. Paste the content of the compiled plugin file under the “Admin > Plugins”:?event=plugin tab and click the Upload button.
  3. Confirm the plugin install by clicking the Install button on the plugin preview page.
  4. Enable the plugin.

Once the plugin and its extensions enabled, you will need to complete the setup by clicking Options or visiting your “Admin > Preferences”:?event=prefs#prefs_group_oui_player tab.
This last step need to be repeated each time you add or remove one or more oui_player extensions to update the plugin preferences.

Via Composer (not available yet)

After installing Composer

  1. Target your project directory:
    $ cd /path/to/your/textpattern/installation/dir
  2. If it’s not already done, lock your version of Txp:
    $ composer require textpattern/lock:4.6.2, where 4.6.2 is the Txp version in use.
  3. Install oui_player:
    $ composer require nicolasgraph/oui_player
  4. Connect to the Txp admin interface and click Options or visit your “Admin > Preferences”:?event=prefs#prefs_group_oui_player tab to fill the plugin prefs.

Update

From the admin interface

Follow the install instructions.
If you are updating from v1.*, be sure to install all wanted extensions before to visit the “Admin > Preferences”:?event=prefs#prefs_group_oui_player tab to keep your preference values untouched.

Via Composer (not available yet)

$ composer update nicolasgraph/oui_player

Uninstall

From the admin interface

  1. Check the box on the left of the plugin row under the “Admin > Plugins”:?event=plugin.
  2. open the select list at the bottom of the plugins table and choose Delete.
  3. confirm the plugin deletion.

Via Composer (not available yet)

$ composer remove nicolasgraph/oui_player

Extension creation

Instructions

A provider related extension can be created by extending the Oui\Provider class in a plugin author prefix related namespace.
As oui_provider may be not installed yet while enabling the new extension; it seems safe to wrap the new child class in a related condition clause.
Once the class created, in most cases, it should only require to override some static properties.

Properties

patterns
Associative array of 'scheme', as a RegEx to check against media URL’s, and 'id', as the index of the media ID in potential matches.
Multiple $patterns can be defined through a multidimensional array. In this case, two optional subkeys can be useful: prefix defines a string to prepend to the matched media ID, and glue defines a string to append to the ID if multiple schemes can be matched at once. =:
src
URL base of the provider player. =:
glue
Array of three strings to append, between the URL player base and media info, between the media info and the player parameters, and finally, between the player parameters.
dims
Associative array of 'width', 'height' and 'ratio' values as strings.
params
Associative array of player paramaters and their related 'default' value and 'valid' values.
Player parameters are used to set plugin preferences and tag attributes.
'valid' values can be set to an array of strings or to a valid input type used for the plugin preference.
If an optional force key is set, the parameter will be used by the player even if its value is set to the default one. =:

Example

namespace Oui {

    if (class_exists('Oui\Provider')) {

        class Bandcamp extends Provider
        {
            protected static $patterns = array(
                'album' => array(
                    'scheme' => '#((http|https)://bandcamp\.com/(EmbeddedPlayer/)?album=(\d+)/?)#i',
                    'id'     => 4,
                    'prefix' => 'album=',
                    'glue' => '/',
                ),
                'track' => array(
                    'scheme' => '#((http|https)://bandcamp\.com/(EmbeddedPlayer/)?[\S]+track=(\d+)/?)#i',
                    'id'     => 4,
                    'prefix' => 'track=',
                ),
            );
            protected static $src = '//bandcamp.com/';
            protected static $glue = array('EmbeddedPlayer/', '/', '/');
            protected static $dims = array(
                'width'  => '350',
                'height' => '470',
                'ratio'  => '',
            );
            protected static $params = array(
                'size'      => array(
                    'default' => 'large',
                    'force'   => true,
                    'valid'   => array('large', 'small'),
                ),
                'artwork'   => array(
                    'default' => '',
                    'valid'   => array('', 'none', 'big', 'small'),
                ),
                'bgcol'     => array(
                    'default' => '#ffffff',
                    'valid'   => 'color',
                ),
                'linkcol'   => array(
                    'default' => '#0687f5',
                    'valid'   => 'color',
                ),
                'tracklist' => array(
                    'default' => 'true',
                    'valid'   => array('true', 'false'),
                ),
            );
        }
    }
}

Credits

Author

Nicolas Morand
Thank you to the Textpattern community and the core team.

License

This plugin is distributed under GPL v2.0.

oui_provider version 1.0.0-BETA4, Copyright © 2018 Nicolas Morand
This Textpattern plugin comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions.

Changelog

  • oui_provider v1.0.0-BETA4 (2018-08-15)
    • Added: pluggable_ui related callback on each rendered player;
    • Added: HTML5 validation;
    • changed: now works as an extension base for oui_player; any plugin extending the \Oui\Provider class in an author prefix related namespace will be plugged into oui_player;
    • added: manages responsive embedding;
    • changed: does not return any player if there is nothing to play (triggers an error);
    • Added: triggers an error if an attribute value is not valid (for defined valid values only);
    • changed: code rework:
      • uses an author prefix related namespace;
      • declares providers related dedicated tags;
      • instances created/get via Txp::get();
      • allows $dims/$prefs to accept a string as default value.
  • oui_player v1.3.1 (2017-07-13)