diff options
author | said belhadj <saidbelhadj0312@gmail.com> | 2021-06-26 12:01:49 +0200 |
---|---|---|
committer | said belhadj <saidbelhadj0312@gmail.com> | 2021-06-26 12:01:49 +0200 |
commit | 05b5bb7d2407006e08f46f66893a972a9f091952 (patch) | |
tree | 5f9756148699ac753de4834068faa4d333c36f98 | |
parent | e58b48a3162539cb79ff495d6040ca6f53f069d6 (diff) |
Add reset, pause, quit functionality
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 Binary files differindex 0bc7b94..e2e5b03 100644 --- a/bin/musichub/business/Album.class +++ b/bin/musichub/business/Album.class diff --git a/bin/musichub/business/AudioBook.class b/bin/musichub/business/AudioBook.class Binary files differindex acd92fc..6ab9f2a 100644 --- a/bin/musichub/business/AudioBook.class +++ b/bin/musichub/business/AudioBook.class diff --git a/bin/musichub/business/AudioElement.class b/bin/musichub/business/AudioElement.class Binary files differindex b737756..9f6e12a 100644 --- a/bin/musichub/business/AudioElement.class +++ b/bin/musichub/business/AudioElement.class diff --git a/bin/musichub/business/Category.class b/bin/musichub/business/Category.class Binary files differindex 08b0990..85ff126 100644 --- a/bin/musichub/business/Category.class +++ b/bin/musichub/business/Category.class diff --git a/bin/musichub/business/Genre.class b/bin/musichub/business/Genre.class Binary files differindex 5a59007..db6f5d7 100644 --- a/bin/musichub/business/Genre.class +++ b/bin/musichub/business/Genre.class diff --git a/bin/musichub/business/Language.class b/bin/musichub/business/Language.class Binary files differindex e22490e..dd87891 100644 --- a/bin/musichub/business/Language.class +++ b/bin/musichub/business/Language.class diff --git a/bin/musichub/business/MusicHub.class b/bin/musichub/business/MusicHub.class Binary files differindex 0a7ffda..40e09b2 100644 --- a/bin/musichub/business/MusicHub.class +++ b/bin/musichub/business/MusicHub.class diff --git a/bin/musichub/business/NoAlbumFoundException.class b/bin/musichub/business/NoAlbumFoundException.class Binary files differindex 2c37b0c..7cee1f4 100644 --- a/bin/musichub/business/NoAlbumFoundException.class +++ b/bin/musichub/business/NoAlbumFoundException.class diff --git a/bin/musichub/business/NoElementFoundException.class b/bin/musichub/business/NoElementFoundException.class Binary files differindex 6afa6b4..e8118b9 100644 --- a/bin/musichub/business/NoElementFoundException.class +++ b/bin/musichub/business/NoElementFoundException.class diff --git a/bin/musichub/business/NoPlayListFoundException.class b/bin/musichub/business/NoPlayListFoundException.class Binary files differindex 2290022..15a3811 100644 --- a/bin/musichub/business/NoPlayListFoundException.class +++ b/bin/musichub/business/NoPlayListFoundException.class diff --git a/bin/musichub/business/PlayList.class b/bin/musichub/business/PlayList.class Binary files differindex 571eac0..9403ae5 100644 --- a/bin/musichub/business/PlayList.class +++ b/bin/musichub/business/PlayList.class diff --git a/bin/musichub/business/Song.class b/bin/musichub/business/Song.class Binary files differindex 2cad917..7790568 100644 --- a/bin/musichub/business/Song.class +++ b/bin/musichub/business/Song.class diff --git a/bin/musichub/business/SortByAuthor.class b/bin/musichub/business/SortByAuthor.class Binary files differindex 009d9fe..232d4a1 100644 --- a/bin/musichub/business/SortByAuthor.class +++ b/bin/musichub/business/SortByAuthor.class diff --git a/bin/musichub/business/SortByDate.class b/bin/musichub/business/SortByDate.class Binary files differindex 4ad6b49..68e775b 100644 --- a/bin/musichub/business/SortByDate.class +++ b/bin/musichub/business/SortByDate.class diff --git a/bin/musichub/business/SortByGenre.class b/bin/musichub/business/SortByGenre.class Binary files differindex cf0f29c..78295f9 100644 --- a/bin/musichub/business/SortByGenre.class +++ b/bin/musichub/business/SortByGenre.class diff --git a/bin/musichub/main/Main.class b/bin/musichub/main/Main.class Binary files differindex 0ebef6e..9528e6f 100644 --- a/bin/musichub/main/Main.class +++ b/bin/musichub/main/Main.class diff --git a/bin/musichub/util/XMLHandler.class b/bin/musichub/util/XMLHandler.class Binary files differindex 9a53fc4..04ba597 100644 --- a/bin/musichub/util/XMLHandler.class +++ b/bin/musichub/util/XMLHandler.class diff --git a/out/production/spoteezer/musichub/business/Album.class b/out/production/spoteezer/musichub/business/Album.class Binary files differnew file mode 100644 index 0000000..c08b1be --- /dev/null +++ b/out/production/spoteezer/musichub/business/Album.class diff --git a/out/production/spoteezer/musichub/business/AudioBook.class b/out/production/spoteezer/musichub/business/AudioBook.class Binary files differnew file mode 100644 index 0000000..3ad965d --- /dev/null +++ b/out/production/spoteezer/musichub/business/AudioBook.class diff --git a/out/production/spoteezer/musichub/business/AudioElement.class b/out/production/spoteezer/musichub/business/AudioElement.class Binary files differnew file mode 100644 index 0000000..ab20d50 --- /dev/null +++ b/out/production/spoteezer/musichub/business/AudioElement.class diff --git a/out/production/spoteezer/musichub/business/Category.class b/out/production/spoteezer/musichub/business/Category.class Binary files differnew file mode 100644 index 0000000..51a68d1 --- /dev/null +++ b/out/production/spoteezer/musichub/business/Category.class diff --git a/out/production/spoteezer/musichub/business/Genre.class b/out/production/spoteezer/musichub/business/Genre.class Binary files differnew file mode 100644 index 0000000..66a7d69 --- /dev/null +++ b/out/production/spoteezer/musichub/business/Genre.class diff --git a/out/production/spoteezer/musichub/business/Language.class b/out/production/spoteezer/musichub/business/Language.class Binary files differnew file mode 100644 index 0000000..31b17c2 --- /dev/null +++ b/out/production/spoteezer/musichub/business/Language.class diff --git a/out/production/spoteezer/musichub/business/MusicHub.class b/out/production/spoteezer/musichub/business/MusicHub.class Binary files differnew file mode 100644 index 0000000..e1a0961 --- /dev/null +++ b/out/production/spoteezer/musichub/business/MusicHub.class diff --git a/out/production/spoteezer/musichub/business/NoAlbumFoundException.class b/out/production/spoteezer/musichub/business/NoAlbumFoundException.class Binary files differnew file mode 100644 index 0000000..03aff87 --- /dev/null +++ b/out/production/spoteezer/musichub/business/NoAlbumFoundException.class diff --git a/out/production/spoteezer/musichub/business/NoElementFoundException.class b/out/production/spoteezer/musichub/business/NoElementFoundException.class Binary files differnew file mode 100644 index 0000000..6ba1c87 --- /dev/null +++ b/out/production/spoteezer/musichub/business/NoElementFoundException.class diff --git a/out/production/spoteezer/musichub/business/NoPlayListFoundException.class b/out/production/spoteezer/musichub/business/NoPlayListFoundException.class Binary files differnew file mode 100644 index 0000000..54319de --- /dev/null +++ b/out/production/spoteezer/musichub/business/NoPlayListFoundException.class diff --git a/out/production/spoteezer/musichub/business/PlayList.class b/out/production/spoteezer/musichub/business/PlayList.class Binary files differnew file mode 100644 index 0000000..ea68021 --- /dev/null +++ b/out/production/spoteezer/musichub/business/PlayList.class diff --git a/out/production/spoteezer/musichub/business/Song.class b/out/production/spoteezer/musichub/business/Song.class Binary files differnew file mode 100644 index 0000000..c3bdeb7 --- /dev/null +++ b/out/production/spoteezer/musichub/business/Song.class diff --git a/out/production/spoteezer/musichub/business/SortByAuthor.class b/out/production/spoteezer/musichub/business/SortByAuthor.class Binary files differnew file mode 100644 index 0000000..fb8ee7a --- /dev/null +++ b/out/production/spoteezer/musichub/business/SortByAuthor.class diff --git a/out/production/spoteezer/musichub/business/SortByDate.class b/out/production/spoteezer/musichub/business/SortByDate.class Binary files differnew file mode 100644 index 0000000..c52e870 --- /dev/null +++ b/out/production/spoteezer/musichub/business/SortByDate.class diff --git a/out/production/spoteezer/musichub/business/SortByGenre.class b/out/production/spoteezer/musichub/business/SortByGenre.class Binary files differnew file mode 100644 index 0000000..2016012 --- /dev/null +++ b/out/production/spoteezer/musichub/business/SortByGenre.class diff --git a/out/production/spoteezer/musichub/main/Main.class b/out/production/spoteezer/musichub/main/Main.class Binary files differnew file mode 100644 index 0000000..419fb9c --- /dev/null +++ b/out/production/spoteezer/musichub/main/Main.class diff --git a/out/production/spoteezer/musichub/util/XMLHandler.class b/out/production/spoteezer/musichub/util/XMLHandler.class Binary files differnew file mode 100644 index 0000000..4ab0064 --- /dev/null +++ b/out/production/spoteezer/musichub/util/XMLHandler.class 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()); } |