From 89dbe1ab05b97d397abd59076859dd13cdcd93a4 Mon Sep 17 00:00:00 2001 From: geichelberger <35195803+geichelberger@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:13:08 +0100 Subject: [PATCH] Fix error notification (#51) * Fix error notification The error notification is shown if two or more streams are available, but it should only be displayed if there are no streams. * code improvements --------- Co-authored-by: ferishili --- classes/local/output_helper.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/classes/local/output_helper.php b/classes/local/output_helper.php index cd678e5..00aeee8 100644 --- a/classes/local/output_helper.php +++ b/classes/local/output_helper.php @@ -135,16 +135,17 @@ public static function output_episode($ocinstanceid, $episodeid, $modinstanceid, return; } - // Find aspect-ratio if there is only one video track. - if (count($data['streams']) === 1 && !empty($data['streams'][0]['sources'])) { + // Find aspect-ratio of the first video track. + $wrapperattrs = []; + if (!empty($data['streams']) && !empty($data['streams'][0]['sources'])) { $sources = $data['streams'][0]['sources']; $res = $sources[array_key_first($sources)][0]['res']; $resolution = $res['w'] . '/' . $res['h']; - echo \html_writer::start_div('player-wrapper', ['style' => '--aspect-ratio:' . $resolution]); - } else { - echo \html_writer::start_div('player-wrapper'); + $wrapperattrs['style'] = '--aspect-ratio:' . $resolution; } + echo \html_writer::start_div('player-wrapper', $wrapperattrs); + echo ''; echo \html_writer::end_div();