Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually adding UI creates duplicate video and controls elements #2073

Closed
gscragg opened this issue Jul 31, 2019 · 6 comments
Closed

Manually adding UI creates duplicate video and controls elements #2073

gscragg opened this issue Jul 31, 2019 · 6 comments
Assignees
Labels
component: UI The issue involves the Shaka Player UI status: archived Archived and locked; will not be updated status: working as intended The behavior is intended; this is not a bug

Comments

@gscragg
Copy link
Contributor

gscragg commented Jul 31, 2019

If I use the Overlay constructor to add a shaka.ui.Overlay to an existing player instance at page load, then the auto scanning code runs on the already UI-ed player (and container).

Example player

Possible fixes:

  1. Provide a way to stop the auto scanning code from running.
  2. Make the auto scanning code check if the container already has a UI element attached:
if (typeof container['ui'] != 'undefined'){
  break;
}
@theodab theodab added component: UI The issue involves the Shaka Player UI needs triage labels Jul 31, 2019
@ismena ismena added type: bug Something isn't working correctly and removed needs triage labels Aug 1, 2019
@ismena ismena self-assigned this Aug 1, 2019
@shaka-bot shaka-bot added this to the v2.6 milestone Aug 1, 2019
@ismena ismena added status: working as intended The behavior is intended; this is not a bug and removed type: bug Something isn't working correctly labels Aug 1, 2019
@shaka-bot shaka-bot removed this from the v2.6 milestone Aug 1, 2019
@ismena
Copy link
Contributor

ismena commented Aug 1, 2019

Hi, @gscragg, thanks for reporting!
The autoscan code only adds UI to your page if you mark the container and/or video with shaka data attributes: data-shaka-player-container and data-shaka-player.
If we see that, we assume you want auto-setup.

If you're creating the UI object yourself, don't add the data attributes and the auto scan code won't touch it!

Are you creating the object yourself because you have a custom layout?
If that's the case, you can also change the auto-created layout by calling ui.configure(). that might be a bit less work than creating the object yourself.

Does this help? Let me know if you have any questions :)

@gscragg
Copy link
Contributor Author

gscragg commented Aug 1, 2019

Based on the example I posted, I am not using data-shaka-player attributes, but the call to new shaka.ui.Overlay adds one to the container regardless (https://github.com/google/shaka-player/blob/master/ui/ui.js#L48)

Is using the Overlay constructor considered bad form? Is their a better way to programmatically add shaka UI to a player?

@joeyparrish
Copy link
Member

You're right. I remember adding the attributes as part of the autoscan process to facilitate mass cleanup of the DOM in our automated tests.

@joeyparrish
Copy link
Member

@ismena, would it be preferable to use the programmatic setup after the 'shaka-ui-loaded' event fires on document?

@ismena
Copy link
Contributor

ismena commented Aug 1, 2019

Oh! Sorry, the code base changed on me!
I'll fix it :)

You might want to wait until the 'shaka-ui-loaded' event has fired to create your UI object, though. It will ensure that shaka library has fully loaded and all the polyfills have been installed.

@gscragg
Copy link
Contributor Author

gscragg commented Aug 1, 2019

Ok, I can probably do that. Thank you both for your responses.

TheModMaker pushed a commit that referenced this issue Aug 22, 2019
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
@shaka-project shaka-project locked and limited conversation to collaborators Sep 30, 2019
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Apr 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: UI The issue involves the Shaka Player UI status: archived Archived and locked; will not be updated status: working as intended The behavior is intended; this is not a bug
Projects
None yet
Development

No branches or pull requests

5 participants