JSPM

  • Created
  • Published
  • Downloads 1169
  • Score
    100M100P100Q108951F
  • License Apache-2.0

Provides a media player with optional placeholder

Package Exports

  • @bbc/psammead-media-player

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@bbc/psammead-media-player) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

⛔️ This is an alpha component ⛔️

This component is currently tagged as alpha and is not suitable for production use. Following the passing of an accessibility review this component will be marked as ready for production and the alpha tag removed.

psammead-media-player · Known Vulnerabilities Dependency Status peerDependencies Status Storybook GitHub license npm version PRs Welcome

Description

The psammead-media-player component exports two versions of our media player: an AMP version, and an Canonical version.

At it's core, this component returns an iframe that is designed to frame a media asset. The AMP variant will render an amp-iframe with a nested amp-img to use as a placeholder. The Canonical variant will render a placeholder, that when clicked will load the iframe into view.

When to use this component

This component to be used at any point on the page, specifically when a media player is needed.

Installation

npm install @bbc/psammead-media-player

Props

CanonicalMediaPlayer

Argument Type Required Default Example
src string Yes - http://foobar.com/embeddable_endpoint
showPlaceholder boolean No true false
placeholderSrc string No null http://foobar.com/placeholder.png
portrait boolean No false true

The src prop is required, as it tells the component what page it needs to embed. The portrait prop is not required, and defaults to false. This is to support portrait video content in the future. The showPlaceholder boolean prop is also not required, and defaults to true. Assuming showPlaceholder is true, the placeholderSrc will be what image to display as the placeholder.

AmpMediaPlayer

Argument Type Required Default Example
src string Yes - http://foobar.com/embeddable_endpoint
portrait boolean No false true
placeholderSrc string yes - http://foobar.com/placeholder.png

The placeholderSrc prop is required for AMP, as in order to have the component load an amp-iframe within 600px or 75% of the viewport from the top, we must have an amp-img placeholder. For more information on this, please refer to the AMP docs for amp-iframe.

Usage

CanonicalMediaPlayer

import { CanonicalMediaPlayer } from '@bbc/psammead-media-player';

const Container = ({ src, portrait, showPlaceholder, placeholderSrc }) => (
  <CanonicalMediaPlayer
    src={src}
    portrait={portrait}
    placeholderSrc={placeholderSrc}
    showPlaceholder={showPlaceholder}
  />
)

AmpMediaPlayer

import { AmpMediaPlayer } from '@bbc/psammead-media-player';

const Container = ({ src, portrait, placeholderSrc }) => (
  <AmpMediaPlayer
    src={src}
    portrait={portrait}
    placeholderSrc={placeholderSrc}
  />
)

Accessibility notes

This component is still in its initial alpha stages, and requires a full and extensive accessibility review.

Contributing

Psammead is completely open source. We are grateful for any contributions, whether they be new components, bug fixes or general improvements. Please see our primary contributing guide which can be found at the root of the Psammead respository.

Code of Conduct

We welcome feedback and help on this work. By participating in this project, you agree to abide by the code of conduct. Please take a moment to read it.

License

Psammead is Apache 2.0 licensed.