Skip to content

Commit

Permalink
Don't create a UI if the app already has one.
Browse files Browse the repository at this point in the history
If an app uses the shaka.ui.Overlay constructor to create
a UI before our auto-detection code runs, they end up with
two UIs one on top of the other.

I personally think anyone should be grateful to get an
extra UI or two, but people complain for some reason.

Closes #2073.

Change-Id: I793b5a7d8b5092a9b65426f5994019fde75bf957
  • Loading branch information
ismena authored and TheModMaker committed Aug 22, 2019
1 parent c41d0cc commit 9daa0f6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ui/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ shaka.ui.Overlay.scanPageForShakaElements_ = function() {
// Just the video elements were provided.
for (let i = 0; i < videos.length; i++) {
const video = videos[i];
// If the app has already manually created a UI for this element,
// don't create another one.
if (video['ui']) {
continue;
}
goog.asserts.assert(video.tagName.toLowerCase() == 'video',
'Should be a video element!');

Expand Down Expand Up @@ -264,6 +269,11 @@ shaka.ui.Overlay.scanPageForShakaElements_ = function() {
} else {
for (let i = 0; i < containers.length; i++) {
const container = containers[i];
// If the app has already manually created a UI for this element,
// don't create another one.
if (container['ui']) {
continue;
}
goog.asserts.assert(container.tagName.toLowerCase() == 'div',
'Container should be a div!');

Expand Down

0 comments on commit 9daa0f6

Please sign in to comment.