I am using the jPlayer example in a create-react-app. Here is a CodeSandbox showing the issue of font-awesome icon's rendering as boxes.
The icons render via css rules specifying content as unicode for <i>
tags with the fa
class.
I installed the font-awesome dependency which was in the jPlayer example's package.json
. Then, I implemented an AudioPlayer component and used the skins provided by jPlayer. The component renders but the icons are all boxes, and I can see the unicode content in the source.
Here's an example of the project architecture. This is the play button in /src/AudioPlayer/AudioPlayer.jsx
.
<Play><i className="fa">{/* Icon set in css */}</i></Play>
Then, the AudioPlayer is imported into App.jsx
. App.jsx
imports a stylesheet which has this relevant rule:
.fa, .fas, .far {
font-family: FontAwesome !important;
}
App.jsx
is then rendered by index.js
. Inside index.js
, we import the audio player's stylesheets:
// Styles the jPlayer to look nice
import 'react-jplayer/dist/css/skins/sleek.min.css';
// Styles Play/Pause/Mute etc when icons (<i />) are used for them
import 'react-jplayer/dist/css/controls/iconControls.min.css';
The rule for the play button in iconControls.css
looks like this:
.jp-jplayer .jp-icon-controls .jp-play i:before {
content: "\F04B";
font-family: 'Font Awesome\ 5 Free';
font-weight: 900;
}
then within index.html
's head
I include the font-awesome CDN as a final attempt at fixing the boxes being rendered instead of font-awesome icons.