Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

Commit

Permalink
Removed JUnit, as it isn't needed.
Browse files Browse the repository at this point in the history
Removed icon.ico, as it is never used.
Minor updates and bugfixes as I tried to build this shit, which still doesn't work outside the IDE.
  • Loading branch information
Adamantcheese committed May 20, 2015
1 parent d0172d0 commit b80a2cc
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 87 deletions.
8 changes: 2 additions & 6 deletions .idea/libraries/Maven__commons_io_commons_io_2_4.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions .idea/libraries/Maven__junit_junit_4_12.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml

This file was deleted.

8 changes: 2 additions & 6 deletions .idea/libraries/Maven__org_jsoup_jsoup_1_8_1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions BCPlayer.iml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" />
<orderEntry type="library" name="Maven: org.jsoup:jsoup:1.8.1" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.soundlibs:jlayer:1.0.1-1" level="project" />
Expand Down
5 changes: 5 additions & 0 deletions META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Manifest-Version: 1.0
Class-Path: lib/jsoup-1.8.1.jar lib/jlayer-1.0.1-1.jar lib/commons-io-
2.4.jar BCPlayer.jar
Main-Class: Main

Binary file removed icon.ico
Binary file not shown.
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
<version>1.0.0</version>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down
19 changes: 11 additions & 8 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.apache.commons.io.FilenameUtils;
import tools.AlbumListUpdater;

import java.io.File;
import java.io.PrintWriter;
import java.util.Scanner;

Expand All @@ -35,7 +36,7 @@ public void handle (WindowEvent event) {
}

