-
-
Notifications
You must be signed in to change notification settings - Fork 12
feat(video): create Video component #72
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
Conversation
Shiti
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we should split the controls file into 3 - mediaIcons component, common(controls common to audio and video) and videocontrols. what do you think ?
| | 'pictureInPicture' | ||
| | 'pictureInPictureExit' | ||
| | 'fullscreen' | ||
| | 'fullscreenExit' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to add the captions ones here too
| | 'fullscreen' | ||
| | 'fullscreenExit' | ||
| className?: string | ||
| color?: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to pass the color as prop? can we not set it to 'primary' always ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The colours change based on the component as well as the viewport, so I was trying to think of a way to control this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the colors should not change by viewport. Please set this to primary
Shiti
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the commit message to clearly indicate what is being changed. Also, for tests, I would recommend using a local video file as that would help speed things up
|
Could you hide the control bar when the mouse has not moved for a few seconds? |
| transcript?: string | ||
| } | ||
|
|
||
| export interface AudioFormat extends MediaFormat {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Is it necessary to add AudioFormat when it's exactly same as MediaFormat? Do we want to introduce a new type just for the semantic reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semantics for clarity but I'm also thinking in the future there could possibly be audio-only fields.
@Shiti This would make it easier to maintain. Will still have to think about how the controls in the settings menu will work. |
| const Icon = props.isTranscriptShown | ||
| ? KeyboardArrowUpIcon | ||
| : KeyboardArrowDownIcon | ||
| export function CaptionsToggle(props: Toggle) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export function CaptionsToggle(props: Toggle) { | |
| export function ToggleCaptionsButton(props: Toggle) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think we need to create a component for these 2 lines. Its not adding any value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured since we're using it in both the Sound and Video components for now until the Video settings menu design flow was finalized, since it seems like playback rate, captions, etc will later be handled there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still, in other cases, where you have defined a component for button, there is additional logic, whereas here there is none.
| const Icon = props.isTranscriptShown | ||
| ? KeyboardArrowUpIcon | ||
| : KeyboardArrowDownIcon | ||
| export function CaptionsToggle(props: Toggle) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think we need to create a component for these 2 lines. Its not adding any value
b1897f5 to
bb98c0f
Compare
|
Hi! I found a bug in the mobile version. Here are the steps to reproduce it:
|
|
Should the |
@lyjeileen Addressed. Initially spoke with @RenataDzotova about making this immediately go to fullscreen on mobile since it's not obvious you have to go to fullscreen for the controls. Maybe we can address this in the future, so I've updated to be back to the original design. Clicking play now simply plays the video without going fullscreen and added back the fullscreen button. |
|
@kaseyvee when transcript is shown in full screen mode, the other controls are not visible even on hover. We have to hide transcript for any other controls to be visible. |
|
When showing picture-in-picture, I think it should show the poster /first frame at the original location. |
| ) | ||
| } | ||
|
|
||
| function renderCaptionsToggle() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| function renderCaptionsToggle() { | |
| function renderCaptionsButton() { |
|
|
||
| export function PausePlayToggle(props: MediaControls) { | ||
| const [isPlaying, setIsPlaying] = useState(false) | ||
| export function PlayOrPauseToggle(props: MediaControls) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export function PlayOrPauseToggle(props: MediaControls) { | |
| export function PlayOrPauseButton(props: MediaControls) { |
| element: HTMLElement | ||
| } | ||
|
|
||
| export function PictureInPictureToggle(props: MediaControls) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export function PictureInPictureToggle(props: MediaControls) { | |
| export function PictureInPictureButton(props: MediaControls) { |
| function handlePictureInPicture() { | ||
| if (isPictureInPicture) { | ||
| document.exitPictureInPicture() | ||
| } else { | ||
| videoElement.requestPictureInPicture() | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both document.exitPictureInPicture() and videoElement.requestPictureInPicture() return Promise. Use that instead of adding event handlers below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left the onleavepictureinpicture handler for when users exit from the pip window.
| document.exitFullscreen() | ||
| } else { | ||
| props.element.requestFullscreen() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update this to handle the returned Promise.
@Shiti Not quite sure how the designs are meant to handle showing the transcript on fullscreen with the controls. I could make them appear like this with a max height of 25% viewport height: @Laurendragonscale @RenataDzotova @lyjeileen What do you guys think? |
|
on desktop, the transcript comes below the controls so I would assume that the same happens on mobile as well. |
| props.mediaElement.play() | ||
| setIsPlaying(true) | ||
| props.mediaElement.play().catch(() => { | ||
| props.onError('Failed to play the media. Please try again.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are catching the exception but not capturing any information regarding it.
Possible errors include:
- NotAllowedError DOMException
Provided if the user agent (browser) or operating system doesn't allow playback of media in the current context or situation. The browser may require the user to explicitly start media playback by clicking a "play" button, for example because of a Permissions Policy.- NotSupportedError DOMException
Provided if the media source (which may be specified as a MediaStream, MediaSource, Blob, or File, for example) doesn't represent a supported media format.
In these scenarios, trying again will be of no use. The appropriate message should be indicated clearly so user understands what the issue is and why the media cannot be played.
Reference - https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play
Co-authored-by: Shiti Saxena <[email protected]> Signed-off-by: kasey <[email protected]>


Changes
Screenshots/Videos
Designs
Desktop
Mobile
Storybook
Light mode
Default

With captions

With poster

Error

Mobile

Dark mode
Default

Mobile

Videos
Desktop Fullscreen
https://github.com/rustic-ai/ui-components/assets/111031789/e0ad61a1-f119-4c3e-adb9-068c3fe5f0f7
Desktop Picture-in-picture
https://github.com/rustic-ai/ui-components/assets/111031789/2f22fe6d-90b7-4c4e-b7e4-a2109d7f5c26
Mobile Fullscreen
https://github.com/rustic-ai/ui-components/assets/111031789/36a9f7fd-4652-4d72-be52-a6e4e32f56b8