diff options
49 files changed, 138 insertions, 5 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/Song/Side_To_Side.wav b/Song/Side_To_Side.wav Binary files differnew file mode 100644 index 0000000..3c874db --- /dev/null +++ b/Song/Side_To_Side.wav 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/files/albums.xml b/files/albums.xml index edfd610..edb2a94 100644 --- a/files/albums.xml +++ b/files/albums.xml @@ -12,6 +12,7 @@ <UUID>b2ee0ca0-b5e2-4bc9-8fed-7932fb145f2f</UUID> <UUID>bbe99998-1be6-4a40-8bf0-6a7fce9087c9</UUID> <UUID>66d277ca-cbc4-471c-a07e-082363375bcc</UUID> + <UUID>44136020-dc80-4522-9b71-2b9aad5e3039</UUID> </songs> </album> <album> @@ -22,6 +23,7 @@ <date>1978-01-23</date> <songs> <UUID>44136020-dc80-4522-9b71-2b9aad5e3039</UUID> + <UUID>66d277ca-cbc4-471c-a07e-082363375bcc</UUID> </songs> </album> </albums>
\ No newline at end of file diff --git a/files/elements.xml b/files/elements.xml index 7fefc5f..553f228 100644 --- a/files/elements.xml +++ b/files/elements.xml @@ -9,11 +9,11 @@ <genre>pop</genre> </song> <song> - <title>I Want to Hold your Hand</title> - <artist>The Beatles</artist> + <title>Side To Side</title> + <artist>Ariana Grande</artist> <length>186</length> <UUID>66d277ca-cbc4-471c-a07e-082363375bcc</UUID> - <content>i_want_to_hold_your_hand.mp3</content> + <content>Song/Side_To_Side.wav</content> <genre>rock</genre> </song> <song> 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 e0a686b..0c1e9e4 100644 --- a/src/musichub/business/AudioElement.java +++ b/src/musichub/business/AudioElement.java @@ -3,8 +3,17 @@ package musichub.business; import org.w3c.dom.Document; 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; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Clip; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.UnsupportedAudioFileException; + public abstract class AudioElement { protected String title; protected String artist; @@ -84,5 +93,40 @@ public abstract class AudioElement { parentElement.appendChild(contentElement); } + + 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); + + 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 38e2214..f7cf137 100644 --- a/src/musichub/business/MusicHub.java +++ b/src/musichub/business/MusicHub.java @@ -6,8 +6,12 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import java.io.IOException; import java.util.*; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.UnsupportedAudioFileException; + class SortByDate implements Comparator<Album> { public int compare(Album a1, Album a2) { return a1.getDate().compareTo(a2.getDate()); @@ -326,4 +330,13 @@ public class MusicHub { } xmlHandler.createXMLFile(document, ELEMENTS_FILE_PATH); } + + public void getAudioElement(List<AudioElement> audios, String elementTitle) throws NoAlbumFoundException, UnsupportedAudioFileException, IOException, LineUnavailableException { + for (AudioElement el : audios) { + if (el.getTitle().equalsIgnoreCase(elementTitle)) { + el.manageAudioElement(); + } + } + + } }
\ No newline at end of file diff --git a/src/musichub/business/Song.java b/src/musichub/business/Song.java index 3e9011b..564b7c5 100644 --- a/src/musichub/business/Song.java +++ b/src/musichub/business/Song.java @@ -53,4 +53,6 @@ public class Song extends AudioElement { parentElement.appendChild(song); } + + }
\ No newline at end of file diff --git a/src/musichub/main/Main.java b/src/musichub/main/Main.java index b72a95b..2876734 100644 --- a/src/musichub/main/Main.java +++ b/src/musichub/main/Main.java @@ -2,11 +2,16 @@ package musichub.main; import musichub.business.*; +import java.io.IOException; import java.util.Iterator; +import java.util.List; import java.util.Scanner; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.UnsupportedAudioFileException; + public class Main { - public static void main(String[] args) { + public static void main(String[] args) throws UnsupportedAudioFileException, IOException, LineUnavailableException { MusicHub theHub = new MusicHub(); @@ -41,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()); } @@ -55,7 +61,10 @@ public class Main { albumTitle = scan.nextLine(); try { + List<AudioElement> songs = theHub.getAlbumSongs(albumTitle); System.out.println(theHub.getAlbumSongs(albumTitle)); + String song = scan.nextLine(); + theHub.getAudioElement(songs, song); } catch (NoAlbumFoundException ex) { System.out.println("No album found with the requested title " + ex.getMessage()); } |