Question

I have successfuly played an mp3 file in java desktop app now what i want is to know that is it possible for me to get the total time duration of an mp3 file playing to be played. So that i can manage my thread to interrupt after the mp3 file has finish its play thread. If its possible then how could it be achieve please help with your hints and ideas thanks in advance

Was it helpful?

Solution

I have this method to play my mp3 file using

      jlayer.jar 
      mp3plugin.jar
      jaudiotagger-2.0.1.jar

      private void playMe(){
        try{

         File file=new File("F:\\Net Beans Work Space\\mp3\\a.mp3");
         FileInputStream fis     = new FileInputStream(file);

             BufferedInputStream bis = new BufferedInputStream(fis);
             player = new Player(bis);

          int d=0;
           AudioFile audioFile = AudioFileIO.read(file);
           d = audioFile.getAudioHeader().getTrackLength();

           System.out.print("ddd=   "+d)  ;

             player.play();
      }catch(Exception e){

       System.out.print("ERROR "+e);
      }

     }

What one must have to do is to create and use Java Threads and the time length using this coding of method is 99% accurate lols

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top