Getting Started with Tunez
π¦ Installationβ
Install Tunez via npm:
npm install tunez
π Setupβ
First, import TunezProvider, useTunez, and the AudioPlayer component from tunez:
import AudioPlayer , { TunezProvider, useTunez } from 'tunez';
Wrap your app with TunezProvider so you can access the useTunez hook from anywhere:
function MyApp({ children }) {
return (
<TunezProvider>
{children}
</TunezProvider>
);
}
π΅ Using Tunezβ
You can now use useTunez to control playback. Hereβs a simple example:
import { useTunez, AudioPlayer } from 'tunez';
const track = {
title: 'Sample Track',
src: 'https://example.com/sample.mp3',
author: 'Artist Name',
thumbnail: 'https://example.com/thumbnail.jpg',
};
function PlayerExample() {
const { playTrack } = useTunez();
return (
<div>
<AudioPlayer />
<button onClick={() => playTrack(track)}>
Click to Play
</button>
</div>
);
}
Now youβre ready to integrate Tunez into your project! π