aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsaid belhadj <saidbelhadj0312@gmail.com>2021-06-26 12:01:49 +0200
committersaid belhadj <saidbelhadj0312@gmail.com>2021-06-26 12:01:49 +0200
commit05b5bb7d2407006e08f46f66893a972a9f091952 (patch)
tree5f9756148699ac753de4834068faa4d333c36f98
parente58b48a3162539cb79ff495d6040ca6f53f069d6 (diff)
Add reset, pause, quit functionality
-rw-r--r--.classpath6
-rw-r--r--.idea/.gitignore8
-rw-r--r--.idea/misc.xml6
-rw-r--r--.idea/modules.xml8
-rw-r--r--.idea/vcs.xml6
-rw-r--r--.project17
-rw-r--r--bin/.gitignore1
-rw-r--r--bin/musichub/business/Album.classbin4580 -> 5577 bytes
-rw-r--r--bin/musichub/business/AudioBook.classbin3854 -> 3968 bytes
-rw-r--r--bin/musichub/business/AudioElement.classbin3209 -> 5105 bytes
-rw-r--r--bin/musichub/business/Category.classbin1318 -> 1442 bytes
-rw-r--r--bin/musichub/business/Genre.classbin1329 -> 1453 bytes
-rw-r--r--bin/musichub/business/Language.classbin1316 -> 1440 bytes
-rw-r--r--bin/musichub/business/MusicHub.classbin8924 -> 11575 bytes
-rw-r--r--bin/musichub/business/NoAlbumFoundException.classbin260 -> 387 bytes
-rw-r--r--bin/musichub/business/NoElementFoundException.classbin264 -> 393 bytes
-rw-r--r--bin/musichub/business/NoPlayListFoundException.classbin266 -> 396 bytes
-rw-r--r--bin/musichub/business/PlayList.classbin3240 -> 3905 bytes
-rw-r--r--bin/musichub/business/Song.classbin2853 -> 2907 bytes
-rw-r--r--bin/musichub/business/SortByAuthor.classbin719 -> 891 bytes
-rw-r--r--bin/musichub/business/SortByDate.classbin681 -> 844 bytes
-rw-r--r--bin/musichub/business/SortByGenre.classbin685 -> 848 bytes
-rw-r--r--bin/musichub/main/Main.classbin7826 -> 9528 bytes
-rw-r--r--bin/musichub/util/XMLHandler.classbin2388 -> 2909 bytes
-rw-r--r--out/production/spoteezer/musichub/business/Album.classbin0 -> 5606 bytes
-rw-r--r--out/production/spoteezer/musichub/business/AudioBook.classbin0 -> 4278 bytes
-rw-r--r--out/production/spoteezer/musichub/business/AudioElement.classbin0 -> 3752 bytes
-rw-r--r--out/production/spoteezer/musichub/business/Category.classbin0 -> 1476 bytes
-rw-r--r--out/production/spoteezer/musichub/business/Genre.classbin0 -> 1487 bytes
-rw-r--r--out/production/spoteezer/musichub/business/Language.classbin0 -> 1474 bytes
-rw-r--r--out/production/spoteezer/musichub/business/MusicHub.classbin0 -> 11031 bytes
-rw-r--r--out/production/spoteezer/musichub/business/NoAlbumFoundException.classbin0 -> 387 bytes
-rw-r--r--out/production/spoteezer/musichub/business/NoElementFoundException.classbin0 -> 393 bytes
-rw-r--r--out/production/spoteezer/musichub/business/NoPlayListFoundException.classbin0 -> 396 bytes
-rw-r--r--out/production/spoteezer/musichub/business/PlayList.classbin0 -> 3926 bytes
-rw-r--r--out/production/spoteezer/musichub/business/Song.classbin0 -> 3217 bytes
-rw-r--r--out/production/spoteezer/musichub/business/SortByAuthor.classbin0 -> 901 bytes
-rw-r--r--out/production/spoteezer/musichub/business/SortByDate.classbin0 -> 854 bytes
-rw-r--r--out/production/spoteezer/musichub/business/SortByGenre.classbin0 -> 858 bytes
-rw-r--r--out/production/spoteezer/musichub/main/Main.classbin0 -> 9322 bytes
-rw-r--r--out/production/spoteezer/musichub/util/XMLHandler.classbin0 -> 2921 bytes
-rw-r--r--spoteezer.iml11
-rw-r--r--src/musichub/business/AudioElement.java32
-rw-r--r--src/musichub/business/MusicHub.java8
-rw-r--r--src/musichub/business/Song.java9
-rw-r--r--src/musichub/main/Main.java6
46 files changed, 100 insertions, 18 deletions
diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..0cbf9cd
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..73f69e0
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..644a944
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_16" project-jdk-name="openjdk-16" project-jdk-type="JavaSDK">
+ <output url="file://$PROJECT_DIR$/out" />
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..8f05ee9
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/spoteezer.iml" filepath="$PROJECT_DIR$/spoteezer.iml" />
+ </modules>
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="" vcs="Git" />
+ </component>
+</project> \ No newline at end of file
diff --git a/.project b/.project
new file mode 100644
index 0000000..cf232f0
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>spoteezer</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/bin/.gitignore b/bin/.gitignore
new file mode 100644
index 0000000..0076c39
--- /dev/null
+++ b/bin/.gitignore
@@ -0,0 +1 @@
+/musichub/
diff --git a/bin/musichub/business/Album.class b/bin/musichub/business/Album.class
index 0bc7b94..e2e5b03 100644
--- a/bin/musichub/business/Album.class
+++ b/bin/musichub/business/Album.class
Binary files differ
diff --git a/bin/musichub/business/AudioBook.class b/bin/musichub/business/AudioBook.class
index acd92fc..6ab9f2a 100644
--- a/bin/musichub/business/AudioBook.class
+++ b/bin/musichub/business/AudioBook.class
Binary files differ
diff --git a/bin/musichub/business/AudioElement.class b/bin/musichub/business/AudioElement.class
index b737756..9f6e12a 100644
--- a/bin/musichub/business/AudioElement.class
+++ b/bin/musichub/business/AudioElement.class
Binary files differ
diff --git a/bin/musichub/business/Category.class b/bin/musichub/business/Category.class
index 08b0990..85ff126 100644
--- a/bin/musichub/business/Category.class
+++ b/bin/musichub/business/Category.class
Binary files differ
diff --git a/bin/musichub/business/Genre.class b/bin/musichub/business/Genre.class
index 5a59007..db6f5d7 100644
--- a/bin/musichub/business/Genre.class
+++ b/bin/musichub/business/Genre.class
Binary files differ
diff --git a/bin/musichub/business/Language.class b/bin/musichub/business/Language.class
index e22490e..dd87891 100644
--- a/bin/musichub/business/Language.class
+++ b/bin/musichub/business/Language.class
Binary files differ
diff --git a/bin/musichub/business/MusicHub.class b/bin/musichub/business/MusicHub.class
index 0a7ffda..40e09b2 100644
--- a/bin/musichub/business/MusicHub.class
+++ b/bin/musichub/business/MusicHub.class
Binary files differ
diff --git a/bin/musichub/business/NoAlbumFoundException.class b/bin/musichub/business/NoAlbumFoundException.class
index 2c37b0c..7cee1f4 100644
--- a/bin/musichub/business/NoAlbumFoundException.class
+++ b/bin/musichub/business/NoAlbumFoundException.class
Binary files differ
diff --git a/bin/musichub/business/NoElementFoundException.class b/bin/musichub/business/NoElementFoundException.class
index 6afa6b4..e8118b9 100644
--- a/bin/musichub/business/NoElementFoundException.class
+++ b/bin/musichub/business/NoElementFoundException.class
Binary files differ
diff --git a/bin/musichub/business/NoPlayListFoundException.class b/bin/musichub/business/NoPlayListFoundException.class
index 2290022..15a3811 100644
--- a/bin/musichub/business/NoPlayListFoundException.class
+++ b/bin/musichub/business/NoPlayListFoundException.class
Binary files differ
diff --git a/bin/musichub/business/PlayList.class b/bin/musichub/business/PlayList.class
index 571eac0..9403ae5 100644
--- a/bin/musichub/business/PlayList.class
+++ b/bin/musichub/business/PlayList.class
Binary files differ
diff --git a/bin/musichub/business/Song.class b/bin/musichub/business/Song.class
index 2cad917..7790568 100644
--- a/bin/musichub/business/Song.class
+++ b/bin/musichub/business/Song.class
Binary files differ
diff --git a/bin/musichub/business/SortByAuthor.class b/bin/musichub/business/SortByAuthor.class
index 009d9fe..232d4a1 100644
--- a/bin/musichub/business/SortByAuthor.class
+++ b/bin/musichub/business/SortByAuthor.class
Binary files differ
diff --git a/bin/musichub/business/SortByDate.class b/bin/musichub/business/SortByDate.class
index 4ad6b49..68e775b 100644
--- a/bin/musichub/business/SortByDate.class
+++ b/bin/musichub/business/SortByDate.class
Binary files differ
diff --git a/bin/musichub/business/SortByGenre.class b/bin/musichub/business/SortByGenre.class
index cf0f29c..78295f9 100644
--- a/bin/musichub/business/SortByGenre.class
+++ b/bin/musichub/business/SortByGenre.class
Binary files differ
diff --git a/bin/musichub/main/Main.class b/bin/musichub/main/Main.class
index 0ebef6e..9528e6f 100644
--- a/bin/musichub/main/Main.class
+++ b/bin/musichub/main/Main.class
Binary files differ
diff --git a/bin/musichub/util/XMLHandler.class b/bin/musichub/util/XMLHandler.class
index 9a53fc4..04ba597 100644
--- a/bin/musichub/util/XMLHandler.class
+++ b/bin/musichub/util/XMLHandler.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/business/Album.class b/out/production/spoteezer/musichub/business/Album.class
new file mode 100644
index 0000000..c08b1be
--- /dev/null
+++ b/out/production/spoteezer/musichub/business/Album.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/business/AudioBook.class b/out/production/spoteezer/musichub/business/AudioBook.class
new file mode 100644
index 0000000..3ad965d
--- /dev/null
+++ b/out/production/spoteezer/musichub/business/AudioBook.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/business/AudioElement.class b/out/production/spoteezer/musichub/business/AudioElement.class
new file mode 100644
index 0000000..ab20d50
--- /dev/null
+++ b/out/production/spoteezer/musichub/business/AudioElement.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/business/Category.class b/out/production/spoteezer/musichub/business/Category.class
new file mode 100644
index 0000000..51a68d1
--- /dev/null
+++ b/out/production/spoteezer/musichub/business/Category.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/business/Genre.class b/out/production/spoteezer/musichub/business/Genre.class
new file mode 100644
index 0000000..66a7d69
--- /dev/null
+++ b/out/production/spoteezer/musichub/business/Genre.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/business/Language.class b/out/production/spoteezer/musichub/business/Language.class
new file mode 100644
index 0000000..31b17c2
--- /dev/null
+++ b/out/production/spoteezer/musichub/business/Language.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/business/MusicHub.class b/out/production/spoteezer/musichub/business/MusicHub.class
new file mode 100644
index 0000000..e1a0961
--- /dev/null
+++ b/out/production/spoteezer/musichub/business/MusicHub.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/business/NoAlbumFoundException.class b/out/production/spoteezer/musichub/business/NoAlbumFoundException.class
new file mode 100644
index 0000000..03aff87
--- /dev/null
+++ b/out/production/spoteezer/musichub/business/NoAlbumFoundException.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/business/NoElementFoundException.class b/out/production/spoteezer/musichub/business/NoElementFoundException.class
new file mode 100644
index 0000000..6ba1c87
--- /dev/null
+++ b/out/production/spoteezer/musichub/business/NoElementFoundException.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/business/NoPlayListFoundException.class b/out/production/spoteezer/musichub/business/NoPlayListFoundException.class
new file mode 100644
index 0000000..54319de
--- /dev/null
+++ b/out/production/spoteezer/musichub/business/NoPlayListFoundException.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/business/PlayList.class b/out/production/spoteezer/musichub/business/PlayList.class
new file mode 100644
index 0000000..ea68021
--- /dev/null
+++ b/out/production/spoteezer/musichub/business/PlayList.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/business/Song.class b/out/production/spoteezer/musichub/business/Song.class
new file mode 100644
index 0000000..c3bdeb7
--- /dev/null
+++ b/out/production/spoteezer/musichub/business/Song.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/business/SortByAuthor.class b/out/production/spoteezer/musichub/business/SortByAuthor.class
new file mode 100644
index 0000000..fb8ee7a
--- /dev/null
+++ b/out/production/spoteezer/musichub/business/SortByAuthor.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/business/SortByDate.class b/out/production/spoteezer/musichub/business/SortByDate.class
new file mode 100644
index 0000000..c52e870
--- /dev/null
+++ b/out/production/spoteezer/musichub/business/SortByDate.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/business/SortByGenre.class b/out/production/spoteezer/musichub/business/SortByGenre.class
new file mode 100644
index 0000000..2016012
--- /dev/null
+++ b/out/production/spoteezer/musichub/business/SortByGenre.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/main/Main.class b/out/production/spoteezer/musichub/main/Main.class
new file mode 100644
index 0000000..419fb9c
--- /dev/null
+++ b/out/production/spoteezer/musichub/main/Main.class
Binary files differ
diff --git a/out/production/spoteezer/musichub/util/XMLHandler.class b/out/production/spoteezer/musichub/util/XMLHandler.class
new file mode 100644
index 0000000..4ab0064
--- /dev/null
+++ b/out/production/spoteezer/musichub/util/XMLHandler.class
Binary files differ
diff --git a/spoteezer.iml b/spoteezer.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/spoteezer.iml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ </component>
+</module> \ No newline at end of file
diff --git a/src/musichub/business/AudioElement.java b/src/musichub/business/AudioElement.java
index 9294b49..0c1e9e4 100644
--- a/src/musichub/business/AudioElement.java
+++ b/src/musichub/business/AudioElement.java
@@ -5,6 +5,7 @@ import org.w3c.dom.Element;
import java.io.File;
import java.io.IOException;
+import java.util.Scanner;
import java.util.UUID;
import javax.sound.sampled.AudioInputStream;
@@ -93,12 +94,39 @@ public abstract class AudioElement {
}
- public void playSong() throws UnsupportedAudioFileException, IOException, LineUnavailableException {
+ public void manageAudioElement() throws UnsupportedAudioFileException, IOException, LineUnavailableException {
+
+ Scanner scanner = new Scanner(System.in);
+
File file = new File(this.content);
AudioInputStream audioStream = AudioSystem.getAudioInputStream(file);
Clip clip = AudioSystem.getClip();
clip.open(audioStream);
- clip.start();
+
+ String action = "";
+
+ while(!action.equals("Q")) {
+ System.out.println("P = Play \b S = Stop \b R = Reset \b Q = Quit");
+ System.out.println("Enter your choice");
+ action = scanner.next();
+ action = action.toUpperCase();
+
+ switch(action) {
+ case "S" : clip.stop();
+ break;
+ case "P" : clip.start();
+ break;
+ case "R" : clip.setMicrosecondPosition(0);
+ break;
+ case "Q" : clip.stop();
+ break;
+ default : System.out.println("try again");
+ }
+ System.out.println("You stoped the Audio element");
+ }
+
+ clip.close();
+
}
} \ No newline at end of file
diff --git a/src/musichub/business/MusicHub.java b/src/musichub/business/MusicHub.java
index e138d84..f7cf137 100644
--- a/src/musichub/business/MusicHub.java
+++ b/src/musichub/business/MusicHub.java
@@ -331,10 +331,10 @@ public class MusicHub {
xmlHandler.createXMLFile(document, ELEMENTS_FILE_PATH);
}
- public void getSong(List<AudioElement> Songs, String songTitle) throws NoAlbumFoundException, UnsupportedAudioFileException, IOException, LineUnavailableException {
- for (AudioElement s : Songs) {
- if (s.getTitle().equalsIgnoreCase(songTitle)) {
- s.playSong();
+ public void getAudioElement(List<AudioElement> audios, String elementTitle) throws NoAlbumFoundException, UnsupportedAudioFileException, IOException, LineUnavailableException {
+ for (AudioElement el : audios) {
+ if (el.getTitle().equalsIgnoreCase(elementTitle)) {
+ el.manageAudioElement();
}
}
diff --git a/src/musichub/business/Song.java b/src/musichub/business/Song.java
index 7b90156..564b7c5 100644
--- a/src/musichub/business/Song.java
+++ b/src/musichub/business/Song.java
@@ -1,14 +1,5 @@
package musichub.business;
-import java.io.File;
-import java.io.IOException;
-
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.Clip;
-import javax.sound.sampled.LineUnavailableException;
-import javax.sound.sampled.UnsupportedAudioFileException;
-
import org.w3c.dom.Document;
import org.w3c.dom.Element;
diff --git a/src/musichub/main/Main.java b/src/musichub/main/Main.java
index 58080bd..2876734 100644
--- a/src/musichub/main/Main.java
+++ b/src/musichub/main/Main.java
@@ -3,7 +3,6 @@ package musichub.main;
import musichub.business.*;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
@@ -47,7 +46,8 @@ public class Main {
albumTitle = scan.nextLine();
try {
- System.out.println(theHub.getAlbumSongsSortedByGenre(albumTitle));
+ List<Song> songs = theHub.getAlbumSongsSortedByGenre(albumTitle);
+ System.out.println(songs);;
} catch (NoAlbumFoundException ex) {
System.out.println("No album found with the requested title " + ex.getMessage());
}
@@ -64,7 +64,7 @@ public class Main {
List<AudioElement> songs = theHub.getAlbumSongs(albumTitle);
System.out.println(theHub.getAlbumSongs(albumTitle));
String song = scan.nextLine();
- theHub.getSong(songs, song);
+ theHub.getAudioElement(songs, song);
} catch (NoAlbumFoundException ex) {
System.out.println("No album found with the requested title " + ex.getMessage());
}