Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403]

H5P player class.

Copyright: 2019 Sara Arjona <sara@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 625 lines (22 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: player  - X-Ref

H5P player class, for displaying any local H5P content.

__construct(string $url, \stdClass $config, bool $preventredirect = true, string $component = '',bool $skipcapcheck = false)   X-Ref
Inits the H5P player for rendering the content.

param: string $url Local URL of the H5P file to display.
param: \stdClass $config Configuration for H5P buttons.
param: bool $preventredirect Set to true in scripts that can not redirect (CLI, RSS feeds, etc.), throws exceptions
param: string $component optional moodle component to sent xAPI tracking
param: bool $skipcapcheck Whether capabilities should be checked or not to get the pluginfile URL because sometimes they

display(string $url, \stdClass $config, bool $preventredirect = true,string $component = '', bool $displayedit = false)   X-Ref
Get the encoded URL for embeding this H5P content.

param: string $url Local URL of the H5P file to display.
param: stdClass $config Configuration for H5P buttons.
param: bool $preventredirect Set to true in scripts that can not redirect (CLI, RSS feeds, etc.), throws exceptions
param: string $component optional moodle component to sent xAPI tracking
param: bool $displayedit Whether the edit button should be displayed below the H5P content.
return: string The embedable code to display a H5P file.

get_messages()   X-Ref
Get the error messages stored in our H5P framework.

return: stdClass with framework error messages.

add_assets_to_page()   X-Ref
Create the H5PIntegration variable that will be included in the page. This variable is used as the
main H5P config variable.


get_state_data(item_activity $xapiobject)   X-Ref
Get the stored xAPI state to use as user data.

param: item_activity $xapiobject
return: string The state data to pass to the player frontend

output()   X-Ref
Outputs H5P wrapper HTML.

return: string The HTML code to display this H5P content.

get_title()   X-Ref
Get the title of the H5P content to display.

return: string the title

get_context()   X-Ref
Get the context where the .h5p file belongs.

return: context The context.

delete_h5p(\stdClass $content)   X-Ref
Delete an H5P package.

param: stdClass $content The H5P package to delete.

get_export_settings(bool $downloadenabled)   X-Ref
Export path for settings

param: bool $downloadenabled Whether the option to export the H5P content is enabled.
return: \moodle_url|null The URL of the exported file.

get_cid()   X-Ref
Get the identifier for the H5P content, to be used in the arrays as index.

return: string The identifier.

get_assets()   X-Ref
Get the core H5P assets, including all core H5P JavaScript and CSS.

return: Array core H5P assets.

get_filtered_parameters()   X-Ref
Get filtered parameters, modifying them by the renderer if the theme implements the h5p_alter_filtered_parameters function.

return: string Filtered parameters.

get_dependency_files()   X-Ref
Finds library dependencies of view

return: array Files that the view has dependencies to

get_resize_code()   X-Ref
Resizing script for settings

return: string The HTML code with the resize script.

get_embed_code(string $url, bool $embedenabled)   X-Ref
Embed code for settings

param: string $url The URL of the .h5p file.
param: bool $embedenabled Whether the option to embed the H5P content is enabled.
return: string The HTML code to reuse this H5P content in a different place.

get_embed_url(string $url, string $component = '')   X-Ref
Get the encoded URL for embeding this H5P content.

param: string $url The URL of the .h5p file.
param: string $component optional Moodle component to send xAPI tracking
return: \moodle_url The embed URL.

get_export_file()   X-Ref
Return the info export file for Mobile App.

return: array or null