matthojo / videojs-Background

Allows for videos to be displayed as a full background to any element.
MIT License
77 stars 41 forks source link

How to import ? #24

Open eduardoarandah opened 5 years ago

eduardoarandah commented 5 years ago

I'm trying to use videojs with yarn, es6 and all the modern tools.

videojs works fine, but videojs-background doesn't

This code gives me error "TypeError: videojs is undefined"

import videojs from "video.js"
import "videojs-background/lib/videojs-Background.js"
export default {
  init() {
    videojs("bg-video").Background(); 
  }, 
};

I read the code and it seems that videojs-Background depends on window.videojs to exist. But in this example, videojs is a local variable.

I tried to apply the variable to window with no success:

import videojs from "video.js";
import "videojs-background/lib/videojs-Background.js";
export default {
  init() {
    window.videojs = videojs;
    window.videojs("bg-video").Background();
  },
};

how to make it work?