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

Example of how to create a custom button in react #16

Open
yshterev opened this issue May 28, 2024 · 2 comments
Open

Example of how to create a custom button in react #16

yshterev opened this issue May 28, 2024 · 2 comments

Comments

@yshterev
Copy link

Hi @MattiasBuelens
We are trying to implement a react version of theoplayer v7 using the npm package.

In older versions UI was created through videojs, like in the guide here.
https://www.theoplayer.com/docs/theoplayer/how-to-guides/ui/how-to-insert-a-button/

This does not seem to work with new player in react when THEOplayer is imported from the npm package.
var Button = THEOplayer.videojs.getComponent("Button");

Can you give a hint how it should be done? I can also make a PR, I think it will be helpful for others.

@MattiasBuelens
Copy link
Contributor

When importing THEOplayer through the npm package, you should be able to use a namespace import:

import * as THEOplayer from "theoplayer";
var Button = THEOplayer.videojs.getComponent("Button");
// ...
Note: usage with TypeScript

We don't ship TypeScript type definitions for the bundled video.js, so if you're using TypeScript you might need to cast to any first:

import * as THEOplayer from "theoplayer";
var Button = (THEOplayer.videojs as any).getComponent("Button");
// ...

That said, if you're looking to build a player UI using React, we would highly recommend you check out our Open Video UI for React. This new UI doesn't use video.js, instead it's built directly out of React components, making it much easier to use in a React app. See the documentation to get started. 😉

@yshterev
Copy link
Author

@MattiasBuelens Thanks for the quick feedback. Very useful 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants