Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Base class for media players

Copyright: 2016 Marina Glancy
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 246 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

core_media_player:: (9 methods):
  get_supported_extensions()
  get_embeddable_markers()
  supports()
  is_enabled()
  list_supported_urls()
  get_name()
  compare_by_rank()
  pick_video_size()
  setup()


Class: core_media_player  - X-Ref

Base class for media players.

Media players return embed HTML for a particular way of playing back audio
or video (or another file type).

get_supported_extensions()   X-Ref
Gets the list of file extensions supported by this media player.

Note: This is only required for the default implementations of
list_supported_urls(), get_embeddable_markers() and supports().
If you override these functions to determine
supported URLs in some way other than by extension, then this function
is not necessary.

return: array Array of strings (extension not including dot e.g. '.mp3')

get_embeddable_markers()   X-Ref
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: array Array of keywords to add to the embeddable markers list

supports($usedextensions = [])   X-Ref
Returns human-readable string of supported file/link types for the "Manage media players" page

param: array $usedextensions extensions that should NOT be highlighted
return: string

is_enabled()   X-Ref


list_supported_urls(array $urls, array $options = array()   X-Ref
Given a list of URLs, returns a reduced array containing only those URLs
which are supported by this player. (Empty if none.)

param: array $urls Array of moodle_url
param: array $options Options (same as will be passed to embed)
return: array Array of supported moodle_url

get_name($name, $urls)   X-Ref
Obtains suitable name for media. Uses specified name if there is one,
otherwise makes one up.

param: string $name User-specified name ('' if none)
param: array $urls Array of moodle_url used to make up name
return: string Name

compare_by_rank()   X-Ref


pick_video_size(&$width, &$height)   X-Ref
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).

param: int $width Width passed to function (updated with final value)
param: int $height Height passed to function (updated with final value)

setup($page)   X-Ref
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 {@link self::embed()} method is meant to be used for that.

param: moodle_page $page The page we are going to add requirements to.