Base class for players which return native HTML5 <video> or <audio> tags.
More...
|
| embed ($urls, $name, $width, $height, $options) |
| Generates code required to embed the player.
|
|
| get_embeddable_markers () |
| Lists keywords that must be included in a url that can be embedded with this player.
|
|
| get_rank () |
| Gets the ranking of this player.
|
|
| get_supported_extensions () |
| Gets the list of file extensions supported by this media player.
|
|
| is_enabled () |
|
| list_supported_urls (array $urls, array $options=array()) |
| Given a list of URLs, returns a reduced array containing only those URLs which are supported by this player.
|
|
| setup ($page) |
| Setup page requirements.
|
|
| supports ($usedextensions=[]) |
| Returns human-readable string of supported file/link types for the "Manage media players" page.
|
|
|
const | LINKPLACEHOLDER = '<!--LINKFALLBACK-->' |
| Placeholder text used to indicate where the link fallback is placed.
|
|
const | PLACEHOLDER = '<!--FALLBACK-->' |
| Placeholder text used to indicate where the fallback content is placed within a result.
|
|
|
| get_name ($name, $urls) |
| Obtains suitable name for media.
|
|
|
static | pick_video_size (&$width, &$height) |
| Utility function that sets width and height to defaults if not specified as a parameter to the function (will be specified either if, (a) the calling code passed it, or (b) the URL included it).
|
|
Base class for players which return native HTML5 <video> or <audio> tags.
- Copyright
- 2016 Marina Glancy
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ add_attributes()
static core_media_player_native::add_attributes |
( |
| $tag, |
|
|
| $attributes ) |
|
static |
Adds attributes to the media tags.
- Parameters
-
string | $tag | html tag which properties are extracted, for example "<video ...>....</video>" |
array | $attributes | key-value pairs of attributes to be added |
- Return values
-
◆ compare_by_rank()
static core_media_player::compare_by_rank |
( |
| ) |
|
|
staticinherited |
◆ embed()
core_media_player::embed |
( |
| $urls, |
|
|
| $name, |
|
|
| $width, |
|
|
| $height, |
|
|
| $options ) |
|
abstractinherited |
Generates code required to embed the player.
The returned code contains a placeholder comment '' (constant core_media_player\PLACEHOLDER) which indicates the location where fallback content should be placed in the event that this type of player is not supported by user browser.
The $urls parameter includes one or more alternative media formats that are supported by this player. It does not include formats that aren't supported (see list_supported_urls).
The $options array contains key-value pairs. See OPTION_xx constants for documentation of standard option(s).
- Parameters
-
array | $urls | URLs of media files |
string | $name | Display name; '' to use default |
int | $width | Optional width; 0 to use default |
int | $height | Optional height; 0 to use default |
array | $options | Options array |
- Return values
-
string | HTML code for embed |
Reimplemented in core_media_player_external, media_html5audio_plugin, media_html5video_plugin, and media_videojs_plugin.
◆ get_attribute()
static core_media_player_native::get_attribute |
( |
| $tag, |
|
|
| $attrname, |
|
|
| $type = PARAM_RAW ) |
|
static |
Extracts a value for an attribute.
- Parameters
-
string | $tag | html tag which properties are extracted, for example "<video ...>....</video>" |
string | $attrname | name of the attribute we are looking for |
string | $type | one of PARAM_* constants to clean the attribute value |
- Return values
-
◆ get_embeddable_markers()
core_media_player::get_embeddable_markers |
( |
| ) |
|
|
inherited |
Lists keywords that must be included in a url that can be embedded with this player.
Any such keywords should be added to the array.
For example if this player supports FLV and F4V files then it should add '.flv' and '.f4v' to the array. (The check is not case-sensitive.)
Default handling calls the get_supported_extensions function, so players only need to override this if they don't implement get_supported_extensions.
This is used to improve performance when matching links in the media filter.
- Return values
-
array | Array of keywords to add to the embeddable markers list |
Reimplemented in media_videojs_plugin, media_vimeo_plugin, and media_youtube_plugin.
◆ get_name()
core_media_player::get_name |
( |
| $name, |
|
|
| $urls ) |
|
protectedinherited |
Obtains suitable name for media.
Uses specified name if there is one, otherwise makes one up.
- Parameters
-
string | $name | User-specified name ('' if none) |
array | $urls | Array of moodle_url used to make up name |
- Return values
-
◆ get_rank()
core_media_player::get_rank |
( |
| ) |
|
|
abstractinherited |
◆ get_supported_extensions()
core_media_player_native::get_supported_extensions |
( |
| ) |
|
◆ is_enabled()
core_media_player::is_enabled |
( |
| ) |
|
|
inherited |
◆ list_supported_urls()
core_media_player_native::list_supported_urls |
( |
array | $urls, |
|
|
array | $options = array() ) |
◆ pick_video_size()
static core_media_player::pick_video_size |
( |
& | $width, |
|
|
& | $height ) |
|
staticprotectedinherited |
Utility function that sets width and height to defaults if not specified as a parameter to the function (will be specified either if, (a) the calling code passed it, or (b) the URL included it).
- Parameters
-
int | $width | Width passed to function (updated with final value) |
int | $height | Height passed to function (updated with final value) |
Reimplemented in media_html5video_plugin, and media_videojs_plugin.
◆ remove_attributes()
static core_media_player_native::remove_attributes |
( |
| $tag, |
|
|
| $attrname ) |
|
static |
Removes an attribute from the media tags.
- Parameters
-
string | $tag | html tag which properties are extracted, for example "<video ...>....</video>" |
string | array | $attrname | |
- Return values
-
◆ replace_sources()
static core_media_player_native::replace_sources |
( |
| $tag, |
|
|
| $sources ) |
|
static |
Replaces all embedded <source> tags and src attribute.
- Parameters
-
string | $tag | html tag which properties are extracted, for example "<video ...>....</video>" |
string | $sources | replacement string (expected to contain <source> tags) |
- Return values
-
◆ setup()
core_media_player::setup |
( |
| $page | ) |
|
|
inherited |
Setup page requirements.
The typical javascript requirements MUST not take action on the content directly. They are meant to load the required libraries and listen to events in order to know when to take action. The role of this method is not to provide a way for plugins to look for content to embed on the page. The self::embed() method is meant to be used for that.
- Parameters
-
moodle_page | $page | The page we are going to add requirements to. |
- Since
- Moodle 3.2
Reimplemented in media_videojs_plugin.
◆ supports()
core_media_player::supports |
( |
| $usedextensions = [] | ) |
|
|
inherited |
Returns human-readable string of supported file/link types for the "Manage media players" page.
- Parameters
-
array | $usedextensions | extensions that should NOT be highlighted |
- Return values
-
Reimplemented in media_videojs_plugin.
◆ LINKPLACEHOLDER
const core_media_player::LINKPLACEHOLDER = '<!--LINKFALLBACK-->' |
|
inherited |
Placeholder text used to indicate where the link fallback is placed.
No other players will apply to it but it will be converted to the link in the end (unless prevented by OPTION_NO_LINK).
The documentation for this class was generated from the following file: