Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mebtte/react-media-session

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mebtte/react-media-session

The react component that wraps MediaSession.

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
73
increased by46%
Maintainers
1
Weekly downloads
 
Created
Source

react-media-session version license

The react component that wraps mediaSession.

What is MediaSession

Requirement

  • react >= 16.8 with hooks

Installation

npm install --save @mebtte/react-media-session

Usage

As component

When browser do not support mediaSession, it will be render children only.

import MediaSession from '@mebtte/react-media-session';

<MediaSession
  title="Way back"
  artist="Vicetone,Cozi Zuehlsdorff"
  album="Way Back"
  artwork={[
    {
      src: 'cover_large.jpeg',
      sizes: '256x256,384x384,512x512',
      type: 'image/jpeg',
    },
    {
      src: 'cover_small.jpeg',
      sizes: '96x96,128x128,192x192',
      type: 'image/jpeg',
    },
  ]}
  onPlay={audio.play}
  onPause={audio.pause}
  onSeekBackward={onSeekBackward}
  onSeekForward={onSeekForward}
  onPreviousTrack={playPreviousMusic}
  onNextTrack={playNextMusic}
>
  children or null
</MediaSession>;

As hooks

import { useMediaSession } from '@mebtte/react-media-session';

const Component = () => {
  // ...

  useMediaSession({
    title: 'Way back',
    artist: 'Vicetone,Cozi Zuehlsdorff',
    album: 'Way Back',
    artwork: [
      {
        src: 'cover_large.jpeg',
        sizes: '256x256,384x384,512x512',
        type: 'image/jpeg',
      },
      {
        src: 'cover_small.jpeg',
        sizes: '96x96,128x128,192x192',
        type: 'image/jpeg',
      },
    ],
    onPlay: audio.play,
    onPause: audio.pause,
    onSeekBackward,
    onSeekForward,
    onPreviousTrack,
    onNextTrack,
  });

  // ...
};

When using hooks, you must make sure mediaSession exists. You can judge by blow.

import { HAS_MEDIA_SESSION } from '@mebtte/react-media-session';

Props

propstyperequireddefault
titlestringfalse''
artiststringfalse''
albumstringfalse''
artworkarray({ src: string, sizes: string, type?: string })false[]
onPlayfuncfalsenull
onPausefuncfalsenull
onSeekBackwardfuncfalsenull
onSeekForwardfuncfalsenull
onPreviousTrackfuncfalsenull
onNextTrackfuncfalsenull

Screenshot

LICENSE

MIT

Keywords

FAQs

Package last updated on 27 Apr 2022

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