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

[chromecast] seems to registerElement multiple times #56

Closed
jimmywarting opened this issue May 26, 2017 · 23 comments
Closed

[chromecast] seems to registerElement multiple times #56

jimmywarting opened this issue May 26, 2017 · 23 comments

Comments

@jimmywarting
Copy link
Contributor

I got a single page website, so when I create a new player i get this error:

Uncaught DOMException: Failed to execute 'registerElement' on 'Document': Registration failed for type 'google-cast-button'. A type with that name is already registered.

@jimmywarting jimmywarting changed the title seems to registerElement multiple times [chromecast] seems to registerElement multiple times May 26, 2017
@rafa8626
Copy link
Contributor

Can you send me a URL to check this please?

@jimmywarting
Copy link
Contributor Author

jimmywarting commented May 26, 2017

@rafa8626 rafa8626 added the Bug label May 28, 2017
@rafa8626
Copy link
Contributor

rafa8626 commented Jun 1, 2017

It can only be one sender per page; I implemented something that might help you:
https://jsfiddle.net/Luuwnjfm/6/

Let me know your thoughts; otherwise, you might need to reach Chromecast directly, since I couldn't find any documentation about this, other than the fact there should be only one instance of the player per page

@rafa8626 rafa8626 added Completed and removed Bug labels Jun 1, 2017
@jimmywarting
Copy link
Contributor Author

Can use that

But I Think this will be a recurring issue among others so I think it would be best if built in to the plugin

@rafa8626
Copy link
Contributor

rafa8626 commented Jun 1, 2017

Please download the master branch; I was able to put a restriction so only one sender per page is now allow and you can use https://jsfiddle.net/Luuwnjfm/1/ without any hacks. Let me know

@jimmywarting
Copy link
Contributor Author

Works

@rafa8626
Copy link
Contributor

rafa8626 commented Jun 2, 2017

I'm glad it worked for you

@jimmywarting
Copy link
Contributor Author

Hmm, didn't work where we'll

The Chromecast don't appear after I set a video source. And the check for the button makes it never appear cuz it's always true?

@jimmywarting jimmywarting reopened this Jun 2, 2017
@rafa8626
Copy link
Contributor

rafa8626 commented Jun 2, 2017

I'll check this on your scenario; do you have a fiddle that I can use for testing scenario?

@jimmywarting
Copy link
Contributor Author

jimmywarting commented Jun 2, 2017

If you get this fiddle to work without modification then i think you have solved both my Chromecast bugs

  • The video source should be possible to set after you have initiated a MediaElementPlayer and you got yourself a visible ChromeCast icon
  • The google-cast-button shouldn't throw an error when initiating a new MediaElementPlayer on the same page more then once

(as you can see console.log(document.createElement('google-cast-button').constructor === HTMLElement) prints true, which makes the script to bail out early

@rafa8626
Copy link
Contributor

rafa8626 commented Jun 5, 2017

@jimmywarting Can you try this Fiddle and check if that solves your issues? https://jsfiddle.net/Luuwnjfm/8/

@rafa8626
Copy link
Contributor

rafa8626 commented Jun 9, 2017

Any updates on this?

@jimmywarting
Copy link
Contributor Author

The chromecast isn't available after I set a source

@rafa8626
Copy link
Contributor

Hmmm I'll take a look at this again. It was working for me before

@jimmywarting
Copy link
Contributor Author

maybe that isn't the problem. document.createElement('x-y').constructor === HTMLElement is always equal to true

(as you can see console.log(document.createElement('google-cast-button').constructor === HTMLElement) prints true, which makes the script to bail out early

which makes this code return early without building the cast button

@rafa8626
Copy link
Contributor

Hmmmm yeah I need to research how to check if the button has been truly registered, because I thought that would be enough. I'll keep you posted

@rafa8626
Copy link
Contributor

@jimmywarting OK I think I finally got it; I added a new Fiddle so you can see the end result. Dealing with Chromecast is a little complicated so I'll be thinking in a better way to do this but for now you should get everything fine: https://jsfiddle.net/Luuwnjfm/13/. Let me know

@rafa8626
Copy link
Contributor

rafa8626 commented Jun 14, 2017

@jimmywarting I have refactor MediaElement to integrate Chromecast inside the player and not as a plugin. If you can help me testing this, please test this Fiddle so it can be part of the next release: https://jsfiddle.net/Luuwnjfm/18/

@rafa8626
Copy link
Contributor

FYI i have completed more work to enable errors properly on the player UI but that should affect your testing. Keep me posted since I'm planning to release this week

@rafa8626
Copy link
Contributor

rafa8626 commented Jun 16, 2017

@jimmywarting I have 2 new branches (one for the player and one for the plugins) named the same: mejs-new. Please test Chromecast using them by enabling the chromecast feature inside your player's configuration:

features: ['playpause', 'current', 'progress', 'duration', 'speed',  'volume', 'chromecast']

**You will need to include chromecast.min.js ** after the MediaElement library, and also the chromecast.min.css stylesheet:
These new branches had addressed many issues in terms of integrating properly Chromecast and achieved the dual-nature of Chromecast and MediaElement, and had integrated all the fixes that will go for the next release. Please let me know your findings. Thanks again for testing this.

@ManoAbraham
Copy link

@rafa8626 Thanks for your work. Testing your new code. I'm getting following tag for chromecast button <button type="button" is="google-cast-button" aria-controls="mep_0" title="Chromecast" aria-label="Chromecast" tabindex="0" style="display: none;"></button>
style="display: none;" cause cast button to disappear. once it's removed rest works fine.
image

@rafa8626
Copy link
Contributor

rafa8626 commented Jun 20, 2017

The display: none remains there to make sure the Cast is found or not. It shouldn't be hidden once Cast is detected. Is that your scenario? I merged the mejs-new branch into master.

@rafa8626
Copy link
Contributor

Closing this issue since all issues related to Chromecast have been discussed and addressed on mediaelement/mediaelement#2273

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants