Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!