Skip to content
Snippets Groups Projects
Commit 230265f3 authored by Justus Dieckmann's avatar Justus Dieckmann
Browse files

Add error message in case there is no stream for the video

parent 9d72c61d
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,7 +134,8 @@ class filter_opencast extends moodle_text_filter { ...@@ -134,7 +134,8 @@ 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']) && count($data['streams']) === 1) { if (isset($data['streams'])) {
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'];
$resolution = $res['w'] . '/' . $res['h']; $resolution = $res['w'] . '/' . $res['h'];
...@@ -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