Don't create a UI if the app already has one.

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
This commit is contained in:
Sandra Lokshina
2019-08-01 14:45:25 -07:00
parent b4ddbd2131
commit a7716632d2
+10
View File
@@ -236,6 +236,11 @@ shaka.ui.Overlay = class {
} else if (videos.length && !containers.length) {
// Just the video elements were provided.
for (const video of videos) {
// 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!');
@@ -264,6 +269,11 @@ shaka.ui.Overlay = class {
}
} else {
for (const container of containers) {
// 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!');