Skip to content

Commit

Permalink
fix: songs doesn't play when sources with preferred audio codec is em…
Browse files Browse the repository at this point in the history
…pty (#976)

* Fix song not playing when m4a or weba is not available (one is available but not the other) for that song

* Update lib/services/sourced_track/sources/youtube.dart

---------

Co-authored-by: Kingkor Roy Tirtho <[email protected]>
  • Loading branch information
franchioping and KRTirtho authored Jan 2, 2024
1 parent 02e44fc commit ba4e11a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/services/sourced_track/sources/youtube.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,17 @@ class YoutubeSourcedTrack extends SourcedTrack {
}

static SourceMap toSourceMap(StreamManifest manifest) {
final m4a = manifest.audioOnly
var m4a = manifest.audioOnly
.where((audio) => audio.codec.mimeType == "audio/mp4")
.sortByBitrate();

final weba = manifest.audioOnly
var weba = manifest.audioOnly
.where((audio) => audio.codec.mimeType == "audio/webm")
.sortByBitrate();

m4a = m4a.isEmpty ? weba.toList() : m4a;
weba = weba.isEmpty ? m4a.toList() : weba;

return SourceMap(
m4a: SourceQualityMap(
high: m4a.first.url.toString(),
Expand Down

0 comments on commit ba4e11a

Please sign in to comment.