本文整理汇总了Java中javazoom.jl.player.Player类的典型用法代码示例。如果您正苦于以下问题:Java Player类的具体用法?Java Player怎么用?Java Player使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Player类属于javazoom.jl.player包,在下文中一共展示了Player类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import javazoom.jl.player.Player; //导入依赖的package包/类
/**
* METODO RUN QUE TOCA O MP3
*/
public void run() {
try {
FileInputStream fis = new FileInputStream(mp3);
BufferedInputStream bis = new BufferedInputStream(fis);
this.player = new Player(bis);
// System.out.println("Tocando Musica!"); // DEBUG NO CONSOLE
this.player.play();
// System.out.println("Terminado Musica!"); // DEBUG NO CONSOLE
if (this.player.isComplete()) {
this.player.close();
}
} catch (Exception e) {
// System.out.println("Problema ao tocar Musica" + mp3); // DEBUG NO CONSOLE
e.printStackTrace();
} finally {
}
}
示例2: play
import javazoom.jl.player.Player; //导入依赖的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();
}
}
});
}
示例3: Music
import javazoom.jl.player.Player; //导入依赖的package包/类
public Music(String name, boolean isloop){
try{
this.isloop = isloop;
file = new File(Main2.class.getResource("../music/"+ name).toURI());
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
player = new Player(bis);
}catch(Exception e){
System.out.println(e.getMessage());
}
}
示例4: playMusic
import javazoom.jl.player.Player; //导入依赖的package包/类
public static void playMusic(final Music music) {
ThreadUtil.runThreadInBackground(new Runnable() {
@Override
public void run() {
try {
/*
JLayer Audio Player
*/
Player player = new Player(ResourceUtil.getInstance().getResourceAsStream(music.getPath()));
player.play();
player.close();
/*
JavaFX Audio Player
*/
// Media media = new Media(ResourceUtil.getInstance().getResource(music.getPath()).toExternalForm());
// MediaPlayer player = new MediaPlayer(media);
// player.setCycleCount(Integer.MAX_VALUE);
// player.setVolume(.5);
// player.play();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
示例5: play
import javazoom.jl.player.Player; //导入依赖的package包/类
public void play() {
try {
BufferedInputStream buffer = new BufferedInputStream(new FileInputStream(filename));
player = new Player(buffer);
player.play();
} catch (Exception e) {
System.out.println(e);
}
}
示例6: MP3Play
import javazoom.jl.player.Player; //导入依赖的package包/类
/**
* @param filePath MP3文件的绝对路径,如 E:/xnx3/test.mp3
* @throws JavaLayerException
* @throws FileNotFoundException
*/
public MP3Play(String filePath) throws JavaLayerException, FileNotFoundException {
if(FileUtil.exists(filePath)){
BufferedInputStream buffer = new BufferedInputStream(new FileInputStream(filePath));
player = new Player(buffer);
}else{
throw new FileNotFoundException(filePath+" is not exists");
}
}
示例7: playAudio
import javazoom.jl.player.Player; //导入依赖的package包/类
/**
* 播放音频文件<br>
* 可以播放MP3
* @author nan.li
* @param audioFile
*/
public static void playAudio(File audioFile)
{
try
{
BufferedInputStream buffer = new BufferedInputStream(new FileInputStream(audioFile));
Player player = new Player(buffer);
player.play();
}
catch (Exception e)
{
e.printStackTrace();
}
}
示例8: playMusic
import javazoom.jl.player.Player; //导入依赖的package包/类
public void playMusic()
throws FileNotFoundException, JavaLayerException, IOException
{
if( dataModel.getOnPlaylist() == -1 ||
dataModel.getCurrentPlaylist().getNames().isEmpty())
{
throw new IOException();
}
if(isPlaying) return;
fis = new FileInputStream(dataModel.getCurrentPlaylist().getCurrentPath());
bis = new BufferedInputStream(fis);
player = new Player(bis);
totalFrames = fis.available();
thread_music = new Thread()
{
@Override
public void run()
{
try
{
player.play();
if(isPlaying == true)
{
autoNextMusic();
}
}
catch (JavaLayerException | IOException ex) { }
}
};
thread_music.start();
isPlaying = true;
}
示例9: play
import javazoom.jl.player.Player; //导入依赖的package包/类
public void play() throws FileNotFoundException, JavaLayerException {
BufferedInputStream buffer =
new BufferedInputStream(new FileInputStream(music));
player = new Player(buffer);
player.play();
}
示例10: play
import javazoom.jl.player.Player; //导入依赖的package包/类
public void play(File file, Callback<Exception> onError) throws FileNotFoundException {
try {
stop();
player = new Player(new FileInputStream(file));
player.play();
} catch(JavaLayerException e) {
onError.callback(e);
}
}
示例11: run
import javazoom.jl.player.Player; //导入依赖的package包/类
@Override
public void run() {
try {
Thread.sleep(100);
for (String audioPath : audioPaths) {
player = new Player(getClass().getResourceAsStream(audioPath));
while (player.play(1))
if (paused.get())
LockSupport.park();
}
} catch (JavaLayerException e) {
e.printStackTrace();
} catch (InterruptedException ignored) {
}
}
示例12: loadSong
import javazoom.jl.player.Player; //导入依赖的package包/类
/**
* Load a song to play.
*
* @param path The path of the song
*/
public static void loadSong(String path){
if(playerStatus == NOT_STARTED || playerStatus == FINISHED){
ClassLoader loader = Thread.currentThread().getContextClassLoader();
InputStream fis = loader.getResourceAsStream(path);
lastPlayedSong = path;
try {
thePlayer = new Player(fis);
playerStatus = LOADED;
}catch(JavaLayerException e){
e.printStackTrace();
}
}
}
示例13: respond
import javazoom.jl.player.Player; //导入依赖的package包/类
public static void respond(String text) {
try {
Game.currentGame.player = new Player(Game.currentGame.synthesiser.getMP3Data(text)/* , new VisualEffectDevice(new JavaSoundAudioDeviceFactory().createAudioDevice()) */);
Game.currentGame.player.play();
} catch (Exception e) {
e.printStackTrace();
}
}
示例14: play
import javazoom.jl.player.Player; //导入依赖的package包/类
public void play() {
try {
BufferedInputStream buffer = new BufferedInputStream(new FileInputStream(filename));
player = new Player(buffer);
player.play();
} catch (Exception e) {
System.out.println(e);
}
}
示例15: init
import javazoom.jl.player.Player; //导入依赖的package包/类
public void init() throws MalformedURLException, IOException, JavaLayerException{
if(!checkConnection()){
urlConnection = new URL(url).openConnection();
System.err.println(urlConnection.toString());
}
if(!checkPlayer()){
player = new Player (urlConnection.getInputStream());
System.err.println(player.toString());
}
connect();
begin();
pc = new PauseControl();
}