contently / videojs-annotation-comments

A plugin for video.js to add support for timeline moment/range comments and annotations
https://contently.github.io/videojs-annotation-comments/
Other
171 stars 50 forks source link

How can I use videojs-annotation-comments in React? #52

Closed alexkruts2 closed 4 years ago

alexkruts2 commented 4 years ago

Hello sir. I am a new developer in react and video.js. I am going to use videojs-annotation-comments plugin in Reactjs. when I import videojs-annotation-comments plugin, I can get such error . >>Error: Cannot find module './videojs-annotation_comments' from '..\plugins\editor.video\res\build\ warning: Error running grunt-browserify. Use --force to continue I have downloaded videojs-annotation-comments file. but there is no components videojs-annotation-comments for using react.js. how can I fix this issue?

jackpope commented 4 years ago

Hi @alexkruts2

It seems you have two separate issues: importing the library and using it within React.

For your imports, are you using npm/yarn to manage the dependency or are you copying the file from Github directly into your code base? If the latter, you should make sure you are copying the CJS version to use it as a module. Most module builders will do this automatically as it is set in the main property of the packaqe.json.

As for using within a React component, I have not tried this yet myself but you should be able to follow the guide for using Videojs within React. https://github.com/videojs/video.js/blob/master/docs/guides/react.md You will have to additionally set up the plugin within componentDidMount and dispose it within componentWillUnmount - or both within a useEffect if you are using hooks based components.

alexkruts2 commented 4 years ago

Hello sir. Thank you for reply. so How can I get the CJS version?

jackpope commented 4 years ago

I recommend using npm or yarn to install the package. yarn add @contently/videojs-annotation-comments

You could also grab it from the build dir of this repo but in the coming version 2 it will no longer be tracked in version control.

jackpope commented 4 years ago

@alexkruts2 I'm going to close this but feel free to open another issue for any other problems you may run into.