Home What causes an array error in JMF
Reply: 0

What causes an array error in JMF

Jovan Dukic
Jovan Dukic Published in 2018-02-12 22:47:01Z

In this code bellow I want to play an mp3 music file using JMF library. I have downloaded mp3.plugIn and added it to my project.

package mediaaa;

import java.io.File;
import java.io.IOException;

import javax.media.*;
import javax.media.format.AudioFormat;
import javax.media.pim.PlugInManager;

       public class Mediaaa {

               public static void main(String[] args) {

       File file = new File("C:\\Users\\Jovan\\Desktop\\music.mp3");

    try {

        Format inputMP3 = new AudioFormat(AudioFormat.MPEGLAYER3);
        Format inputMPEG = new AudioFormat(AudioFormat.MPEG);
        Format output = new AudioFormat(AudioFormat.LINEAR);

        PlugInManager.addPlugIn("com.sun.media.codec.audio.mp3.JavaDecoder", new Format[] { inputMP3, inputMPEG },
                new Format[] { output }, PlugInManager.CODEC);

        Player player = Manager.createRealizedPlayer(file.toURI().toURL());

        player.start(); // Without this code works but there is no sound

    } catch (NoPlayerException | IOException | CannotRealizeException e) {



I get this error when I run my code:

java.lang.ArrayIndexOutOfBoundsException: -2
at codecLib.mp3.i.a(Unknown Source)
at codecLib.mp3.i.char(Unknown Source)
at codecLib.mp3.Decoder.decode(Unknown Source)
at com.sun.media.codec.audio.mp3.JavaDecoder.process        (JavaDecoder.java:323)
at com.sun.media.BasicFilterModule.process(BasicFilterModule.java:322)
at com.sun.media.BasicModule.connectorPushed(BasicModule.java:69)
at com.sun.media.BasicOutputConnector.writeReport  (BasicOutputConnector.java:120)
at com.sun.media.SourceThread.process(BasicSourceModule.java:729)
at com.sun.media.util.LoopThread.run(LoopThread.java:135)

Does anyone know how to fix it?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.346222 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO