PlayButton component renders a button with a 'video' or 'audio' icon and optional duration timestamp. Which icon is displayed is defined by the value of the
type prop. The component displays a 'video' icon by default. This component has options for displaying a duration timestamp, which if not provided will render gracefully without. When clicked, the function passed to
onClick will be called.
npm install @bbc/psammead-play-button
A typical use case for this component would be to indicate to a user that a media asset placeholder contains playable media, which is either 'video' or 'audio' and, if applicable, its duration. A function triggering playback would be passed to the button's
import PlayButton from '@bbc/psammead-play-button';<PlayButton="news"="Dog barks at cat."=="2:30"="2 minutes 30 seconds"="PT2M30S"="audio"="Contains strong language."/>;
When to use this component
PlayButton component is designed to be used in a media asset placeholder containing playable media. It indicates to the user to expect 'video' or 'audio' content, as well as its duration, if applicable.
This component is expected to provide information about the playable media to screenreaders and other assistive technology. It is required that the title of the media be passed to the
title prop and, if duration is to be displayed, a human-friendly version to
durationSpoken. If the video has guidance information, this is also read out in the assitive text. This is used to build a string, which is rendered in a VisuallyHiddenText element. The icon is marked as
aria-hidden="true", which means it should be ignored by screenreaders.
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.
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.
Psammead is Apache 2.0 licensed.