Skip to content

Conversation

@saseungmin
Copy link
Member

@saseungmin saseungmin commented Jun 16, 2025

Summary by CodeRabbit

  • New Features
    • Enhanced playback controls with a seek back 10 seconds button and improved play/pause handling.
    • The player now provides detailed status information (such as playback rates, quality, time, volume, and mute state) when ready, enabling richer UI updates.
    • Added customizable styling options for web and native player components.
  • Improvements
    • Playback controls have been rearranged for better usability.
    • Player sizing is now more flexible with max height styling and expanded dimension support.
    • Optimized event handling and state updates for smoother interactions.
  • Type Updates
    • Introduced a new PlayerInfo type for more comprehensive player event data.
    • Updated event handler signatures to include detailed player state information.

@coderabbitai
Copy link

coderabbitai bot commented Jun 16, 2025

Walkthrough

The changes introduce a new PlayerInfo type that encapsulates detailed YouTube player state, and update the onReady event across the codebase to provide this information as an argument. Event handler signatures, messaging structures, and UI logic are refactored to use PlayerInfo, improving state handling and playback control interactions.

Changes

File(s) Change Summary
example/src/App.tsx Refactored event handlers to use PlayerInfo, moved formatTime utility, added seek controls, and updated UI.
src/YoutubePlayer.tsx, src/YoutubePlayer.web.tsx Modified onReady event to provide a PlayerInfo object with detailed player state; added style props.
src/hooks/youtubeIframeScripts.ts Updated ready message to send a playerInfo object instead of separate fields.
src/index.tsx Exported new PlayerInfo type from ./types/youtube.
src/types/iframe.d.ts Introduced generic PlayerEvent<T>, updated event handler signatures, imported PlayerInfo.
src/types/message.ts Changed ReadyMessageData to use a playerInfo: PlayerInfo property.
src/types/youtube.ts Added PlayerInfo type, updated onReady signature in YoutubePlayerProps to accept PlayerInfo; added style props and flexible dimension types.
src/YoutubePlayerWrapper.tsx Updated width and height prop types to DimensionValue for more flexible sizing.

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant YoutubePlayer
    participant Iframe/Web
    participant YouTubeAPI

    App->>YoutubePlayer: Mounts component, passes onReady handler
    YoutubePlayer->>Iframe/Web: Loads YouTube player
    Iframe/Web->>YouTubeAPI: Initializes player
    YouTubeAPI-->>Iframe/Web: Player ready with state
    Iframe/Web-->>YoutubePlayer: Sends 'ready' message with playerInfo
    YoutubePlayer-->>App: Calls onReady(playerInfo)
    App->>App: Updates state with playerInfo
Loading

Possibly related PRs

Poem

In a field of code, a rabbit hops,
PlayerInfo in its paws, it never stops.
Ready events now bring more cheer,
With playback rates and states so clear.
Seek and play, mute and more—
This bunny’s player does not bore!
🐇🎶


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0627bac and d8909d9.

📒 Files selected for processing (1)
  • example/src/App.tsx (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • example/src/App.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jun 16, 2025

Deploying react-native-youtube-bridge with  Cloudflare Pages  Cloudflare Pages

Latest commit: d8909d9
Status: ✅  Deploy successful!
Preview URL: https://ff292667.react-native-youtube-bridge.pages.dev
Branch Preview URL: https://fix-youtube-sync-issues.react-native-youtube-bridge.pages.dev

View logs

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (5)
src/types/youtube.ts (1)

56-70: PlayerInfo could be stricter & readonly

All fields are optional; in practice duration, availablePlaybackRates, etc. are always available after onReady.
Mark the truly-always fields as required (or wrap the type in Readonly<…>). This tightens type-safety and avoids a sea of undefined checks downstream.

-export type PlayerInfo = {
+export type PlayerInfo = Readonly<{
   availablePlaybackRates: number[];
   duration: number;
   // …
-};
+}>;          // remaining keys stay optional as needed
src/YoutubePlayer.tsx (1)

54-68: Pass playerInfo directly & guard for undefined

Copy-pasting every field is repetitive and couples this block to future PlayerInfo changes. A simple null-check plus direct pass keeps the handler resilient.

-            const { playerInfo } = data;
-
-            setIsReady(true);
-            onReady?.({
-              availablePlaybackRates: playerInfo.availablePlaybackRates,
-              availableQualityLevels: playerInfo.availableQualityLevels,
-              currentTime: playerInfo.currentTime,
-              duration: playerInfo.duration,
-              muted: playerInfo.muted,
-              playbackQuality: playerInfo.playbackQuality,
-              playbackRate: playerInfo.playbackRate,
-              playerState: playerInfo.playerState,
-              size: playerInfo.size,
-              volume: playerInfo.volume,
-            });
+            const { playerInfo } = data;
+
+            setIsReady(true);
+            if (playerInfo) {
+              onReady?.(playerInfo);
+            }
example/src/App.tsx (3)

30-30: async keyword is unnecessary

handleReady performs no await; drop async to avoid misleading callers.


110-113: Volume state can fall out-of-sync

setVolume is invoked optimistically. If the underlying player rejects the value, UI will still display the new percentage. Consider awaiting the promise and updating state only on success.


126-133: Rename onPlaytogglePlay for clarity

The handler toggles between play / pause; naming it explicitly communicates intent and avoids the momentary mental jump. Purely semantic but improves readability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91fc978 and 861928e.

📒 Files selected for processing (8)
  • example/src/App.tsx (6 hunks)
  • src/YoutubePlayer.tsx (1 hunks)
  • src/YoutubePlayer.web.tsx (1 hunks)
  • src/hooks/youtubeIframeScripts.ts (1 hunks)
  • src/index.tsx (1 hunks)
  • src/types/iframe.d.ts (3 hunks)
  • src/types/message.ts (2 hunks)
  • src/types/youtube.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/types/message.ts (1)
src/types/youtube.ts (1)
  • PlayerInfo (56-70)
example/src/App.tsx (2)
src/index.tsx (1)
  • PlayerInfo (11-11)
src/types/youtube.ts (1)
  • PlayerInfo (56-70)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (4)
src/types/youtube.ts (1)

22-22: Breaking-API change – bump minor/major version & update docs

onReady now delivers PlayerInfo; all downstream callbacks/tests must be adapted.
Remember to list this in CHANGELOG and bump the public version accordingly.

src/index.tsx (1)

11-12: Re-export LGTM

Re-exporting PlayerInfo aligns the public surface with the new type. 👍

src/types/message.ts (1)

15-16: Message shape updated – ensure native/web consumers are in sync

playerInfo replaces separate fields. Verify all message handlers (RN WebView, web build) parse the new structure, otherwise they will silently ignore readiness data.

src/types/iframe.d.ts (1)

59-65: onReady’s data is always null — confirm intent

You changed the higher-level React wrapper to pass a PlayerInfo object, but here PlayerEvent<null> keeps the payload empty. If you eventually need the same info at the raw iframe-API layer, consider PlayerEvent<PlayerInfo | null> to stay consistent.
Otherwise, clarify with a comment that the details are exposed only via target.playerInfo.

@saseungmin saseungmin merged commit 4b26472 into main Jun 16, 2025
6 checks passed
@saseungmin saseungmin deleted the fix/youtube-sync-issues branch June 16, 2025 09:51
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.

2 participants