Skip to content

Commit

Permalink
Minor fixes to plmp3
Browse files Browse the repository at this point in the history
  • Loading branch information
marigostra committed Jun 14, 2022
1 parent 2720673 commit 6231112
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions plmp3/src/main/java/org/luwrain/extensions/plmp3/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@
import java.net.*;
import java.util.*;
import java.util.concurrent.*;
import javax.sound.sampled.*;

import javazoom.jl.player.advanced.*;
import javazoom.jl.decoder.*;
import javazoom.jl.player.*;

import org.luwrain.core.*;

Expand Down Expand Up @@ -58,16 +55,12 @@ final class Instance implements org.luwrain.core.MediaResourcePlayer.Instance
finishing = false;
task = new FutureTask<>(()->{
try {
// AudioInputStream stream = null;
InputStream stream = null;
// InputStream is = null;
try {
long currentFrame = 0;
float currentPosition = 0;
long lastNotifiedMsec = 0;
final BufferedInputStream bufferedIn = new BufferedInputStream(url.openStream());
stream = bufferedIn;
// stream = AudioSystem.getAudioInputStream(bufferedIn);
// final AudioFormat bitFormat = stream.getFormat();
try (final InputStream is = new BufferedInputStream(url.openStream())){
device = new CustomDevice(params.volume);
if(device==null)
{
Expand All @@ -77,7 +70,7 @@ final class Instance implements org.luwrain.core.MediaResourcePlayer.Instance
}
final Decoder decoder=new Decoder();
device.open(decoder);
final Bitstream bitstream = new Bitstream(stream);
final Bitstream bitstream = new Bitstream(is);
while(currentPosition < params.playFromMsec)
{
final Header frame = bitstream.readFrame();
Expand Down Expand Up @@ -115,13 +108,12 @@ final class Instance implements org.luwrain.core.MediaResourcePlayer.Instance
}
bitstream.closeFrame();
} //playing
}
}
finally
{
if(device != null)
device.close();
if(stream != null)
stream.close();
finishing = true;
listener.onPlayerFinish(Instance.this);
}
Expand Down

0 comments on commit 6231112

Please sign in to comment.