New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-media-player

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-media-player

React media player.

  • 0.3.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.9K
increased by6.11%
Maintainers
1
Weekly downloads
 
Created
Source

React Media Player

React media container component to help build video & audio players.

Install

npm install react-media-player --save

bower install react-media-player --save

Example using Babel Stage 0


import React, { Component, PropTypes } from 'react'
import { Media, controls } from 'react-media-player'
const { PlayPause, CurrentTime, Progress, SeekBar, Duration, MuteUnmute, Volume, Fullscreen } = controls

class MediaPlayer extends Component {
  static contextTypes = {
    playPause: PropTypes.func,
    isLoading: PropTypes.bool
  }

  render() {
    const { Player } = this.props
    const { isLoading, playPause } = this.context

    return (
      <div className="media">
        <div className="media-player" onClick={() => playPause()}>
          {Player}
        </div>
        <nav className="media-controls">
          <PlayPause />
          <CurrentTime />
          <Progress />
          <SeekBar />
          <Duration />
          <MuteUnmute />
          <Volume />
          <Fullscreen />
        </nav>
      </div>
    )
  }
}

class App extends React.Component {
  state = {
    currentSource: 'http://www.youtube.com/embed/h3YVKTxTOgU'
  }

  render() {
    return (
      <Media src={this.state.currentSource}>
        {Player => <MediaPlayer Player={Player} />}
      </Media>
    )
  }
}

Live Codepen Demo

Demo

Props

src: PropTypes.string.isRequired

The source of the media you want to play. Currently supporting Youtube, Vimeo, and any HTML5 compatible video or audio.

vendor: PropTypes.oneOf(['youtube', 'vimeo', 'audio', 'video'])

Explicitly choose which component to render for the player. If not set, the library does its best to determine what player to render based on the source.

children: PropTypes.func.isRequired

Passes in the Player to be rendered.

Contexts

currentTime: PropTypes.number
progress: PropTypes.number
duration: PropTypes.number
volume: PropTypes.number
isLoading: PropTypes.bool
isPlaying: PropTypes.bool
isMuted: PropTypes.bool
isFullscreen: PropTypes.bool
play: PropTypes.func
pause: PropTypes.func
playPause: PropTypes.func
stop: PropTypes.func
seekTo: PropTypes.func
mute: PropTypes.func
muteUnmute: PropTypes.func
setVolume: PropTypes.func
fullscreen: PropTypes.func

Warning

This library makes heavy use of context, please be advised that with new releases of React the way context is handled in this library is subject to change.

Running Locally

clone repo

git clone git@github.com:souporserious/react-media-player.git

move into folder

cd ~/react-media-player

install dependencies

npm install

run dev mode

npm run dev

open your browser and visit: http://localhost:8080/

Keywords

FAQs

Package last updated on 15 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc