(video) feature: unified video player interface with YouTube IFrame API integration#2421
Closed
nwizugbesamson wants to merge 3 commits intoIvy-Interactive:mainfrom
Conversation
…ing specific implementation depending on video type
Collaborator
|
@claude review this. Explain me, does this add value when we already have support for Embed where we can plug in youtube URL-s. Maybe the implementation with the shared controls needs to be done to the Embed widget instead for Youtube client and others? |
This comment was marked as off-topic.
This comment was marked as off-topic.
Collaborator
|
@nwizugbesamson My main worry is that video player was meant to display videos hosted by the user, not for embedding (we have separate Embed) I will give this another thought on Monday and discuss with the Ivy team |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors the
VideoPlayerwidget's frontend implementation to establish a shared props interface across all player backends and introduce the YouTube IFrame API as the rendering layer for YouTube videos — replacing the previous<iframe>approach and laying the foundation for imperative prop controls (e.g. volume, seek).Why
The old implementation had no shared contract between native and YouTube player components. Each player received ad-hoc props with no type enforcement, and YouTube videos were rendered via a static
<iframe>with no access to the player's JS API. That meant properties likemuted,loop,controls, andautoplayhad to be baked into the embed URL — and future controls (volume, playback rate, etc.) would be impossible without a full rewrite.What changed
Shared
VideoPlayerPropsinterface (video/types.ts)All player backends now receive the same typed props:
Player registry (
players.ts)New players are registered in a typed map. Adding a new backend is a one-liner:
YouTube IFrame API loader (
lib/youtube-api.ts)Lazy singleton — injects the YouTube script once per page, resolves when
YTis ready:This gives direct JS access to the player instance, so future controls like
player.setVolume(n)orplayer.seekTo(t)require no structural changes — just a new prop and a call intoplayerRef.current.Extending with a new player
To add e.g. a Vimeo player:
'vimeo'toVideoTypeintypes.tsVimeoPlayer: React.FC<VideoPlayerProps>vimeo: VimeoPlayerinplayers.tsVideoPlayerWidget'sEMBED_TO_VIDEO_TYPEmapNo other files need to change.
C# API
Unchanged.
Source,Autoplay,Controls,Muted,Loop, andPosterall serialize exactly as before.Closes #2420