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

190
Visualizações
Using requirejs instance outside of definition?

I am using requirejs to determine dependencies. I have some code that determines the use of the Video.js:

require.config({
  'paths': {
    'bc': 'https://players.brightcove.net/1507807800001/default_default/index.min'
  },
  waitSeconds: 30
});
require(['bc'], function() {
  var myPlayer = videojs.getPlayers().myPlayerID;
  myPlayer.on('loadstart', function(){
    myPlayer.play();
  })
});

Also I have some code that wants to get an instance and use that Video.js:

if (typeof myPlayer != "undefined") {
  console.log("myPlayer existence true");
  myPlayer.stop();
} else {
  console.log("myPlayer existence false");
}

Is there a way to access outside of the Video.js's definition? This is a working example https://playcode.io/868784/

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can define your module and later use it:

require.config({
  'paths': {
    'bc': 'https://players.brightcove.net/1507807800001/default_default/index.min'
  },
  waitSeconds: 30
});
define('myPlayer', ['bc'], function() {
  var myPlayer = videojs.getPlayers().myPlayerID;
  myPlayer.on('loadstart', function(){
    myPlayer.play();
  })

  return myPlayer;
});

Video.js:

require(['myPlayer'], function (myPlayer) {
  myPlayer.stop();
});
about 4 years ago · Juan Pablo Isaza Relatório
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