Package crazyOrb.musikplayer

Source Code of crazyOrb.musikplayer.Soundplayer

package crazyOrb.musikplayer;

import java.io.BufferedInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.AudioDevice;
import javazoom.jl.player.FactoryRegistry;
import javazoom.jl.player.advanced.AdvancedPlayer;

/**
*
* @author Daniel
*/
public class Soundplayer {
    PlayList playList = new PlayList();
    AdvancedPlayer player;
    InputStream input;
    AudioDevice device;

    public boolean setTrack(String trackTitle) {
        try {
            input = this.getClass().getResourceAsStream(playList.getPath(trackTitle));
            BufferedInputStream in = new BufferedInputStream(this.input);
            device = FactoryRegistry.systemRegistry().createAudioDevice();
            this.player = new AdvancedPlayer(in, device);
        } catch (JavaLayerException ex) {
            Logger.getLogger(MPmitMP3.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
        return true;
    }

    public void play(){
        try {
            player.play();
        } catch (JavaLayerException ex) {
            Logger.getLogger(Soundplayer.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
        public ArrayList<String> getTrackPaths() {
        return playList.getTrackPaths();
    }

    public ArrayList<String> getTracks() {
        return playList.getTrackNames();
    }
}
TOP

Related Classes of crazyOrb.musikplayer.Soundplayer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.