MediaPlayer mediaPlayer = MediaPlayer.create(this, R.raw.audio_file); // Start the media player mediaPlayer.start(); // Pause the media player after 5 seconds new Handler().postDelayed(new Runnable() { @Override public void run() { mediaPlayer.pause(); } }, 5000);In this example, we are playing an audio file using the MediaPlayer class and then pausing it after 5 seconds using the pause() method. We have used the Handler class to delay the pause operation by 5 seconds. The package library for the MediaPlayer class is android.media.