V
V
vladocc2015-12-30 15:05:23
Java
vladocc, 2015-12-30 15:05:23

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);
    }

Another class looks for all the songs on the device, and when found, this constructor is called.
Perhaps the method is not the most successful, but I do not know of others. With MediaMetadataRetriever everything crashes even faster.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
one pavel, 2015-12-30
@onepavel

Yes, no, either normal, it's in the hands. And about third-party, the question of
BASS, FMOD, SDL has already been raised repeatedly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question