From e8f27fefd3662bab14f42d0a0d3893f6b8f92bde Mon Sep 17 00:00:00 2001 From: Amin Date: Sun, 25 Oct 2020 18:09:28 +0330 Subject: [PATCH] bug fixes #78 --- src/HLSPlaylist.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/HLSPlaylist.php b/src/HLSPlaylist.php index 7b92442..bb7587d 100644 --- a/src/HLSPlaylist.php +++ b/src/HLSPlaylist.php @@ -107,12 +107,13 @@ private function getAudioBitrate(Representation $rep): int private function getOriginalAudioBitrate(): int { try { - return $this->hls - ->getMedia() - ->getStreams() - ->audios() - ->first() - ->get('bit_rate', static::DEFAULT_AUDIO_BITRATE); + $audios = $this->hls->getMedia()->getStreams()->audios(); + + if (!$audios->count()){ + return static::DEFAULT_AUDIO_BITRATE; + } + + return $audios->first()->get('bit_rate', static::DEFAULT_AUDIO_BITRATE); } catch (ExceptionInterface $e) { return static::DEFAULT_AUDIO_BITRATE; }