Skip to content

Commit

Permalink
v1.1.6: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Amir-Alipour committed Jun 2, 2023
1 parent 9fb5988 commit 1c91484
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ const songList = [
## Example
See the example directory for a basic working example of using this project. To run it locally, run `npm install` in the [example directory](https://github.com/Amir-Alipour/reaplay/tree/master/example) and then `npm start`.
or <br />
[![Edit blog](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/blissful-frost-yl38y)
or
<br />
```jsx
Expand Down
14 changes: 8 additions & 6 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ const App = () => {
<button onClick={() => player.toPrevTrack()}>prev</button>
<button
onClick={() =>
player.setIsPlaying((isPlay: boolean) => !isPlay)
player.setIsPlaying(player.isPlaying ? false : true)
}
>
{player.isPlaying ? 'pause' : 'play'}
</button>
<button onClick={() => player.toNextTrack()}>next</button>
<button
onClick={() =>
player.setIsRepeat((isRepeat: boolean) => !isRepeat)
}
onClick={() => {
player.isRepeat ? player.repeat(false) : player.repeat(true)
}}
>
{player.isRepeat ? 'un repeat' : 'repeat'}
</button>
Expand All @@ -71,11 +71,13 @@ const App = () => {
step='1'
min='0'
max='100'
onChange={(e) => player.setVolume(e.target.value)}
onChange={(e) => player.setVolume(+e.target.value)}
className='volume-range'
/>
<button
onClick={() => player.setIsMute((isMute: boolean) => !isMute)}
onClick={() => {
player.isMute ? player.unmute() : player.mute()
}}
style={{ padding: '5px' }}
>
{player.isMute ? 'unmute' : 'mute'}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reaplay",
"version": "1.1.5",
"version": "1.1.6",
"description": "the react HOC for create custom players with any styles you like",
"author": "amir-alipour",
"license": "MIT",
Expand Down
13 changes: 7 additions & 6 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export const Reaplay = ({ tracks, startIndex = 0, children }: Props) => {
*
*/
const audioRef = useRef(new Audio(tracks[trackIndex]))
audioRef.current.autoplay = false
audioRef.current.volume = volume / 100
audioRef.current.muted = isMute
audioRef.current.playbackRate = speed
Expand Down Expand Up @@ -333,7 +334,7 @@ export const Reaplay = ({ tracks, startIndex = 0, children }: Props) => {
*/

const repeat = (SetOnRepeat: boolean): void => {
if(SetOnRepeat) {
if (SetOnRepeat) {
setIsRepeat(true)
} else {
setIsRepeat(false)
Expand Down Expand Up @@ -531,7 +532,7 @@ export interface PlayerType {
isLoading: boolean
isHaveError: boolean
trackIndex: number
setTrackIndex: Function
setTrackIndex: (index: number) => void
duration: number
durationText: string
trackProgress: number
Expand All @@ -540,22 +541,22 @@ export interface PlayerType {
onScrub: Function
onScrubEnd: Function
isPlaying: boolean
setIsPlaying: Function
setIsPlaying: (isPlaying: boolean) => void
play: Function
pause: Function
toNextTrack: Function
toPrevTrack: Function
isRepeat: boolean
repeat: Function
repeat: (setOnrepeat: boolean) => void
volume: number
setVolume: Function
setVolume: (volume: number) => void
speed: number
playSlow: Function
playNormal: Function
playFast: Function
isStopPlayMoreSong: boolean
StopPlayMoreSong: Function
playShuffle: Function
playShuffle: (isShuffle: boolean) => void
isShuffle: boolean
playRandom: Function
isMute: boolean
Expand Down

0 comments on commit 1c91484

Please sign in to comment.