silvermine / videojs-chromecast

MIT License
148 stars 75 forks source link

"google-cast-button" has already been used with this registry #162

Open ToshY opened 1 year ago

ToshY commented 1 year ago

Problem

The console shows the following error:

Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': the name "google-cast-button" has already been used with this registry
    at https://www.gstatic.com/cast/sdk/libs/sender/1.0/cast_framework.js:64:39
    at https://www.gstatic.com/cast/sdk/libs/sender/1.0/cast_framework.js:69:234

With that said, the chromecast functionality itself still seems to work.

Reproduction

Example (pseudo) code

watch.js

import videojs from 'video.js';
require('@silvermine/videojs-chromecast')(videojs, {preloadWebComponents: true});

import $ from 'jquery';

# ...

playerOptions = {
    controls: true,
    techOrder: ['chromecast', 'html5'],
    html5: {
        hls: {
            overrideNative: true
        }
    },
    plugins: {
        chromecast: {},
    }
};

let player = videojs('#myPlayer', playerOptions);

Minimal view file with cast_sender.js after watch.js.

watch.html.twig

<head>
    <script src="watch.js"></script>
    <script src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>
</head>

image

Versions

"video.js": "^8.3.0",
"@silvermine/videojs-chromecast": "^1.4.1",

I've read the Initialization Options section, but trying to put JQuery before/after, or turning preloadWebComponents on/off does not seem to resolve the issue.