Skip to content

Commit

Permalink
0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpiz097 committed May 13, 2018
1 parent eea328c commit 45d43df
Show file tree
Hide file tree
Showing 36 changed files with 691 additions and 457 deletions.
660 changes: 396 additions & 264 deletions .idea/workspace.xml

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions OrangePlayer.iml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,23 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../ithaka-audioinfo/out/artifacts/ithaka_audioinfo_jar/ithaka-audioinfo.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../../javaLibs/Music/jaudiotagger-2.0.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ Music player library in pure Java.
abstracto de la clase padre Track
## Se añade opcion de ver tiempo actual de la cancion
## Se añade opcion de dirigirse a un segundo especifico de la cancion (No disponible correctamente en archivos FLAC y M4A)
# 0.6.1 Beta
## Se añade funcion para agregar más musica al reproductor

## 0.7
## Se logra obtener duracion de archivos de audio para todos los formatos disponibles
## Se añade opcion para obtener la caratula de un archivo de audio cualquiera
Binary file modified bin/OrangePlayer.jar
Binary file not shown.
Binary file not shown.
Binary file modified out/production/OrangePlayer/org/orangeplayer/audio/Player.class
Binary file not shown.
Binary file not shown.
Binary file modified out/production/OrangePlayer/org/orangeplayer/audio/Track.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
46 changes: 46 additions & 0 deletions src/org/orangeplayer/audio/AudioInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.orangeplayer.audio;

import org.jaudiotagger.audio.AudioFile;
import org.jaudiotagger.audio.AudioFileIO;
import org.jaudiotagger.audio.AudioHeader;
import org.jaudiotagger.audio.exceptions.CannotReadException;
import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException;
import org.jaudiotagger.audio.exceptions.ReadOnlyFileException;
import org.jaudiotagger.tag.FieldKey;
import org.jaudiotagger.tag.Tag;
import org.jaudiotagger.tag.TagException;
import org.jaudiotagger.tag.images.Artwork;

import java.io.File;
import java.io.IOException;

public class AudioInfo {
private AudioFile audioFile;
private Tag fileTag;
private AudioHeader header;

public AudioInfo(File sound)
throws TagException, ReadOnlyFileException,
CannotReadException, InvalidAudioFrameException, IOException {
this.audioFile = AudioFileIO.read(sound);
fileTag = audioFile.getTag();
header = audioFile.getAudioHeader();
}

public String getTag(FieldKey tag) {
return fileTag.getFirst(tag);
}

public String getTag(String tagName) {
return getTag(FieldKey.valueOf(tagName.toUpperCase()));
}

public int getDuration() {
return header.getTrackLength();
}

public Artwork getCover() {
return fileTag.getFirstArtwork();
}

}
85 changes: 70 additions & 15 deletions src/org/orangeplayer/audio/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class Player extends Thread implements PlayerControls {
Expand Down Expand Up @@ -43,7 +44,16 @@ public static Player getPlayer() {
return player;
}*/

private Player(File rootFolder) throws FileNotFoundException {
public Player() {
this.rootFolder = rootFolder;
listSoundPaths = new ArrayList<>();
listListeners = new ArrayList<>();
trackIndex = 0;
currentVolume = DEFAULT_VOLUME;
on = false;
setName("ThreadPlayer "+getId());
}
public Player(File rootFolder) throws FileNotFoundException {
this.rootFolder = rootFolder;
listSoundPaths = new ArrayList<>();
listListeners = new ArrayList<>();
Expand Down Expand Up @@ -71,7 +81,7 @@ public Player(String folderPath) throws FileNotFoundException {

private void loadTracks(File folder) {
File[] fldFiles = folder.listFiles();
File f;
File f = null;
if (fldFiles != null)
for (int i = 0; i < fldFiles.length; i++) {
f = fldFiles[i];
Expand All @@ -83,12 +93,11 @@ private void loadTracks(File folder) {
}

private void loadTracks(List<File> listFiles) {
listSoundPaths.clear();
trackIndex = 0;

// Se supone que todos son archivos
listFiles.stream().forEach((f)->{
if (!f.isDirectory())
listFiles.stream().forEach(f->{
if (f.isDirectory())
loadTracks(f);
else
listSoundPaths.add(f.getPath());
});
}
Expand Down Expand Up @@ -213,7 +222,12 @@ private void changeTrack() {
current.finish();
}

private void waitForSongs() {
while (on && getSongsCount() == 0);
}

void loadNextTrack() {
waitForSongs();
Track cur = current;
current = getNextTrack();
finishTrack(cur);
Expand All @@ -223,15 +237,12 @@ void loadNextTrack() {
System.out.println(current.getInfoSong());
}



// Test
public void jumpTrack(int jumps) {
if (jumps > 0)
trackIndex+=(--jumps);
else {
else
trackIndex-=jumps;
}
if (trackIndex >= listSoundPaths.size())
trackIndex = 0;
else if (trackIndex < 0)
Expand Down Expand Up @@ -297,25 +308,71 @@ public boolean isFinished() {
return current == null ? false : current.isFinished();
}

@Override
public void open(File sound) {

listSoundPaths.clear();
listSoundPaths.add(sound.getPath());
if (isPlaying())
playNext();
else if (isAlive())
play();
else
start();
}

@Override
public void open(List<File> listSounds) {
listSounds.clear();
loadTracks(listSounds);
sortTracks();
/*
// Ver si el thread no es nulo
if (current != null && currentThread.isAlive()) {
current.kill();
current = getTrack(trackIndex, true);
currentThread = new Thread(current);
currentThread.start();
}
*/
}

public int getCurrentProgress() {
@Override
public void addMusic(List<File> listSounds) {
if (!listSounds.isEmpty()) {
if (listSounds instanceof LinkedList) {
listSounds.stream().forEach(sound->{
if (sound.isDirectory())
loadTracks(sound);
else
listSoundPaths.add(sound.getPath());
});
}
else {
File sound = null;
for (int i = 0; i < listSounds.size(); i++) {
sound = listSounds.get(i);
if (sound.isDirectory())
loadTracks(sound);
else
listSoundPaths.add(sound.getPath());
}
}
}
sortTracks(); }

@Override
public void addMusic(File musicFolder) {
loadTracks(musicFolder);
sortTracks();
}

public int getTrackProgress() {
return current.getProgress();
}

public int getSongsCount() {
return listSoundPaths.size();
}
@Override
public void play() {
if (!isAlive())
Expand Down Expand Up @@ -411,8 +468,6 @@ public void shutdown() {
loadListenerMethod("onShutdown", null);
}



@Override
public void run() {
PlayerHandler.setInstance(this);
Expand Down
88 changes: 0 additions & 88 deletions src/org/orangeplayer/audio/Player2.java

This file was deleted.

Loading

0 comments on commit 45d43df

Please sign in to comment.