kmoskwiak / videojs-resolution-switcher

Resolution switcher adds the ability to select the video quality in video.js player.
https://kmoskwiak.github.io/videojs-resolution-switcher/
Other
403 stars 243 forks source link

Why do I get an error when I initialize videoJS in a separate js file? #94

Open puneeth8994 opened 7 years ago

puneeth8994 commented 7 years ago

I have created a separate javascript file and I'm trying to call the function from html. 'use strict' var intializeVideoJs = (videoUrl) => { alert("inside function"); console.log("this is the videoUrl"); console.log(videoUrl); videojs('video', { controls: true, muted: false, techOrder: ["youtube"], width: 500, sources: [{ "type": "video/youtube", "src": 'https://www.youtube.com/watch?v=iD_MyDbP_ZE' }], plugins: { videoJsResolutionSwitcher: { default: 'low', dynamicLabel: true } } }, function() { var player = this; window.player = player; player.on('resolutionchange', function() { console.info('Source changed') }) }); }

I get the following errors

  1. VIDEOJS: ERROR: Unable to find plugin: videoJsResolutionSwitcher
  2. video.js:16869 VIDEOJS: ERROR: The "Youtube" tech is undefined. Skipped browser support check for that tech.
  3. VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) No compatible source was found for this video. MediaErrorcode: 4message: "No compatible source was found for this video."proto: Object _logType @ video.js:16869

This works fine when I initialize it directly in the script tag. I also get the same error when I try to run it inside jquery's document.ready function.

I am retrieving my URL from the backend. So, I want the initializations to take place after I have the URL.