how to play a sound for 5 seconds
<p>i want to play a sound for 5 seconds but the code which i am using is playing the sound infinitely.</p>

<p>My code is</p>

<pre><code>final MediaPlayer player = new MediaPlayer();
AssetFileDescriptor afd = this.getResources().openRawResourceFd(R.raw.hangout_ringtone);
player.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
afd.close();
player.setAudioStreamType(AudioManager.STREAM_ALARM);
player.setLooping(true);
player.prepare();
</code></pre>
