diff --git a/src/App.jsx b/src/App.jsx
index 48c315e..881ac67 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,16 +1,17 @@
import Player from "./Player/Player";
import "./Player/player.scss";
-import { songsdata } from "./Player/AudioData.js";
import { useRef, useState, useEffect } from "react";
+import { song_dll } from "./Player/AudioData.js";
+import { BsArrowsExpandVertical } from "react-icons/bs";
const App = () => {
- const [songs, setSongs] = useState(songsdata);
+ const [songs, setSongs] = useState(song_dll);
const [isplaying, setisplaying] = useState(false);
- const [currentSong, setCurrentSong] = useState(songsdata[1]);
+ const [currentSong, setCurrentSong] = useState(window.current_song_ptr);
const audioElem = useRef();
- useEffect(() => {
+ useEffect(() => {songs
if (isplaying) {
audioElem.current.play();
} else {
@@ -31,7 +32,11 @@ const App = () => {
return (
-
+
{
-
+import { useRef } from "react";
+import "./player.scss";
+import {
+ BsFillPlayCircleFill,
+ BsFillPauseCircleFill,
+ BsFillSkipStartCircleFill,
+ BsFillSkipEndCircleFill,
+} from "react-icons/bs";
+const Player = ({
+ audioElem,
+ isPlaying,
+ setIsPlaying,
+ currentSong,
+ setCurrentSong,
+
+}) => {
const clickRef = useRef();
- const PlayPause = ()=>
- {
+ const PlayPause = () => {
setIsPlaying(!isPlaying);
+ };
- }
-
-
- const checkWidth = (e)=>
- {
+ const checkWidth = (e) => {
let width = clickRef.current.clientWidth;
const offset = e.nativeEvent.offsetX;
- const divprogress = offset / width * 100;
- audioElem.current.currentTime = divprogress / 100 * currentSong.length;
+ const divprogress = (offset / width) * 100;
+ audioElem.current.currentTime = (divprogress / 100) * currentSong.length;
+ };
- }
+ const skipBack = () => {
- const skipBack = ()=>
- {
- const index = songs.findIndex(x=>x.title == currentSong.title);
- if (index == 0)
- {
- setCurrentSong(songs[songs.length - 1])
- }
- else
- {
- setCurrentSong(songs[index - 1])
+ if (window.current_song_ptr.prev !== null) {
+ window.current_song_ptr = window.current_song_ptr.prev;
+ setCurrentSong(window.current_song_ptr);
}
- audioElem.current.currentTime = 0;
-
- }
- const skiptoNext = ()=>
- {
- const index = songs.findIndex(x=>x.title == currentSong.title);
+ audioElem.current.currentTime = 0;
+ };
- if (index == songs.length-1)
- {
- setCurrentSong(songs[0])
- }
- else
- {
- setCurrentSong(songs[index + 1])
+ const skiptoNext = () => {
+ if (window.current_song_ptr.next !== null) {
+ window.current_song_ptr = window.current_song_ptr.next;
+ setCurrentSong(window.current_song_ptr);
}
+
audioElem.current.currentTime = 0;
-
- }
+ };
return (
-
+
-
- {isPlaying ? : }
-
+
+ {isPlaying ? (
+
+ ) : (
+
+ )}
+
-
- )
-}
-
-export default Player
-
-import PropTypes from 'prop-types';
+ );
+};
+export default Player;
+import PropTypes from "prop-types";
Player.propTypes = {
audioElem: PropTypes.object, // or other appropriate PropType
@@ -87,5 +87,4 @@ Player.propTypes = {
setIsPlaying: PropTypes.func,
currentSong: PropTypes.object,
setCurrentSong: PropTypes.func,
- songs: PropTypes.array
-};
\ No newline at end of file
+};
diff --git a/src/algorithms/.gitkeep b/src/algorithms/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/src/algorithms/dll.js b/src/algorithms/dll.js
new file mode 100644
index 0000000..9a71ebc
--- /dev/null
+++ b/src/algorithms/dll.js
@@ -0,0 +1,118 @@
+class Node {
+ constructor(data) {
+ this.data = data;
+ this.prev = null;
+ this.next = null;
+ }
+}
+
+class DoublyLinkedList {
+ constructor() {
+ this.head = null;
+ this.tail = null;
+ this.size = 0;
+ }
+
+ isEmpty() {
+ return this.size === 0;
+ }
+
+ back() {
+ if (this.isEmpty()) {
+ return null;
+ }
+ return this.tail.data;
+ }
+
+ front() {
+ if (this.isEmpty()) {
+ return null;
+ }
+ return this.head.data;
+ }
+
+ pushBack(data) {
+ const newNode = new Node(data);
+ if (this.isEmpty()) {
+ this.head = newNode;
+ this.tail = newNode;
+ } else {
+ this.tail.next = newNode;
+ newNode.prev = this.tail;
+ this.tail = newNode;
+ }
+ this.size++;
+ }
+
+ pushFront(data) {
+ const newNode = new Node(data);
+ if (this.isEmpty()) {
+ this.head = newNode;
+ this.tail = newNode;
+ } else {
+ newNode.next = this.head;
+ this.head.prev = newNode;
+ this.head = newNode;
+ }
+ this.size++;
+ }
+
+ popBack() {
+ if (this.isEmpty()) {
+ return null;
+ }
+ const removedData = this.tail.data;
+ if (this.size === 1) {
+ this.head = null;
+ this.tail = null;
+ } else {
+ this.tail = this.tail.prev;
+ this.tail.next = null;
+ }
+ this.size--;
+ return removedData;
+ }
+
+ popFront() {
+ if (this.isEmpty()) {
+ return null;
+ }
+ const removedData = this.head.data;
+ if (this.size === 1) {
+ this.head = null;
+ this.tail = null;
+ } else {
+ this.head = this.head.next;
+ this.head.prev = null;
+ }
+ this.size--;
+ return removedData;
+ }
+
+ display() {
+ let current = this.head;
+ while (current) {
+ console.log(current.data);
+ current = current.next;
+ }
+ }
+}
+
+export default DoublyLinkedList;
+// Example usage:
+const dll = new DoublyLinkedList();
+dll.pushBack(1);
+dll.pushBack("anup");
+dll.pushBack(3);
+// dll.display(); // Output: 1 anup 3
+var ptr = dll.head;
+ptr= ptr.next;
+ptr = ptr.prev;
+console.log(ptr.data);
+
+// console.log(dll.tail.prev.prev.data);
+
+
+
+
+