From 5ca1350add080e41d6a01d7d35bfa90d28dd5d21 Mon Sep 17 00:00:00 2001 From: apil <078bct017.apil@pcampus.edu.np> Date: Thu, 7 Mar 2024 21:00:26 +0545 Subject: [PATCH 1/4] initial commit --- src/algorithms/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/algorithms/.gitkeep diff --git a/src/algorithms/.gitkeep b/src/algorithms/.gitkeep new file mode 100644 index 0000000..e69de29 From 88541975ca9246657b564b73bd7ea9b3af1c62d9 Mon Sep 17 00:00:00 2001 From: Anoobee Date: Thu, 7 Mar 2024 21:45:16 +0545 Subject: [PATCH 2/4] added doublylinklist --- src/algorithms/dll.js | 113 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 src/algorithms/dll.js diff --git a/src/algorithms/dll.js b/src/algorithms/dll.js new file mode 100644 index 0000000..1f50184 --- /dev/null +++ b/src/algorithms/dll.js @@ -0,0 +1,113 @@ +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 { + newNode.prev = this.tail; + this.tail.next = newNode; + 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 +// console.log("Front:", dll.front()); // Output: Front: 1 +// console.log("Back:", dll.back()); // Output: Back: 3 +// dll.popBack(); +// dll.display(); // Output: 1 anup +// dll.popFront(); +// dll.display(); // Output: anup From fd4c58d7c2fbb0ef824cc821901a34a204cbc35e Mon Sep 17 00:00:00 2001 From: Anoobee Date: Fri, 8 Mar 2024 00:14:13 +0545 Subject: [PATCH 3/4] random --- src/Player/AudioData.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Player/AudioData.js b/src/Player/AudioData.js index 07530d6..e7301a3 100644 --- a/src/Player/AudioData.js +++ b/src/Player/AudioData.js @@ -16,7 +16,7 @@ const songsdata = [ "url": song3 } ] -export { songsdata }; +export { songsdata }; // change hello //Better Data // let savage = { From 3e53e510c4fc06527f05e56c69ed713e6f5bcd88 Mon Sep 17 00:00:00 2001 From: Anoobee Date: Sat, 9 Mar 2024 01:13:28 +0545 Subject: [PATCH 4/4] integrated DLL --- src/App.jsx | 15 ++++-- src/Player/AudioData.js | 50 ++++++++++++------ src/Player/Player.jsx | 109 ++++++++++++++++++++-------------------- src/algorithms/dll.js | 31 +++++++----- 4 files changed, 116 insertions(+), 89 deletions(-) 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 (
-