//This is the edited code that works:

I have been trying to find different ways to fix it, but it looks like I have to ask for help.

The media player plays the file the first time and never again.
This is the code:

```
btn_default_acc = (ImageButton) layout.findViewById(R.id.btn_df_acc);
        btn_default_acc.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {if(sentencePlayer==null){
                        sentencePlayer  = new MediaPlayer();
                    }sentencePlayer.reset();
                    sentencePlayer.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
                    sentencePlayer.prepare();
                    sentencePlayer.start();

                } catch (IllegalArgumentException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalStateException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        });

        sentencePlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer sentencePlayer) {
                sentencePlayer.stop();

            }
        });

```

and the logcat:
`01-11 13:28:36.744 9044-9044/com.testapp.imre.testapp W/System.err: java.lang.IllegalStateException
01-11 13:28:36.744 9044-9044/com.testapp.imre.testapp W/System.err: at android.media.MediaPlayer._setDataSource(Native Method)
01-11 13:28:36.744 9044-9044/com.testapp.imre.testapp W/System.err: at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1254)
01-11 13:28:36.744 9044-9044/com.testapp.imre.testapp W/System.err: at com.testapp.imre.testapp.Lesson1Reading$11.onClick(Lesson1Reading.java:1134)
01-11 13:28:36.744 9044-9044/com.testapp.imre.testapp W/System.err: at android.view.View.performClick(View.java:5156)
01-11 13:28:36.744 9044-9044/com.testapp.imre.testapp W/System.err: at android.view.View$PerformClick.run(View.java:20755)
01-11 13:28:36.744 9044-9044/com.testapp.imre.testapp W/System.err: at android.os.Handler.handleCallback(Handler.java:739)
01-11 13:28:36.744 9044-9044/com.testapp.imre.testapp W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
01-11 13:28:36.744 9044-9044/com.testapp.imre.testapp W/System.err: at android.os.Looper.loop(Looper.java:145)
01-11 13:28:36.744 9044-9044/com.testapp.imre.testapp W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5832)
01-11 13:28:36.744 9044-9044/com.testapp.imre.testapp W/System.err: at java.lang.reflect.Method.invoke(Native Method)
01-11 13:28:36.744 9044-9044/com.testapp.imre.testapp W/System.err: at java.lang.reflect.Method.invoke(Method.java:372)
01-11 13:28:36.744 9044-9044/com.testapp.imre.testapp W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
01-11 13:28:36.744 9044-9044/com.testapp.imre.testapp W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)`

I also modified the method that closes the screen:

`private View.OnClickListener close_popup_screen_listener = new View.OnClickListener() {
 public void onClick(View v) {
 if (sentencePlayer != null){
 sentencePlayer.stop();
 }
 popUpScreen.dismiss();
 try {
 fd.close();
 } catch (IOException e) {
 e.printStackTrace();
 }
 stopMediaRecorder();
 }
 };`