Skip to content

Commit

Permalink
Implement isAudioOnly for src=
Browse files Browse the repository at this point in the history
This is a generic implementation that doesn't rely on the audioTracks
and videoTracks members currently only available on Safari.

Issue #997

Change-Id: I849845513efb2ee51205dcdca8568c889f1f7cdb
  • Loading branch information
joeyparrish committed Apr 30, 2019
1 parent 0e65a45 commit 8178e91
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/player.js
Expand Up @@ -2561,8 +2561,14 @@ shaka.Player.prototype.isAudioOnly = function() {
// Therefore if the first variant has no video, that's sufficient to say it
// is audio-only content.
return !variants[0].video;
} else if (this.video_ && this.video_.src) {
// 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
// true.
const video = /** @type {HTMLVideoElement} */(this.video_);
return video.videoHeight == 0;
} else {
// TODO: Safari's native HLS has audioTracks/videoTracks on the element.
return false;
}
};
Expand Down

0 comments on commit 8178e91

Please sign in to comment.