Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

445
Visualizações
video.js and video-youtube.js throwing "Cannot read properties of undefined (reading 'videojs')" when loading page

I'm trying to play a Youtube video using videojs and videojs-youtube. I've installed the latest versions with npm (videojs 7.18.1, videoojs-youtube 2.6.1). I'm loading in this order:

<script type="text/javascript" src="/node_modules/video.js/dist/video.js"></script>
<script type="module" src="/node_modules/videojs-youtube/dist/Youtube.js"></script>

When the page loads, I get the error: "Cannot read properties of undefined (reading 'videojs')" when it hits line 32:

root.Youtube = factory(root.videojs);

If I try to play the video, I get the following errors:

VIDEOJS: ERROR: The "youtube" tech is undefined. Skipped browser support check for that tech.
VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) No compatible source was found for this media.

I'm creating the player in JavaScript with:

videojs(video.id).ready(function () {
myPlayer = this;
myPlayer.width = width;
myPlayer.height = height;
myPlayer.addClass("video-js");
myPlayer.addClass("vjs-default-skin");
myPlayer.autoplay(true);
myPlayer.controls(true);
myPlayer.options_.techOrder[1] = "youtube";
myPlayer.preload("auto");
myPlayer.on("play", moviePlay);
myPlayer.on('ended', movieEnded);
myPlayer.on('failed', movieFailed);
myPlayer.on('seeking', movieSeeking);
});

I'm selecting from a number of videos, so I them with:

myPlayer.src( { type: "video/youtube", src: "https://www.youtube.com/watch?v=HlXexv4Uc1E?1651837154234" } );

Youtube does show up in the techOrder. I wasn't sure how to do that in JavaScript but it seems to be one of two in the array. The page itself is in a frame of a frameset if that makes any difference. I've changed the videojs-youtube JavaScript example into an .asp frameset and used the same type of include files and it works fine. Could I have variable or function names that conflict... something like that?

What have I done wrong and how to I fix the original error which I assume causes the other two errors on play?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda