Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
alsar opened this issue May 17, 2017 · 42 comments · Fixed by #170
Closed

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

alsar opened this issue May 17, 2017 · 42 comments · Fixed by #170
Labels
Milestone

Comments

@alsar
Copy link
Collaborator

alsar commented May 17, 2017

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

@thijstriemstra
Copy link
Member

thijstriemstra commented May 23, 2017

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
Copy link
Member

thijstriemstra commented Jun 16, 2017

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

@thijstriemstra
Copy link
Member

thijstriemstra commented Jun 17, 2017

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

@alsar
Copy link
Collaborator Author

alsar commented Jun 17, 2017

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

@alsar
Copy link
Collaborator Author

alsar commented Jun 17, 2017

With 6.1.0 it works now in both Firefox and Chrome.

@thijstriemstra
Copy link
Member

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

@alsar
Copy link
Collaborator Author

alsar commented Jun 17, 2017

Yes, is looks that way.

@thijstriemstra
Copy link
Member

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

@alsar
Copy link
Collaborator Author

alsar commented Jun 18, 2017

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.

@perminder-klair
Copy link

perminder-klair commented Jun 18, 2017

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",

@thijstriemstra
Copy link
Member

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

@thijstriemstra
Copy link
Member

This fix in a different plugin could be related: videojs/videojs-youtube@ad7275c#diff-41489607c076711cf7440b328fb7a065R37.

@thijstriemstra
Copy link
Member

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

@alsar
Copy link
Collaborator Author

alsar commented Jun 30, 2017

@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:
videojs/video.js#2698 (comment)
https://medium.com/@kentcdodds/misunderstanding-es6-modules-upgrading-babel-tears-and-a-solution-ad2d5ab93ce0

@thijstriemstra
Copy link
Member

thijstriemstra commented Jul 3, 2017

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
Copy link
Member

thijstriemstra commented Jul 3, 2017

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

@thijstriemstra thijstriemstra changed the title Play button doesn't work with video.js 6.0 Play button doesn't work with video.js 6.2.0 Jul 3, 2017
@thijstriemstra thijstriemstra changed the title Play button doesn't work with video.js 6.2.0 Play button doesn't work with video.js 6.2.0 and webpack Jul 3, 2017
@gkatsev
Copy link

gkatsev commented Jul 3, 2017

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
Copy link

gkatsev commented Jul 4, 2017

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.

@thijstriemstra
Copy link
Member

thijstriemstra commented Jul 4, 2017

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
Copy link
Member

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

@gkatsev
Copy link

gkatsev commented Jul 4, 2017

Actually, I think it's exactly module field issue. Just remembered I had to do: https://github.com/videojs/videojs-bundler-sample/blob/master/src-es5/webpack.config.js#L9-L11
We probably should document that in the webpack guide.

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, can you elaborate?

What I meant is that in videojs-bundler-sample, we require video.js directly in that project and we don't have a dependency also require video.js.

It sounds to me like if any module isn't using ESM, things could cause an issue. :(

@thijstriemstra
Copy link
Member

It sounds to me like if any module isn't using ESM, things could cause an issue. :(

wtf is ESM. sorry.

@gkatsev
Copy link

gkatsev commented Jul 4, 2017

it's ok. ESM is short for ES modules or Ecmascript modules. That is the import and export syntax. CJS is commonjs, i.e., what nodejs uses and what bundlers used to use.

@alsar
Copy link
Collaborator Author

alsar commented Jul 4, 2017

I'm using Webpack 3 now. Had the same problem with version 2.

Webpack with ES6 by default uses video.es.js.
I solved the problem temporarily by aliasing video.js with node_modules/video.js/dist/video.js which doesn't use the ES6 syntax. But that is not really a proper fix.

@thijstriemstra
Copy link
Member

thijstriemstra commented Jul 8, 2017

I will:

@thijstriemstra
Copy link
Member

I'm using Webpack 3 now. Had the same problem with version 2.

video.js will be using webpack 3.1.0 soon it looks like (when this travis build succeeds I suppose): videojs/video.js#4470

@thijstriemstra
Copy link
Member

I opened videojs/video.js#4580 cc @gkatsev

@thijstriemstra
Copy link
Member

They committed a fix at videojs/video.js@5e23048. You can give that a try @alsar or wait till they release it.

@alsar
Copy link
Collaborator Author

alsar commented Sep 4, 2017

I tested it quickly with the newsest video.js release that ships with the fix.

    "video.js": "6.2.8",
    "videojs-record": "1.7.0",

but I get an error with webpack Error: plugin "record" does not exist (also with other plugins). I currently don't have the time to debug it in the next days, but it's definitely a ES6 issue and also maybe isn't related to the fix. Because I don't get any error with video.js/dist/video.js.

@thijstriemstra
Copy link
Member

@gkatsev any idea?

@thijstriemstra
Copy link
Member

@perminder-klair can you give it a try with 6.2.8 or newer?

@gavfu
Copy link

gavfu commented Sep 18, 2017

I got the same "Error: plugin 'record' does not exist" with video.js 6.2.8 and videojs-record 1.7.0.

I tried to low versions of video.js and videojs-record, but still get the same error. Do you guys know any workaround to make it workable for now? Thanks.

@thijstriemstra
Copy link
Member

@gavfu you tried video.js 6.1.0?

@gavfu
Copy link

gavfu commented Sep 18, 2017

@thijstriemstra �yes,I'm trying to use it in an electron app, with webpack 2.2.1。
I even tried video.js 5.19.0 with following configurations in package.json, but still got the error.

"video.js": "5.19.0",
"videojs-record": "1.6.0"

@thijstriemstra
Copy link
Member

@gavfu have you tried an older version of webpack, e.g. 1.x.x? I'm currently refactoring the plugins to ES6 and webpack build so this should get fixed eventually.

@gavfu
Copy link

gavfu commented Sep 18, 2017

@thijstriemstra Not yet, webpack 1.x is deprecated so I'd rather not to downgrade to it. May I know roughly when will the new version plugin be released? Meanwhile, if there are any workable combinations of video.js + videojs-record found, I'm willing to try that...

@thijstriemstra
Copy link
Member

Without webpack it works fine so your only option is to downgrade for now I think.

@gavfu
Copy link

gavfu commented Sep 18, 2017

I'll try and see, thanks thijstriemstra. :)

@alsar
Copy link
Collaborator Author

alsar commented Sep 18, 2017

@gavfu You can alias video.js to use the non-ES6 version.

Use something like this in your webpack config:

  resolve: {
    alias: {
      'video.js': path.resolve(__dirname, '../../node_modules/video.js/dist/video.js')
    }
  }

This is a quick workaround until this issue is resolved.

@thijstriemstra
Copy link
Member

thijstriemstra commented Sep 19, 2017

Also see #167 for v2.0 (with better build system/ES6 etc) that will also resolve this ticket.

@thijstriemstra thijstriemstra added this to the 2.0.0 milestone Oct 3, 2017
thijstriemstra added a commit that referenced this issue Oct 3, 2017
- (videojs-)wavesurfer >= 2.0 (only) support
- video.js >= 6.0 (only) support
- new build system (using babel/browserify, with tests for webpack, fixes #149)
- modules/es6 (fixes #167)
- advanced video.js plugin
- support for the video.js fluid option (fixes #166)
- React example (fixes #171)
- replace usage of  URL.createObjectURL(stream) (fixes #169)
@thijstriemstra
Copy link
Member

thijstriemstra commented Oct 3, 2017

@alsar @gavfu @perminder-klair 2.0.0 PR was merged to master branch (containing a fix for this ticket), any help testing before I release 2.0.0 would be appreciated!

@12smc120
Copy link

12smc120 commented Sep 4, 2018

@thijstriemstra
I'm getting an error
Error: plugin "record" does not exist

Please tell me some solution for this.

@collab-project collab-project locked as resolved and limited conversation to collaborators Sep 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants