
Originally Posted by
singh.jagatjit
i know there is a method Player.deallocate();
if i call
Player.start();
Player.deallocate();
nothing is played.
i want to Deallocate the resource once i have played the sound. How do i know the sound has been played and i can then call Player.deallocate(); ??
The deallocate() method actually "resets" the player if it was prefetched. Try to use a PlayerListener with the player, so the player will notify you whenever it has finished the media playback through the method playerUpdate(Player player, String event, Object eventData). Usually the END_OF_MEDIA event is thrown at the end of media playback.
Code:
Player player;
private void startPlayer() {
player = Manager.createPlayer(...);
player.addPlayerListener(this); // note, this class should implement the PlayerListener interface
player.prefetch();
player.start(); // and nothing else
} // end startPlayer
...in the same class...
public void playerUpdate(Player player, String event, Object eventData) {
if (event.equals(PlayerListener.END_OF_MEDIA)) {
player.close(); // finito lá comedia
player = null;
} // end if END_OF_MEDIA
} // end playerUpdate