1

When I start playing music by javazoom library, console stops answer. I can write anything, but no response.

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;
import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.advanced.AdvancedPlayer;
public class Main {
 
 public static void men(int i) {
 try {
 FileInputStream fis = new FileInputStream("Filename.WAV");
 AdvancedPlayer player = new AdvancedPlayer(fis);
 player.play(); 
 }catch(FileNotFoundException e){
 e.printStackTrace();
 }catch(JavaLayerException e) {
 e.printStackTrace();
 }
 }
 
 public static Scanner scn = new Scanner(System.in);
 public static void main(String[] args) {
 while(true) {
 int i = scn.nextInt();
 if(i == 1) {
 men(i);
 }
 if(i == 5) {
 System.out.println("i am here");
 }
 } 
 }
}

Is there solution? Or javazoom can't play audio and do other things?

8
  • please provide the code base through github Commented Sep 24, 2020 at 13:20
  • @AnishB. , i am new at this website, you mean, you want me to send you java-project? Commented Sep 24, 2020 at 13:22
  • 1
    @AnishB. god, i can't use github. i don't know how to use it. tutorial didn't help. maybe google drive? Commented Sep 24, 2020 at 13:48
  • 1
    @AnishB. drive.google.com/drive/folders/… Commented Sep 24, 2020 at 14:02
  • 1
    @AnishB. i want code to start playing music and i could write other commands and java will response. Now, when i write something in console after java start playing music, it didn't response at all. I think, it stays at player.play(), and will go futher after song will end. Thanks! Commented Sep 24, 2020 at 14:08

1 Answer 1

0

I'm not clear what you mean by "console stops answer" and "Javazoom can't play audio and do other things."

You can execute the javazoom play command in its own thread. While that thread runs concurrently, your program will be free to execute other tasks.

Do you know how to create and launch a thread? Here is Oracle's tutorial Processes and Threads.

answered Sep 25, 2020 at 3:29
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.