Answer the question
In order to leave comments, you need to log in
What are non-stock libraries for playing music on Android?
I used the stock MediaPlayer library for Android when developing my player, and now, after changing the DataSource for the nth amount, she decided to say no to me and threw an IllegalStateException on prepare. To add understanding, I’ll say that it was a cycle in which only the path to the file changed and, therefore, an exception would have to fall on the first iteration, but it definitely succeeds on iteration 6. On what it falls, it was not possible to find out.
As a result, it is easier to find another library than to fix this one, because I don't have the option to skip this cycle.
The code:
public class Song {
static MediaPlayer play = new MediaPlayer();
static ArrayList<Song> Songs = new ArrayList<>();
String name;
String path;
int Duration;
int Number;
Song(String songName, String songPath){
name = songName;
path = songPath;
try {
play.setDataSource(songPath);
} catch (IOException e) {
e.printStackTrace();
}
try {
play.prepare();
} catch (IOException e) {
e.printStackTrace();
}
Duration = play.getDuration();
play.reset();
Number = Songs.size();
Songs.add(this);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question