npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

replica-player

v0.1.2

Published

Video-player for React that is identical to YouTube's player. YouTube video-player clone.

Downloads

12

Readme

Replica Player

Minzipped size License

Video-player for React that is identical to YouTube's in-app player. YouTube video-player clone.

[Todo: add comparison of original player and Replica Player]

Work in progress

Motivation

YouTube player is probably the best universal video-player ever created, I have never met a player in the web with such a good UX. However, YouTube made it's impossible to play custom videos in YouTube native player. There was some attempts to recreate this player, but in most they're just examples and prototypes. There was no full-features, mobile-first, production-ready YouTube's player clone.

Features

  • Works on native HTML5 video element, so any format, that your browser can play, can also be played in Replica Player

  • On mobile it's identical to YouTube's in-app player, on PC it's identical to YouTube's web player

  • Features supported (roadmap):

  • [ ] Fast-forwarding

  • [x] Speed change

  • [x] Quality versions

  • [ ] Subtitles

  • [ ] Hotkeys

  • [ ] Episodes

  • [ ] Playlists

  • [x] Aspect-ratio view modes: fit, cover, resize

  • [ ] Localization

  • [ ] Chrome cast (using Presentation API)

  • React v18 supported. Vue, Angular and Vanilla JS support may be added in future.

  • TypeScript supported

  • MIT licensed, not patented by Google LLC

Install

npm i replica-player
yarn add replica-player

Compiled with TypeScript, bundled with Rollup. Building is done for CJS. If you need ESM code, you can follow instructions in CONTRIBUTING.md file.

Tested with

Use with React

Developed with React 18.2.0

You must import replica-player/dist/index.css along with the component itself. For SSR and Next.js, import css globally in pages/_app.js file.

import React from 'react'
import ReplicaPlayer from 'replica-player'
import 'replica-player/dist/index.css'

export default function YourApp() {
  // Component can hold a ref
  const ref = React.useRef()

  return (
    <ReplicaPlayer 
      src={[
        {
          uri: 'https://www.w3schools.com/html/mov_bbb.mp4',
          quality: '720p'
        },
        {
          uri: 'https://www.w3schools.com/html/mov_bbb.mp4',
          quality: {
            width: 1280,
            height: 720,
            fps: 30
          }
        }
      ]}
      ref={ref}
    />
  )
}

API Reference

Props

Props with types ending with ? are optional.

| Prop | Type | Default | Description | | ------------------------- | -------------------------- | :-------- | ------------------------------------------------------------------- | | src | array of objects | undefined | Media source. Array of either presets or custom quality. See below. | | width | number? | 640 | Width of player's container. Can be overriden with css styles | | height | number? | 360 | Height of player's container. Can be overriden with css styles | | resizeMode | string? | 'fit' | One of 'fit', 'cover' and 'fill' | | segments | Segment?[] | [] | Array of video segments | | componentsProps | object? | undefined | Rest props for any components inside player | | componentsProps.container | object? | undefined | Props for player's container div | | componentsProps.controls | object? | undefined | Props for player's controls | | subtitles | Subtitles?[] | [] | Subtitles. Array of objects. See below. |

src props

Sources are source files of the same video with different quality.

src prop is always array of objects with uri and quality properties, where URI is a link to video file (may be anything that browser understands) and quality is either preset or object with custom quality.

  • Presets for qualities: '144p' | '240p' | '360p' | '480p' | '720p' | '1080p' | '1440p' | '2160p' | '4320p'
  • Custom quality: { width: number, height: number, fps: number } (will be displayed as {width}x{height}p{fps})

Interfaces

Segment

Video segment

| Prop | Type | Default | Description | | --------- | ------ | :-------- | --------------------------------------------------- | | timeStart | number | undefined | Seconds from start of the video when segment starts | | title | string | "" | Title of segment |

Subtitles

Currently not supported.

| Prop | Type | Default | Description | | ------- | ------ | :------ | -------------------------------- | | fileURI | string | '' | URI of file with subtitles | | name | string | '' | Human-friendly name of subtitles |

Ref API reference

[Todo]

Legal notice

YouTube player's code is minified and copyrighted to YouTube, but the player itself is not patented/copyrighted. You can patent a technology feature (such as splitting videos in chunks, optimisation, which this player doesn't do), brand's logos, but you can't patent/copyright the web component, it's impossible :) Otherwise, everything in the web would be much more complicated.

Source code of this player is written by me, Viktor Shcheclochkov @hloth <[email protected]>, as seen from commits history, and, as stated in LICENSE.md and below, I give anyone with copy of this component a permission to use it in any context as you wish: you can embed ads in it and sell products using this component without need to credit me (but I would appreciate you credit me tho).

License

MIT License

Copyright (c) 2022 Viktor Shchelochkov

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Funding

Donate: hloth.dev/donate