Skip to content

Commit

Permalink
MDL-38158 media: missing require and videojs fallback
Browse files Browse the repository at this point in the history
Problems picked up by behat tests
  • Loading branch information
marinaglancy committed Nov 7, 2016
1 parent b667a67 commit 2a63c0b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions media/classes/player_native.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public static function replace_sources($tag, $sources) {
}

public function get_supported_extensions() {
global $CFG;
require_once($CFG->libdir . '/filelib.php');
return file_get_typegroup('extension', ['html_video', 'html_audio']);
}

Expand Down
2 changes: 2 additions & 0 deletions media/player/html5audio/classes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public function embed($urls, $name, $width, $height, $options) {
}

public function get_supported_extensions() {
global $CFG;
require_once($CFG->libdir . '/filelib.php');
return file_get_typegroup('extension', 'html_audio');
}

Expand Down
3 changes: 3 additions & 0 deletions media/player/html5audio/tests/player_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public function test_is_installed() {
* Test method get_supported_extensions()
*/
public function test_supported_extensions() {
global $CFG;
require_once($CFG->libdir . '/filelib.php');

$nativeextensions = file_get_typegroup('extension', 'html_audio');

// Make sure that the list of extensions from the setting is exactly the same as html_audio group.
Expand Down
2 changes: 2 additions & 0 deletions media/player/html5video/classes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public function embed($urls, $name, $width, $height, $options) {
}

public function get_supported_extensions() {
global $CFG;
require_once($CFG->libdir . '/filelib.php');
return file_get_typegroup('extension', 'html_video');
}

Expand Down
7 changes: 6 additions & 1 deletion media/player/videojs/classes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class media_videojs_plugin extends core_media_player_native {
* @return string
*/
public function embed($urls, $name, $width, $height, $options) {
global $CFG;
require_once($CFG->libdir . '/filelib.php');

$sources = array();
$mediamanager = core_media_manager::instance();
$datasetup = [];
Expand Down Expand Up @@ -157,7 +160,7 @@ public function embed($urls, $name, $width, $height, $options) {
} else {
// Create <video> or <audio> tag with necessary attributes and all sources.
$attributes += ['preload' => 'auto', 'controls' => 'true', 'title' => $title];
$text = html_writer::tag($isaudio ? 'audio' : 'video', $sources, $attributes);
$text = html_writer::tag($isaudio ? 'audio' : 'video', $sources . self::PLACEHOLDER, $attributes);
}

// Limit the width of the video if width is specified.
Expand Down Expand Up @@ -188,6 +191,8 @@ protected static function pick_video_size(&$width, &$height) {
}

public function get_supported_extensions() {
global $CFG;
require_once($CFG->libdir . '/filelib.php');
if ($this->extensions === null) {
$filetypes = preg_split('/\s*,\s*/',
strtolower(trim(get_config('media_videojs', 'videoextensions') . ',' .
Expand Down
3 changes: 2 additions & 1 deletion mod/lesson/tests/behat/import_images.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ Feature: In a lesson activity, teacher can import embedded images in questions a
And I upload "mod/lesson/tests/fixtures/multichoice.xml" file to "Upload" filemanager
And I press "Import"
Then I should see "Importing 1 questions"
And I should see "bonjour.mp3"
And I should see " Listen to this greeting:"
And I should see "What language is being spoken?"
And I press "Continue"
And I should see "What language is being spoken?"
And "//audio[contains(@title, 'Listen to this greeting:')]/source[contains(@src, 'bonjour.mp3')]" "xpath_element" should exist
And "//*[contains(@class, 'answeroption')]//img[contains(@src, 'pluginfile.php')]" "xpath_element" should exist
And "//*[contains(@class, 'answeroption')]//img[contains(@src, 'flag-france.jpg')]" "xpath_element" should exist

0 comments on commit 2a63c0b

Please sign in to comment.