react-jPlaylist is an add-on to react-jPlayer that provides playlist functionality and components for you to use.
- Documentation
https://github.com/jplayer/react-jPlayer-examples
npm install --save react-jplaylist
The recommended way to use this package is through npm and webpack. However if you insist on including the .js and .css files manually then both the unminified and minified versions are available from the /dist/
folder. The dependencies of this package have been excluded for the UMD build so you will need to include them manually as shown in the react-jPlayer-example's UMDPlaylist.
This module is exported to a variable called ReactJPlaylist
.
- Cross compatible with many legacy different Html5 browsers
- Back, Forward, Shuffle, Playlist Selection, Playlist Looping
- Fully customizable, modular and componentized
- Comes with a fully reponsive css skin for your players
Same as react-jPlayer
Used for setting up the default options for your jPlaylist. Deep merges the options that you pass in with react-jPlayer's and react-jPlaylist's default options. The result of this is used as the initial state for your jPlaylist.
Arguments
jPlayerOptions
(object): The jPlayer options to specify for your jPlaylist.jPlaylistOptions
(object): The jPlaylist options to specify for your jPlaylist.
The jPlaylist reducer that will be called whenever a jPlaylist function is dispatched. Must be passed to your store with the key named 'jPlaylists'.
All of the actions need to be dispatched using Reduxes dispatch
function as you normally do with actions.
Sets any jPlaylist option.
Arguments
id
(string): Id of the jPlaylist to apply this to.key
(string): The name of the option that you want to set. Specifying nested keys is not supported.value
(any): The value to set the option to.
Sets the playlist of the jPlaylist. You don't need to use this on jPlaylist load because this method is automatically called internally on componentDidMount
with the playlist you supplied in options.playlist.
Arguments
id
(string): Id of the jPlaylist to apply this to.playlist
(array: objects): The new playlist which will be set to your jPlaylist.
Adds the media to the end of the playlist.
Arguments
id
(string): Id of the jPlaylist to apply this to.media
(object): The media to be added to your playlist.playNow
(bool): Optionally play the media as soon as it's added.
Removes the media from the playlist at the specified index.
Arguments
id
(string): Id of the jPlaylist to apply this to.index
(number): The index of the playlist array with which to remove.
Clears the playlist array and resets some jPlaylist values back to default.
Arguments
id
(string): Id of the jPlaylist to apply this to.
Plays the jPlaylist. If no index is supplied then it plays the current media.
Arguments
id
(string): Id of the jPlaylist to apply this to.index
(number): Optionally play the media at the supplied index.
Shuffles the playlist.
Arguments
id
(string): Id of the jPlaylist to apply this to.shuffled
(bool): Toggles shuffled setting if no param is given. True always shuffles the playlist. False will un-shuffle if it was shuffled.playNow
(bool): Optionally play the media as soon as it's shuffled.
Plays the next media item in the playlist.
Arguments
id
(string): Id of the jPlaylist to apply this to.
Plays the previous media item in the playlist.
Arguments
id
(string): Id of the jPlaylist to apply this to.
Properties in this object are used to initialize the jPlaylist. They are deep merged with the default jPlaylist options.
jPlaylist will load the playlist from this option on load automatically. Each object within the array should be the same as react-jPlayer's media schema but also must include an id that can be a string or a number.
E.g.
media: { { id: 0, // react jPlayer media options here... } }
id
needs to be a number or a string.
Default: true
The playlist will loop back to the end when calling previous()
.
Default: true
If loop is 'loop-playlist' and shuffled is true, the playlist will shuffle when calling next()
on the last item.
Default: "loop-playlist"
There are three settings which jPlaylist recognizes for loop:
- 'off': Doesn't loop the playlist or the current media, stops on the last item when
next()
is called. - 'loop': Loops the current media in the playlist.
- 'loop-playlist': Loops the entire playlist when calling
next()
on the last item.
Default: false
Hides or shows the playlist. Used internally with the TogglePlaylist
component.
props
children
(element) : Required: Must be the JPlayer component.id
(string) : Required: Must be the same as the one you supplied to the jPlayer options.keyBindings
(object): Specifies the keyBindings to be applied when that key is pressed. Deep merges these props with the jPlaylist's default keyBindings. See react-jPlayer's keyBindings for more information.
Default:
keyBindings: {
next: {
key: 221, // ]
fn: () => dispatch(next(id)),
},
previous: {
key: 219, // [
fn: () => dispatch(previous(id)),
},
shuffle: {
key: 83, // s
fn: () => dispatch(shuffle(id, undefined, true)),
},
loop: {
key: 76, // l
fn: () => {
const loop = getLoopState(stateProps.loop);
dispatch(setOption(id, 'loop', loop));
},
},
}
This component needs to wrap the JPlayer component
props
children
(node) : Required
Any component that is a child of this component will be duplicated x number of times where x is the size of your playlist.
props
children
(node) : Required
Default: ×
Should be nested as a child of the Playlist
component. Renders the remove controls for each media in your playlist.
props
children
(node) : Required
Should be nested as a child of the Playlist
component. Renders the media links for the playlist and allows the user to select other media's in your playlist.
Default: media.artist
- media.title
Should be nested as a child of the Playlist
component. Renders the artist and title of the current media.
Should be nested as a child of the Playlist
component. Renders the poster of the current media.
props
children
(node) : Required
Used in conjunction with the hidePlaylist
property. Toggles the visiblity of the playlist onClick
.
props
children
(node) : Required
onClick
calls the previous
action internally and sets the media to the previous item.
props
children
(node) : Required
onClick
calls the next
action internally and sets the media to the next item.
props
children
(node) : Required
onClick
calls the shuffle
action internally and shuffles the media.
props
children
(node) : Required
onClick
calls the setOption
action internally and sets the loop to the next state, i.e. if loop is currently 'off" then clicking on this component will set the loop state to 'loop'.