java-menokiammapi

Trying to play audio on Nokia C3, results in : Failed to fetch media data


I am currently working on a project that uses Manager.createPlayer(InputStream is, String mimeType) to create an audio player.

The audio player works perfectly on the emulator. On a Nokia C3 it is able to play an audio/mpeg track after the app starts, but fails when an attempt is made to play the same/other audio again. On prefetch a message, "failed to fetch media data" is caught.

When opening the player for the first time it is taken through the normal lifecycle: realize,prefetch,start. After the track is finished it is: stopped,deallocated,closed . The player is even set to null, before the process is repeated for another audio track.

Any ideas?

Here is a sample of the code used to create the player.

    public static Player play(PlayerListener listener, InputStream is, String[] mimeTypes) {
    Player player = null;
    for (int i = 0; i < mimeTypes.length; i++) {    
        try {
            player = Manager.createPlayer(is, mimeTypes[i]);
            player.realize();
            player.prefetch();  
            player.addPlayerListener(listener);
            player.start();
            Log.write("started - " + mimeTypes[i]);
            break;
        } catch (Exception e) {
            Log.write("player fail (" + mimeTypes[i] + "): " + e.getMessage());
            player = null;
        } catch (Throwable e) {
            Log.write("player fail (" + mimeTypes[i] + "): " + e.getMessage());
            player = null;
        } 
    }
    return player;
}

Solution

  • It seems that the answer is that the file size of the MP3 I am trying to play is too large. By lowering the size the problem solved itself.

    From 2MB to 150kb.

    If anyone could shed some light on why this would happen, it would be very greatly appreciated.