MCPcopy
hub / github.com/tjallingt/react-youtube

github.com/tjallingt/react-youtube @v10.1.0 sqlite

repository ↗ · DeepWiki ↗ · release v10.1.0 ↗
15 symbols 34 edges 11 files 4 documented · 27%
README

Release Tests Example

react-youtube

Simple React component acting as a thin layer over the YouTube IFrame Player API

Features

Installation

NPM

npm install react-youtube

Yarn

yarn add react-youtube

PNPM

pnpm add react-youtube

Usage

<YouTube
  videoId={string}                  // defaults -> ''
  id={string}                       // defaults -> ''
  className={string}                // defaults -> ''
  iframeClassName={string}          // defaults -> ''
  style={object}                    // defaults -> {}
  title={string}                    // defaults -> ''
  loading={string}                  // defaults -> undefined
  opts={obj}                        // defaults -> {}
  onReady={func}                    // defaults -> noop
  onPlay={func}                     // defaults -> noop
  onPause={func}                    // defaults -> noop
  onEnd={func}                      // defaults -> noop
  onError={func}                    // defaults -> noop
  onStateChange={func}              // defaults -> noop
  onPlaybackRateChange={func}       // defaults -> noop
  onPlaybackQualityChange={func}    // defaults -> noop
/>

For convenience it is also possible to access the PlayerState constants through react-youtube: YouTube.PlayerState contains the values that are used by the YouTube IFrame Player API.

Example

// js
import React from 'react';
import YouTube from 'react-youtube';

class Example extends React.Component {
  render() {
    const opts = {
      height: '390',
      width: '640',
      playerVars: {
        // https://developers.google.com/youtube/player_parameters
        autoplay: 1,
      },
    };

    return <YouTube videoId="2g811Eo7K8U" opts={opts} onReady={this._onReady} />;
  }

  _onReady(event) {
    // access to player in all event handlers via event.target
    event.target.pauseVideo();
  }
}
// ts
import React from 'react';
import YouTube, { YouTubeProps } from 'react-youtube';

function Example() {
  const onPlayerReady: YouTubeProps['onReady'] = (event) => {
    // access to player in all event handlers via event.target
    event.target.pauseVideo();
  }

  const opts: YouTubeProps['opts'] = {
    height: '390',
    width: '640',
    playerVars: {
      // https://developers.google.com/youtube/player_parameters
      autoplay: 1,
    },
  };

  return <YouTube videoId="2g811Eo7K8U" opts={opts} onReady={onPlayerReady} />;
}

Controlling the player

You can access & control the player in a way similar to the official api:

The ~~API~~ component will pass an event object as the sole argument to each of ~~those functions~~ the event handler props. The event object has the following properties:

  • The event's target identifies the video player that corresponds to the event.
  • The event's data specifies a value relevant to the event. Note that the onReady event does not specify a data property.

License

MIT

Core symbols most depended-on inside this repo

filterResetOptions
called by 2
packages/react-youtube/src/YouTube.tsx
shouldUpdateVideo
called by 1
packages/react-youtube/src/YouTube.tsx
shouldResetPlayer
called by 1
packages/react-youtube/src/YouTube.tsx
shouldUpdatePlayer
called by 1
packages/react-youtube/src/YouTube.tsx
render
called by 1
packages/react-youtube/src/YouTube.tsx
YouTubeComponentExample
called by 0
packages/example/src/index.tsx
outExtension
called by 0
packages/react-youtube/tsup.config.ts
constructor
called by 0
packages/react-youtube/src/YouTube.tsx

Shape

Function 8
Method 5
Class 2

Languages

TypeScript100%

Modules by API surface

packages/react-youtube/src/YouTube.tsx11 symbols
packages/react-youtube/tsup.config.ts1 symbols
packages/example/src/index.tsx1 symbols
packages/example-ssr/pages/index.tsx1 symbols
packages/example-ssr/pages/_app.tsx1 symbols

Dependencies from manifests, versioned

@commitlint/cli17.1.2 · 1×
@commitlint/config-conventional17.1.0 · 1×
@testing-library/jest-dom5.16.5 · 1×
@testing-library/react13.4.0 · 1×
@types/jest29.0.0 · 1×
@types/node18.7.16 · 1×
@types/react18.0.18 · 1×
@types/react-dom18.0.6 · 1×
@types/youtube-player5.5.6 · 1×
@typescript-eslint/eslint-plugin5.36.2 · 1×
@typescript-eslint/parser5.36.2 · 1×
eslint8.23.0 · 1×

For agents

$ claude mcp add react-youtube \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact