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 players which handle external links

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

Defines 1 class

core_media_player_external:: (4 methods):
  embed()
  list_supported_urls()
  get_regex()
  fix_match_count()


Class: core_media_player_external  - X-Ref

Base class for players which handle external links (YouTube etc).

As opposed to media files.

embed($urls, $name, $width, $height, $options)   X-Ref
Part of a regular expression, including ending ~ symbol (note: these
regexes use ~ instead of / because URLs and HTML code typically include
/ symbol and makes harder to read if you have to escape it).
Matches the end part of a link after you have read the 'important' data
including optional #d=400x300 at end of url, plus content of <a> tag,
up to </a>.


list_supported_urls(array $urls, array $options = array()   X-Ref
Obtains HTML code to embed the link.

param: moodle_url $url Single URL to embed
param: string $name Display name; '' to use default
param: int $width Optional width; 0 to use default
param: int $height Optional height; 0 to use default
param: array $options Options array
return: string HTML code for embed

get_regex()   X-Ref
Returns regular expression used to match URLs that this player handles

return: string PHP regular expression e.g. '~^https?://example.org/~'

fix_match_count(&$matches, $count)   X-Ref
Annoyingly, preg_match $matches result does not always have the same
number of parameters - it leaves out optional ones at the end. WHAT.
Anyway, this function can be used to fix it.

param: array $matches Array that should be adjusted
param: int $count Number of capturing groups (=6 to make $matches[6] work)