MDL-38158 media: missing require and videojs fallback

Problems picked up by behat tests
This commit is contained in:
Marina Glancy 2016-11-07 09:21:18 +08:00
parent b667a67c47
commit 2a63c0b1c2
6 changed files with 17 additions and 2 deletions

View File

@ -108,6 +108,8 @@ abstract class core_media_player_native extends core_media_player {
}
public function get_supported_extensions() {
global $CFG;
require_once($CFG->libdir . '/filelib.php');
return file_get_typegroup('extension', ['html_video', 'html_audio']);
}

View File

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

View File

@ -61,6 +61,9 @@ class media_html5audio_testcase extends advanced_testcase {
* 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.

View File

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

View File

@ -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 = [];
@ -157,7 +160,7 @@ class media_videojs_plugin extends core_media_player_native {
} 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.
@ -188,6 +191,8 @@ class media_videojs_plugin extends core_media_player_native {
}
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') . ',' .

View File

@ -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