public static void writeTrackFile () throws Exception {
Scanner tempScanner = new Scanner(Constants.getInternalTrackFile());
Scanner tempScanner = new Scanner(new File(Main.class.getResource("tracks.nll").toURI()));
PrintWriter tempWriter = new PrintWriter(Constants.TRACK_FILE);
while (tempScanner.hasNextLine()) {
tempWriter.println(tempScanner.nextLine());
Expand All @@ -45,8 +46,11 @@ public static void writeTrackFile () throws Exception {
}

public static void main (String[] args) throws Exception {
boolean forceUpdate = false;
//If the user specified a file, make sure it has the right extension
if (args.length == 1 && FilenameUtils.getExtension(args[0]) != "nll") {
if(args.length == 1 && args[0].equals("--forcelist")) {
forceUpdate = true;
} else if (args.length == 1 && FilenameUtils.getExtension(args[0]) != "nll") {
System.err.println("File should have extension nll, with one URL per line.");
return;
}
Expand All @@ -59,21 +63,20 @@ public static void main (String[] args) throws Exception {
//Copy the internal track file to the temp directory, or expand the one specified to the temp directory
if (!Constants.TRACK_FILE.exists()) {
if (args.length == 1) {
System.out.println("Warning: The operation may take upwards of 30 minutes to finish, do you want to continue? (Y/N)");
System.out.println("Warning: The operation may take a while to finish, do you want to continue? (Y/N)");
Scanner keyboard = new Scanner(System.in);
String ans = "";
while (!(ans.equals("y") || ans.equals("n"))) {
ans = keyboard.nextLine().toLowerCase();
}
if (ans.equals("n")) {
writeTrackFile();
} else {
if (ans.equals("y")) {
AlbumListUpdater.update(args[0]);
}
} else {
writeTrackFile();
}
} else if (forceUpdate) {
Constants.TRACK_FILE.delete();
}
writeTrackFile();

//Launch the application
launch(args);
Expand Down
37 changes: 13 additions & 24 deletions src/main/java/boot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
* Created by Jacob on 3/22/2015.
Expand All @@ -20,16 +19,6 @@ public class Constants {

public static final File BASE_DIR = new File(BASE_TEMP_DIR);
public static final File TRACK_FILE = new File(TRACK_FILE_DIR);
private static File INTERNAL_TRACK_FILE = null;

public static File getInternalTrackFile () throws Exception {
if (INTERNAL_TRACK_FILE == null) {
INTERNAL_TRACK_FILE = new File(Constants.class.getResource("../tracks.nll").toURI());
}
return INTERNAL_TRACK_FILE;
}

public static final Random RANDOMIZER = new Random();

private static TrackContainer TRACK_HELPER = null;

Expand All @@ -40,6 +29,19 @@ public static TrackContainer getTrackHelper () throws Exception {
return TRACK_HELPER;
}

private static HostServicesDelegate HOST_SERVICES = null;

public static HostServicesDelegate getHostServices() {
if(HOST_SERVICES == null) {
throw new IllegalAccessError();
}
return HOST_SERVICES;
}

public static void setHostServices(HostServicesDelegate hsd) {
HOST_SERVICES = hsd;
}

private static URL DEFAULT_COVER = null;

public static URL getDefaultCover () {
Expand Down Expand Up @@ -83,17 +85,4 @@ public static List<Image> getIcons() {
}
return ICONS;
}

private static HostServicesDelegate HOST_SERVICES = null;

public static HostServicesDelegate getHostServices() {
if(HOST_SERVICES == null) {
throw new IllegalAccessError();
}
return HOST_SERVICES;
}

public static void setHostServices(HostServicesDelegate hsd) {
HOST_SERVICES = hsd;
}
}
4 changes: 3 additions & 1 deletion src/main/java/boot/Controller.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package boot;

import constructs.PlayerContainer;
import javafx.application.HostServices;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
Expand All @@ -22,6 +21,9 @@ public class Controller implements Initializable {
private PlayerContainer playerContainer;
private InfoWatcher infoWatcher;

private Track prevTrack;
private Track nextTrack;

@FXML
private void playPause () {
playerContainer.pauseToggle();
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/constructs/PlayerContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
public class PlayerContainer extends Thread {

private Player player;
private boolean hoursLong;

public PlayerContainer (Track track) throws Exception {
player = new Player(track.getTrackURL().openStream());
hoursLong = (track.getDuration().split(":").length == 3);
}

public void run () {
Expand Down Expand Up @@ -45,10 +47,11 @@ public boolean isPaused () {
public String getCurrentTime () {
String dur = "";
int duration = player.getPosition();
int hours = (int) (duration / 1000 / 60 / 60);
int minutes = (int) (duration / 1000 / 60) - hours * 60;
int seconds = (int) (duration / 1000) - minutes * 60;
if (hours > 0) {
int hours = duration / 1000 / 60 / 60;
int minutes = duration / 1000 / 60 - hours * 60;
int seconds = duration / 1000 - minutes * 60 - hours * 3600;
//If the track's duration contains hours, we add hours to the current time counter
if (hoursLong) {
dur += String.format("%02d:", hours);
}
dur += String.format("%02d:%02d", minutes, seconds);
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/constructs/TrackContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.net.SocketTimeoutException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand All @@ -22,6 +23,7 @@
public class TrackContainer {

private ArrayList<String> TRACK_LIST;
private Random RANDOMIZER;

private final Pattern TRACK_NAME = Pattern.compile("\"title\":\".*?\"");
private final Pattern ARTIST_NAME = Pattern.compile("artist: \".*?\",");
Expand All @@ -33,6 +35,9 @@ public TrackContainer () throws Exception {
//Init the album list
TRACK_LIST = new ArrayList<String>(15000);

//Init randomizer
RANDOMIZER = new Random();

//Internalize the track file
Scanner albumScanner = new Scanner(Constants.TRACK_FILE);
while (albumScanner.hasNextLine()) {
Expand All @@ -44,7 +49,7 @@ public TrackContainer () throws Exception {

public Track getRandomSong () {
//Grab a random track URL
String URL = TRACK_LIST.get(Constants.RANDOMIZER.nextInt(TRACK_LIST.size()));
String URL = TRACK_LIST.get(RANDOMIZER.nextInt(TRACK_LIST.size()));

//Get the track HTML document
Document doc = null;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/objects/Track.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ public String getDuration () {
return duration;
}

public String setDuration (double d) {
private String setDuration (double d) {
String dur = "";
int hours = (int) (d / 60 / 60);
int minutes = (int) (d / 60) - hours * 60;
int seconds = (int) (d) - minutes * 60;
int seconds = (int) (d) - minutes * 60 - hours * 3600;
if (hours > 0) {
dur += String.format("%02d:", hours);
}
Expand Down

0 comments on commit b80a2cc

Please sign in to comment.