当前位置: 首页>>代码示例>>Java>>正文


Java Player类代码示例

本文整理汇总了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 {
	}
}
 
开发者ID:tadeuespindolapalermo,项目名称:ShowMilhaoPOOJava,代码行数:22,代码来源:JLayer.java

示例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();
			}
		}
	});
}
 
开发者ID:RPTools,项目名称:rplib,代码行数:19,代码来源:SoundPlayer.java

示例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());
	}
}
 
开发者ID:beargrllys,项目名称:OverTale,代码行数:12,代码来源:Music.java

示例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();
                }
            }
        });
    }
 
开发者ID:pogostick29dev,项目名称:RPG29,代码行数:27,代码来源:AudioPlayer.java

示例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);
    }
}
 
开发者ID:IzzelAliz,项目名称:LCL,代码行数:10,代码来源:GameMusic.java

示例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");
	}
}
 
开发者ID:xnx3,项目名称:xnx3,代码行数:14,代码来源:MP3Play.java

示例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();
    }
}
 
开发者ID:lnwazg,项目名称:kit,代码行数:20,代码来源:AudioMgr.java

示例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;
}
 
开发者ID:obernardovieira,项目名称:vucor,代码行数:36,代码来源:Model.java

示例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();
    }
 
开发者ID:xiaomin0322,项目名称:alimama,代码行数:8,代码来源:AudioPlayer.java

示例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);
    }
}
 
开发者ID:Martin-Dames,项目名称:Tingeltangel,代码行数:10,代码来源:MP3Player.java

示例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) {
    }
}
 
开发者ID:MitchTalmadge,项目名称:TheAmericanLife,代码行数:16,代码来源:AudioThread.java

示例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();
		}
	}
}
 
开发者ID:dstumpff,项目名称:VortexGameLibrary,代码行数:19,代码来源:BackgroundMusic.java

示例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();
	}
}
 
开发者ID:Dakror,项目名称:Anna,代码行数:9,代码来源:Reaction.java

示例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);
    }

}
 
开发者ID:xNovax,项目名称:Multiplication_Dungeon,代码行数:12,代码来源:Mp3Player.java

示例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();
}
 
开发者ID:gjkf,项目名称:HeadPhones-Radio,代码行数:14,代码来源:URLConnection.java


注:本文中的javazoom.jl.player.Player类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。