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

feat: Videojs POC #2974

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

feat: Videojs POC #2974

wants to merge 5 commits into from

Conversation

smithgajjar09
Copy link
Contributor

@smithgajjar09 smithgajjar09 commented Nov 13, 2024

Overview

Early draft of Videojs Integration.
Documentation

Notes

  • Currently videojs does not support module css and also importing .css file results into build errors. Right now we have just copied entire videojs's styles from lib directly into our Global, we could also import css as - !style-loader!css-loader!video.js/dist/video-js.css to force style-loader and get rid of base videojs styles from gamut
  • @type/videojs does not work for version 8 of videojs. v8+ comes with its own types but lacks a lot of types for options and players, which we would need to define separately.
  • Building custom components has some limitations, since they are being rendered using ReactDOM.render it is not part of the primary dom tree the context gets lost for themes and colormodes so GamutProvider needs to be defined again.

Copy link

nx-cloud bot commented Nov 13, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 39ffa92. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 3 targets

Sent with 💌 from NxCloud.

@smithgajjar09 smithgajjar09 changed the title Videojs POC feat: Videojs POC Nov 13, 2024
@codecademydev
Copy link
Collaborator

📬Published Alpha Packages:

@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]

@codecademydev
Copy link
Collaborator

🚀 Styleguide deploy preview ready!

https://673f4adc0d52ee00c6ee82c7--gamut-preview.netlify.app

Deploy Logs

const fullscreenToggle = controlBarFullScreen?.el()
fullscreenToggle?.insertAdjacentElement('beforebegin', el)

ReactDOM.render(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were different ways to add custom components but none of them worked when the player is in fullscreen mode (REF), since the component needs to be within videojs tree. This approach solves that but has an limitation - gamut theme would not apply to ControlSettings component since it is being rendered from a separate dom tree than our primary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this brings me pause because it breaks ColorMode context. we could do this inline or maybe create.a wrapper around the render to pass the current mode context?

const [show, setShow] = useState(false);
const target = useRef<HTMLButtonElement>(null);
return (
<GamutProvider theme={coreTheme} useCache useGlobals>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to ReactDOM.render as it is not part of the actual dom tree, GamutProvider needs to be defined separately to make it work with different themes and colormodes

@@ -0,0 +1,339 @@
// eslint-disable-next-line gamut/no-css-standalone, import/no-webpack-loader-syntax
import '!style-loader!css-loader!video.js/dist/video-js.css';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to force using style and css loader here, If not we would need to copy the entire css of videojs from video.js/dist/video-js.css

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch


import { css, Global } from '@emotion/react';

const videojsStyle = css`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For customisations/themes custom css are the only way videojs supports right now. Open to suggestions if there's a better way of defining custom styles

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to use percipio's styles? maybe we can loop stacey in to update these

const videoSrc = playerOptions.src;
const videoPoster = playerOptions.poster;
videoSrc && player.src(videoSrc);
videoPoster && player.poster(videoPoster);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of Accessibility fixes will also be needed here by manipulating DOM directly

Comment on lines +8 to +11
interface VideoJSProps {
options: any;
onReady?: (player: any) => void;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@type/videojs does not work for version 8 of videojs. v8+ comes with its own types but lacks a lot of types for options and players, which we would need to define separately

Copy link
Contributor

@dreamwasp dreamwasp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still need to look into some of this CSS stuff here, but i'm wondering because of the added complexity and dependecies here if this should be moved into it's own package outside of Gamut (esp the CSS stuff makes me think this might be best?) @jakemhiller curious about your thoughts here!

i'm also going to look to see if other design systems have video players and take a look around

const fullscreenToggle = controlBarFullScreen?.el()
fullscreenToggle?.insertAdjacentElement('beforebegin', el)

ReactDOM.render(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this brings me pause because it breaks ColorMode context. we could do this inline or maybe create.a wrapper around the render to pass the current mode context?

@@ -0,0 +1,339 @@
// eslint-disable-next-line gamut/no-css-standalone, import/no-webpack-loader-syntax
import '!style-loader!css-loader!video.js/dist/video-js.css';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch

@jakemhiller
Copy link
Member

still need to look into some of this CSS stuff here, but i'm wondering because of the added complexity and dependecies here if this should be moved into it's own package outside of Gamut (esp the CSS stuff makes me think this might be best?) @jakemhiller curious about your thoughts here!

i'm also going to look to see if other design systems have video players and take a look around

Yeah, i think a separate package makes sense. @dreamwasp were you thinking it should still be in this repo? i think it would be fine in the repo, since the dependencies and stuff will be mostly isolated. I haven't taken a really deep look at the code, but it does seem like we have to do a lot to make it work, which isn't great. I haven't been close enough to the project to suggest any alternatives though, if that's even an option.

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

Successfully merging this pull request may close these issues.

4 participants