videojs-record icon indicating copy to clipboard operation
videojs-record copied to clipboard

Play button doesn't work with video.js 6.2.0 and webpack

Open alsar opened this issue 9 years ago • 42 comments

Description

Playing the recorded video doesn't work with video.js ~~6.0.0~~ ~6.2.0 When you record a video and then press the play button noting happens.

Steps to reproduce

Install video.js ~6.2.0

Results

Expected

Should play the video.

Error output

Uncaught TypeError: videojs.getComponent is not a function

Additional Information

versions

videojs

what version of videojs does this occur with? video.js 6.2.0 videojs-record 1.6.1

browsers

what browser are affected? Tested in Firefox and Chrome

OSes

what platforms (operating systems and devices) are affected? Linux

alsar avatar May 17 '17 11:05 alsar

Confirmed it's an issue (tested with videojs 6.1.0). Also looks like CSS is screwed:

screen shot 2017-05-27 at 03 53 10

thijstriemstra avatar May 23 '17 16:05 thijstriemstra

It works in Firefox (53) now but not in Chrome (60), closed this too soon (only worked around css issues).

thijstriemstra avatar Jun 16 '17 23:06 thijstriemstra

@alsar can you confirm it's working now with the latest master and video.js 6.2.0 or newer?

thijstriemstra avatar Jun 17 '17 01:06 thijstriemstra

@thijstriemstra With 6.2.0 i get an Uncaught TypeError: videojs.getComponent is not a functionerror.

alsar avatar Jun 17 '17 06:06 alsar

With 6.1.0 it works now in both Firefox and Chrome.

alsar avatar Jun 17 '17 06:06 alsar

@alsar really, it works with 6.1.0 but not with 6.2.0?

thijstriemstra avatar Jun 17 '17 12:06 thijstriemstra

Yes, is looks that way.

alsar avatar Jun 17 '17 14:06 alsar

what os/version of firefox/chrome? I can't reproduce that..

thijstriemstra avatar Jun 17 '17 20:06 thijstriemstra

Linux with Firefox 54 and Chromium 58. Maybe it's an Webpack problem. I'll investigate in the next days and get back to you.

alsar avatar Jun 18 '17 08:06 alsar

Getting same issue with

    "video.js": "^6.1.0",
    "videojs-record": "^1.6.2"

TypeError: videojs.getComponent is not a function

Just tested, it works if I use video.js like: "video.js": "6.1.0",

perminder-klair avatar Jun 18 '17 11:06 perminder-klair

What line does this error occur on? Can someone post a screenshot or stacktrace? (with unminified versions)

thijstriemstra avatar Jun 18 '17 18:06 thijstriemstra

This fix in a different plugin could be related: https://github.com/videojs/videojs-youtube/commit/ad7275caf4b9d102354fbceda86ab9f20e216ee8#diff-41489607c076711cf7440b328fb7a065R37.

thijstriemstra avatar Jun 18 '17 18:06 thijstriemstra

Also tested on OSX with Chrome 60.0.3112.40, still cannot reproduce.

thijstriemstra avatar Jun 25 '17 16:06 thijstriemstra

@thijstriemstra I could get down to the root of the problem. The problem is the combination of ES6 exports export default videojs and requirejs imports require('video.js)

video.js switched from module.exports = videojs in 6.1.0 to export default videojs in 6.2.0 And while videojs-record still uses require('video.js) and if you use ES6 stops working.

https://github.com/videojs/video.js/blob/v6.1.0/src/js/video.js#L727 https://github.com/videojs/video.js/blob/v6.2.0/src/js/video.js#L726

So the fix to this is as I understand it to switch to ES6 imports or to change the require to require('video.js).default

But I'm not really an expert regarding this subject.

Explanations of this problem: https://github.com/videojs/video.js/issues/2698#issuecomment-148151327 https://medium.com/@kentcdodds/misunderstanding-es6-modules-upgrading-babel-tears-and-a-solution-ad2d5ab93ce0

alsar avatar Jun 30 '17 12:06 alsar

Thanks for the research @alsar! There's also a webpack guide now but that doesn't mention anything related: https://github.com/videojs/video.js/blob/master/docs/guides/webpack.md

Hmm, @gkatsev should we use require('video.js).default as suggested in order to support both versions of video.js?

thijstriemstra avatar Jul 03 '17 11:07 thijstriemstra

@alsar I assume you (will) have the same issue with https://github.com/collab-project/videojs-wavesurfer when recording audio-only?

thijstriemstra avatar Jul 03 '17 22:07 thijstriemstra

Hm... when making the changes in 6.2.0 I tested to make sure that it works without requiring es6: https://github.com/videojs/videojs-bundler-sample Maybe the issue is that this is a separate project that requires videojs and not an end-user which is what the bundler-sample project is?

gkatsev avatar Jul 03 '17 23:07 gkatsev

Though, thinking about it some more, what version of webpack is used? We're outputting both CJS and ESM outputs and specify a main and a module property in the config. If webpack 2 is used, it probably tries to load the ESM module and things break.

gkatsev avatar Jul 04 '17 00:07 gkatsev

Maybe the issue is that this is a separate project that requires videojs and not an end-user which is what the bundler-sample project is?

This sounds confusing to me, can you elaborate?

If webpack 2 is used, it probably tries to load the ESM module and things break.

@alsar what version are you using?

thijstriemstra avatar Jul 04 '17 00:07 thijstriemstra

A new release of this plugin (in short term) would pin video.js to anything < 6.2.0.

thijstriemstra avatar Jul 04 '17 00:07 thijstriemstra