문제

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;
}
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top