![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
react-soundplayer
Advanced tools
Create highly-customizable SoundCloud (or any audio) players with React.js.
npm install react-soundplayer --save
There are several examples on the website. Here is the basic one to get you started:
import React from 'react';
import ReactDOM from 'react-dom';
import { PlayButton, Timer } from 'react-soundplayer/components';
import { withSoundCloudAudio } from 'react-soundplayer/addons';
const clientId = 'YOUR CLIENT ID';
const resolveUrl = 'https://soundcloud.com/ksmtk/chronemics';
const Player = withSoundCloudAudio(props => {
let { track, currentTime } = props;
return (
<div className="custom-player">
<PlayButton
className="custom-player-btn"
onPlayClick={() => {
console.log('play button clicked!');
}}
{...props} />
<h2 className="custom-player-title">
{track ? track.title : 'Loading...'}
</h2>
<Timer
className="custom-player-timer"
duration={track ? track.duration / 1000 : 0}
currentTime={currentTime}
{...props} />
</div>
);
});
const App = () => {
return (
<Player
clientId={clientId}
resolveUrl={resolveUrl}
onReady={() => console.log('track is loaded!')} />
);
};
ReactDOM.render(
<App />,
document.getElementById('#app')
);
It is also easy to built players without using SoundCloud API. You just need to pass audio source via streamUrl
and all other necessary track meta information can be passed as custom props. Also you can choose preloadType
, according to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio#Attributes, by default this property is equal to 'auto'.
import React from 'react';
import ReactDOM from 'react-dom';
import { PlayButton, Timer } from 'react-soundplayer/components';
// it's just an alias for `withSoundCloudAudio` but makes code clearer
import { withCustomAudio } from 'react-soundplayer/addons';
// audio source
const streamUrl = 'https://example.org/path/to/file.mp3';
// some track meta information
const trackTitle = 'Great song by random artist';
const AWSSoundPlayer = withCustomAudio(props => {
const { trackTitle } = props;
return (
<div>
<PlayButton {...props} />
<h2>{trackTitle}</h2>
<Timer {...props} />
</div>
);
});
class App extends React.Component {
render() {
return (
<AWSSoundPlayer
streamUrl={streamUrl}
trackTitle={trackTitle}
preloadType="auto" />
);
}
}
ReactDOM.render(<App />, document.getElementById('app'));
MIT Licensed
FAQs
Create custom SoundCloud players with React
The npm package react-soundplayer receives a total of 0 weekly downloads. As such, react-soundplayer popularity was classified as not popular.
We found that react-soundplayer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.