The React Player Controls are a great way to build your own custom player controls. You can use them to create your own music player, podcast player, video player, or something else entirely.
Selectively Display React Player Controls
You can control what type of react player controls you want to display. For example, you might choose to only show the fast forward button when the player is playing.
Instead of always displaying all buttons, you can selectively display controls based on a condition: whether or not the player is active (playing), paused, stopped or seeking forward in time.
The following code snippet shows how this works:
Displaying the Title
You can use a custom component to display the title in your React Player Controls.
To do this, you need to pass the player’s props and a helper function that renders the title:
Displaying Error Messages
When displaying an error message, it’s important to make sure that the react player controls knows what they did wrong and how they can fix it. The following are some guidelines for creating error messages:
Make sure your error messages are clear. Don’t use technical jargon or abbreviations; instead, be sure to display all relevant details in plain language that anyone can understand.
Make sure your error messages are easy to understand. If a user doesn’t have access to the internet and gets an error message because of this, they might be alarmed by how difficult it is to figure out what went wrong and why even though most errors aren’t actually that complicated!
Make sure your error messages are easy to fix or remove (delete). If there’s an issue with a plugin or extension, then users may need assistance from someone who has more experience working with those programs than they do; otherwise, they could spend hours trying their own methods before realizing their efforts were pointless!
Making the Play Button More Noticeable
To make it stand out more, try making the play button larger. This might be enough to help users notice it and make their decision to watch or not watch. If you want to get fancy, you can give the react player controls button a different color than the rest of your UI elements (like the background color), so that people will notice it even when they don’t know what they should be looking for.
You can make great looking for react player controls
If you want to make great looking controls for your React Player, you can!
With the [gatsby-player] component, you get consistent and responsive controls in any device. No more different styles for different devices or players the same code will work for all!
The [gatsby-player] component has two built-in themes: dark and light. If you don’t like those themes, though, it’s easy to customize them with CSS.
Summary of all the react player controls
The react player controls are the components that extend and enhance the video player. They’re used to control video playback, provide error messages and suggestions, and more.
Each control is created as a container component with a specific role:
- Container: contains all other components (play button, title text)
- Player-controls contains react player controls that affect playback (play/pause button, volume slider)
- Title: displays title of currently playing video
- Error Message: displays error messages or suggestions based on user input
If you’re looking for a slick way to control your video player, I hope this has been helpful. React Player Controls is a simple library that gives you access to a lot of the same functionality that you get with native controls. If you’re interested in learning more about ReactJS or how we use React at Filestack, check out our blog post on Building A Simple File Storage App With ReactJS.