Skip to content

Commit

Permalink
Fix isAudioOnly race with native HLS
Browse files Browse the repository at this point in the history
With native HLS, we have a better, more accurate, and more timely way
to detect audio-only content.  Use that whenever possible.  This fixes
the audio-only poster and PiP element state with native HLS content.

Issue #997

Change-Id: Iee9f03deae6e56e7cfc140ed12278270eb667a41
  • Loading branch information
joeyparrish committed May 3, 2019
1 parent 62c8762 commit 6ee4579
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2598,6 +2598,14 @@ shaka.Player.prototype.isAudioOnly = function() {
// is audio-only content.
return !variants[0].video;
} else if (this.video_ && this.video_.src) {
// If we have video track info, use that. It will be the least error-prone
// way with native HLS. In contrast, videoHeight might be unset until
// the first frame is loaded. Since isAudioOnly is queried by the UI on
// the 'trackschanged' event, the videoTracks info should be up-to-date.
if (this.video_.videoTracks) {
return this.video_.videoTracks.length == 0;
}

// We cast to the more specific HTMLVideoElement to access videoHeight.
// This might be an audio element, though, in which case videoHeight will
// be undefined at runtime. For audio elements, this will always return
Expand Down

0 comments on commit 6ee4579

Please sign in to comment.