Skip to content

Commit

Permalink
feat(play-added-song)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x1h committed Aug 8, 2022
1 parent 1ea07d4 commit 8266df0
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div align="center">
<img src="https://img.shields.io/npm/dt/react-simplified-player.svg">
<img src="https://img.shields.io/static/v1?label=version&message=v1.0.78&color=yellow">
<img src="https://img.shields.io/static/v1?label=version&message=v1.0.9&color=yellow">
<img src="https://img.shields.io/static/v1?label=license&message=MIT&color=black">
<img src="https://img.shields.io/static/v1?label=minzipped file&message=45.1 KB&color=success">
<img src="https://visitor-badge.glitch.me/badge?page_id=callmenikk.react-simplified-player">
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": "react-simplified-player",
"version": "1.0.77",
"version": "1.0.9",
"description": "Simple Easy Customizable React Audio Player 🎶",
"main": "index.js",
"publishConfig": {
Expand Down
16 changes: 12 additions & 4 deletions src/ReactSimplifiedPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,20 @@ export const ReactSimplifiedPlayer: FC<PlayerProps> = (props) => {

if (!props.song!.url.trim()) return;

// when first song loads it adds 2 song togethers
if (
songData[0]?.song_title?.trim() === songData[1]?.song_title?.trim() &&
songData[0]?.song_artist?.trim() === songData[1]?.song_artist?.trim()
)
//this code removes second extra added song from queue
setSongData((prev) => {
return prev.slice(1, 0);
});

//if last added song and clicked song urls are same do not add it in queue
if (
props.song!.song_title?.trim() ===
songData[lastIndex]?.song_title?.trim() &&
props.song!.song_artist?.trim() ===
songData[lastIndex]?.song_artist?.trim()
props.song!.url.trim() ===
songData[lastIndex]?.url.trim()
)
return;

Expand All @@ -63,6 +64,13 @@ export const ReactSimplifiedPlayer: FC<PlayerProps> = (props) => {
},
];
});
setCurrentIndex(songData.length)
setControl((prev) => {
return {
...prev,
playing: true
}
})
}, [props.song]);

const [timeLapse, setTimeLapse] = useState({
Expand Down
2 changes: 1 addition & 1 deletion src/style/queue.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
border-radius: 10px 10px 0 0;
bottom: 0;
right: 0;
z-index: 1;
z-index: 99;
transform: translateY(-80px);
}
@media screen and (max-width: 768px) {
Expand Down
2 changes: 1 addition & 1 deletion src/style/queue.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/style/queue.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
border-radius: 10px 10px 0 0;
bottom: 0;
right: 0;
z-index: 1;
z-index: 99;
transform: translateY(-80px);
@media screen and (max-width: 768px){
transform: translateY(0px);
Expand Down

0 comments on commit 8266df0

Please sign in to comment.