videojs / videojs-overlay

A video.js plugin to display simple overlays during playback.
Other
245 stars 92 forks source link

Plugin is not importable #83

Open qubis741 opened 6 years ago

qubis741 commented 6 years ago

Description

I am trying to use your plugin, via import statements. Problem is, that I can't get it working. I am getting error

Steps to reproduce

I have imported videojs and overlay plugin and try to register it, because when I didn't, I got error about function overlay to be undefined. Then I got error mentioned below

import videojs from 'video.js' import overlay from 'videojs-overlay' .... videojs.registerPlugin('overlay', overlay) // error .... player.overlay({...})

Results

Expected

Expected to be working

Actual

Got error

Error output

VIDEOJS: ERROR: Error: Component Overlay does not exist at Player.addChild (video.cjs.js:3361) at videojs-overlay.es.js:371 at Array.map () at Player.plugin (videojs-overlay.es.js:347) at Player.basicPluginWrapper [as overlay] (video.cjs.js:23094) at videoTracking (application.js:130) at Player. (application.js:92) at HTMLDivElement.bound (video.cjs.js:2070) at HTMLDivElement.data.dispatcher (video.cjs.js:1717) at trigger (video.cjs.js:1849)

Additional Information

Please include any additional information necessary here. Including the following:

versions

videojs

"video.js": "^7.0.3", "videojs-overlay": "^2.1.4"

browsers

Version 69.0.3497.100 (Official Build) (64-bit)

OSes

macOS High Sierra 10.13.6

plugins

"@dlive/videojs-resolution-switcher": "^0.6.0"

If I am doing something wrong, please help me and include it also in docs, because I haven't found any documentation about how to use your plugin with imports. Thanks

qubis741 commented 6 years ago

There was problem with imports inside plugin. Overlay imported other videojs than I did in app.js, even if "name" is the same. Quick fix is to copy videojs-overlay.es.js to your lib and import it like: import '../lib/videojs-overlay'

You don't need to register plugin then. Hope developers could find solution without this kinda forking

ndevvy commented 6 years ago

if you import the plugin you don't need to call registerPlugin; the registration will happen when the module is imported. you should be able to just call player.overlay after importing.

amirmasoud commented 5 months ago

You can copy the file as @qubis741 said, I just impoorted it like this:

import "videojs-overlay/dist/videojs-overlay.es.js";

(context: I'm using VideoJS inside of a Vue component)