简体   繁体   中英

MP3 Player, play button has no sound

I'm trying to get an mp3 play button to work using JLayer. I get no errors but it doesn't play any sound. I added all the required jar files to the library and followed many tutorials so the code should work but I just don't get any sound. (P/S: I don't have an mp3 plugin)

try
{
    JOptionPane.showMessageDialog(null,"Trying");
    FIS = new FileInputStream("C:\\Users\\Jun\\Documents\\NetBeansProjects\\Player\\src\\Songs\\NumaNuma.mp3");
    BIS = new BufferedInputStream(FIS);

    playSong = new javazoom.jl.player.Player(BIS);
    playSong.play();
}
catch(FileNotFoundException | JavaLayerException e)
{
    JOptionPane.showMessageDialog(null,"Error Occured " + e);
}

new Thread()
{
    @Override
    public void run()
    {
        try 
        {
            playSong.play();
        } 
        catch (JavaLayerException ex) {
            JOptionPane.showMessageDialog(null,"Error Occured " + ex);
        }
    }
}.start();

The player works now. I was trying to play an mp4 that I renamed as an mp3 not fully realising that that wouldn't work until I used an actual mp3 song.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM