vujable / react-mediainfo

React wrapper for mediainfo.js
7 stars 5 forks source link

Worker is not defined #2

Open JKamsker opened 2 years ago

JKamsker commented 2 years ago

Trying to get it running in https://github.com/devias-io/material-kit-react

It always spits out error - ReferenceError: Worker is not defined when referencing this lib

leozitor commented 1 year ago

Trying to get it running in https://github.com/devias-io/material-kit-react

It always spits out error - ReferenceError: Worker is not defined when referencing this lib

I was struggling with the problem as you, I am developing using next.js and that problem was showing up, finally I could discover a way to solve that. Instead of importing on top of the file and using the getInfo, what i did now is using require inside the function I use to call the getInfo, then this problem does not happen! I hope i helped you.


...
export default function ReactComponent() {
    const [files, setFiles] = useState([])

    const func =  async (file) => {
            const  MediaInfo = require('react-mediainfo')
            const result = await MediaInfo.getInfo(file)
    ....
    }

    return (
    ...
    )