本文整理匯總了Java中javazoom.jl.decoder.JavaLayerException類的典型用法代碼示例。如果您正苦於以下問題:Java JavaLayerException類的具體用法?Java JavaLayerException怎麽用?Java JavaLayerException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JavaLayerException類屬於javazoom.jl.decoder包,在下文中一共展示了JavaLayerException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: play
import javazoom.jl.decoder.JavaLayerException; //導入依賴的package包/類
private static void play(final Player player) {
playerCount.incrementAndGet();
//Not sure how to use Future here?
Future<?> f = playerThreadPool.submit(new Runnable() {
public void run() {
try {
player.play();
playerCount.decrementAndGet();
synchronized (playerCount) {
playerCount.notify();
}
} catch (JavaLayerException jle) {
jle.printStackTrace();
}
}
});
}
示例2: testPlay
import javazoom.jl.decoder.JavaLayerException; //導入依賴的package包/類
public void testPlay()
{
String[] args = new String[1];
args[0] = filename;
jlp player = jlp.createInstance(args);
try
{
player.play();
assertTrue("Play",true);
}
catch (JavaLayerException e)
{
e.printStackTrace();
assertTrue("JavaLayerException : "+e.getMessage(),false);
}
}
示例3: Player
import javazoom.jl.decoder.JavaLayerException; //導入依賴的package包/類
public Player(InputStream stream, AudioDevice device) throws JavaLayerException
{
bitstream = new Bitstream(stream);
decoder = new Decoder();
if (device!=null)
{
audio = device;
}
else
{
FactoryRegistry r = FactoryRegistry.systemRegistry();
audio = r.createAudioDevice();
}
audio.open(decoder);
}
示例4: play
import javazoom.jl.decoder.JavaLayerException; //導入依賴的package包/類
/**
* Plays a number of MPEG audio frames.
*
* @param frames The number of frames to play.
* @return true if the last frame was played, or false if there are
* more frames.
*/
public boolean play(int frames) throws JavaLayerException
{
boolean ret = true;
while (frames-- > 0 && ret)
{
ret = decodeFrame();
}
if (!ret)
{
// last frame, ensure all data flushed to the audio device.
AudioDevice out = audio;
if (out!=null)
{
out.flush();
synchronized (this)
{
complete = (!closed);
close();
}
}
}
return ret;
}
示例5: test
import javazoom.jl.decoder.JavaLayerException; //導入依賴的package包/類
/**
* Runs a short test by playing a short silent sound.
*/
public void test()
throws JavaLayerException
{
try
{
open(new AudioFormat(22050, 16, 1, true, false));
short[] data = new short[22050/10];
write(data, 0, data.length);
flush();
close();
}
catch (RuntimeException ex)
{
throw new JavaLayerException("Device test failed: "+ex);
}
}
示例6: playMp3
import javazoom.jl.decoder.JavaLayerException; //導入依賴的package包/類
public static AdvancedPlayer playMp3(final InputStream is, final int start, final int end, PlaybackListener listener) throws JavaLayerException
{
final AdvancedPlayer player = new AdvancedPlayer(is);
player.setPlayBackListener(listener);
// run in new thread
new Thread()
{
public void run()
{
try
{
player.play(start, end);
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage());
}
}
}.start();
return player;
}
示例7: start
import javazoom.jl.decoder.JavaLayerException; //導入依賴的package包/類
/**
* Starts this applet. An input stream and audio device
* are created and passed to the play() method.
*/
public void start()
{
String name = getAudioFileName();
try
{
InputStream in = getAudioStream();
AudioDevice dev = getAudioDevice();
play(in, dev);
}
catch (JavaLayerException ex)
{
synchronized (System.err)
{
System.err.println("Unable to play "+name);
ex.printStackTrace(System.err);
}
}
}
示例8: speak
import javazoom.jl.decoder.JavaLayerException; //導入依賴的package包/類
public static synchronized void speak(String text) {
/*
Thread safe method for Text to Speech.
*/
new Thread(
() -> {
try {
synthesiserV2.setSpeed(0.955f);
System.out.println("{->} Speaking : " + text);
AdvancedPlayer advancedPlayer = new AdvancedPlayer(synthesiserV2.getMP3Data(text));
advancedPlayer.play();
} catch (IOException | JavaLayerException exception) {
System.out.println("{X} Exception in TTS. ");
System.out.println(exception.getMessage());
}
}
).start();
}
示例9: play
import javazoom.jl.decoder.JavaLayerException; //導入依賴的package包/類
@Override
public void play(Song song, SongAudio songAudio) {
this.currentSong = song;
RenderedSong renderedSong = songPersistenceService.getRenderedSongById(song.getId()).orElse(new RenderedSong());
this.renderedChannelMap = new Gson().fromJson(renderedSong.getRenderData(), RenderedChannelMap.class);
try {
FactoryRegistry r = FactoryRegistry.systemRegistry();
audioDevice = r.createAudioDevice();
ByteArrayInputStream inputStream = new ByteArrayInputStream(songAudio.getAudioData());
AdvancedPlayer player = new AdvancedPlayer(inputStream, audioDevice);
player.setPlayBackListener(playbackListener);
player.play();
} catch (JavaLayerException e) {
e.printStackTrace();
}
}
示例10: setPlaylistAndMusic
import javazoom.jl.decoder.JavaLayerException; //導入依賴的package包/類
public void setPlaylistAndMusic(Playlist playlist, String music_name)
{
model.getDataModel().getPlaylists().forEach((playlist_) ->
{
playlist_.getNames().forEach((name_) ->
{
if(name_.equals(music_name))
{
model.stopMusic();
model.changeToPlaylist(playlist_.getPlaylistName());
model.getDataModel().getCurrentPlaylist().setOnMusic(music_name);
try
{
model.playMusic();
}
catch (JavaLayerException | IOException ex)
{ }
}
});
});
}
示例11: write
import javazoom.jl.decoder.JavaLayerException; //導入依賴的package包/類
@Override
public void write(short[] paramArrayOfShort, int paramInt1, int paramInt2) throws JavaLayerException {
if (gain == 1.0) {
// default behavior
super.write(paramArrayOfShort, paramInt1, paramInt2);
} else {
// so some digital signal processing!!! woot!
//System.out.print(".");
short[] volumeAdjusted = new short[paramArrayOfShort.length];
for (int i = 0 ; i < paramArrayOfShort.length ; i++) {
// Multiplication is volume control! amplify the signal by the gain
// EEK that's a lot of type casting!
volumeAdjusted[i] = (short)(((float)paramArrayOfShort[i])*gain);
}
// pass the volume adjusted array to the underlying audio device
super.write(volumeAdjusted, paramInt1, paramInt2);
}
}
示例12: play
import javazoom.jl.decoder.JavaLayerException; //導入依賴的package包/類
/**
* Starts playback (resumes if paused)
*/
public void play() throws JavaLayerException {
synchronized (playerLock) {
switch (playerStatus) {
case NOT_STARTED:
final Runnable r = new Runnable() {
public void run() {
playInternal();
}
};
final Thread t = new Thread(r);
t.setDaemon(true);
t.setPriority(Thread.MAX_PRIORITY);
playerStatus = PLAYING;
t.start();
break;
case PAUSED:
resume();
break;
default:
break;
}
}
}
示例13: convertMP3toWAV
import javazoom.jl.decoder.JavaLayerException; //導入依賴的package包/類
public static File convertMP3toWAV(File mp3){
File temp=null;
try {
temp = File.createTempFile(mp3.getName().split("\\.")[0],".wav");
temp.deleteOnExit();
} catch (IOException e1) {
e1.printStackTrace();
}
Converter converter = new Converter();
try {
converter.convert(mp3.getAbsolutePath(), temp.getAbsolutePath());
} catch (JavaLayerException e) {
e.printStackTrace();
}
return temp;
}
示例14: play
import javazoom.jl.decoder.JavaLayerException; //導入依賴的package包/類
/**
* Plays the loaded song or does nothing if song is not loaded.
*
* @param flag Modifier to loop or not (use BackgroundMusic.LOOP_CONTINUOUSLY to loop or anything else to play once)
* @throws JavaLayerException
*/
public static void play(int flag) throws JavaLayerException{
synchronized(playerLock){
switch(playerStatus){
case LOADED:
stopPlaying = false;
final Runnable r = new Runnable(){
public void run(){
playInternal(flag);
}
};
final Thread t = new Thread(r);
t.setDaemon(true);
t.setPriority(Thread.MAX_PRIORITY);
playerStatus = PLAYING;
t.start();
break;
case PAUSED:
resume();
break;
default:
break;
}
}
}
示例15: convert
import javazoom.jl.decoder.JavaLayerException; //導入依賴的package包/類
public void convert(String sourceName, String destName,
ProgressListener progressListener, Decoder.Params decoderParams)
throws JavaLayerException
{
if (destName.length()==0)
destName = null;
try {
InputStream in = openInput(sourceName);
convert(in, destName, progressListener, decoderParams);
in.close();
} catch(IOException ioe) {
throw new JavaLayerException(ioe.getLocalizedMessage(), ioe);
}
}