Skip to content
Snippets Groups Projects
Unverified Commit 5f6e9318 authored by Nina Herrmann's avatar Nina Herrmann Committed by GitHub
Browse files

Merge pull request #40 from justusdieckmann/issue-37

Prevent error if there is no stream in the episode.json
parents 66f52cf6 230265f3
Branches
No related tags found
No related merge requests found
...@@ -44,7 +44,7 @@ class filter_opencast extends moodle_text_filter { ...@@ -44,7 +44,7 @@ class filter_opencast extends moodle_text_filter {
* @throws dml_exception * @throws dml_exception
*/ */
public function filter($text, array $options = []) { public function filter($text, array $options = []) {
global $CFG, $PAGE; global $PAGE, $OUTPUT;
$i = 0; $i = 0;
if (stripos($text, '</video>') === false) { if (stripos($text, '</video>') === false) {
...@@ -134,6 +134,7 @@ class filter_opencast extends moodle_text_filter { ...@@ -134,6 +134,7 @@ class filter_opencast extends moodle_text_filter {
$mustachedata->height = $height; $mustachedata->height = $height;
$mustachedata->modplayerpath = (new moodle_url('/mod/opencast/player.html'))->out(); $mustachedata->modplayerpath = (new moodle_url('/mod/opencast/player.html'))->out();
if (isset($data['streams'])) {
if (count($data['streams']) === 1) { if (count($data['streams']) === 1) {
$sources = $data['streams'][0]['sources']; $sources = $data['streams'][0]['sources'];
$res = $sources[array_key_first($sources)][0]['res']; $res = $sources[array_key_first($sources)][0]['res'];
...@@ -153,8 +154,13 @@ class filter_opencast extends moodle_text_filter { ...@@ -153,8 +154,13 @@ class filter_opencast extends moodle_text_filter {
$mustachedata->height = $height; $mustachedata->height = $height;
} }
} }
$newtext = $renderer->render_player($mustachedata); $newtext = $renderer->render_player($mustachedata);
} else {
$newtext = $OUTPUT->render(new \core\output\notification(
get_string('erroremptystreamsources', 'mod_opencast'),
\core\output\notification::NOTIFY_ERROR
));
}
// Replace video tag. // Replace video tag.
$text = preg_replace('/<video(?:(?!<\/video>).)*?' . preg_quote($match, '/') . '.*?<\/video>/', $text = preg_replace('/<video(?:(?!<\/video>).)*?' . preg_quote($match, '/') . '.*?<\/video>/',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment