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