Q:

Android MediaPlayer start called in State 1. Error -38,0

Good day! As usual - I am starting to learn Android programming and have faced unexpected difficulty while trying to create basic MediaPlayer app. Audio file is stored in res/raw. It is accessed with create(). I have read a few manuals on how to build a media player app and was convinced that using prepare() and prepareAsync() was not necessary in case if file is stored in res/raw folder. So here is my initial code 
private MediaPlayer playerM = new MediaPlayer();

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button playButton = (Button) findViewById(R.id.playButton);
    playButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            playMusic(R.raw.sleep_away);
        }
    });
    Button stopButton = (Button) findViewById(R.id.pauseButton);
    stopButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            stopMusic();
        }
    });
}

private void playMusic(int rid) {
    playerM.create(this, rid);
    playerM.start();
}

private void stopMusic() {
    playerM.stop();
}

}
Since that I have made numerous changes, but nothing helped. According to dev.android manual on MediaPlayer the code above should work. However it results in the following errors: 
E/MediaPlayer: start called in state 1, mPlayer(0x0)
E/MediaPlayer: error (-38, 0)
E/MediaPlayer: Error (-38,0)
Probably I am just making some blunt mistake. Any help would be much appreciated.

A:

Solved by myself
playButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try{

                Uri myUri = Uri.parse("android.resource://" + v.getContext().getPackageName() + "/" + R.raw.sleep_away);
                System.out.println(myUri);
                playerM.setDataSource(v.getContext(), myUri);
                playerM.prepare();
                playerM.setOnPreparedListener(new MediaPlayer.OnPreparedListener(){
                    @Override
                    public void onPrepared(MediaPlayer playerM){
                        playerM.start();
                    }
                });
            }catch(IOException e){
                e.printStackTrace();
            }

        }
    });

I know I should add other methods to change State, but the main purpose was to get it to play file. 

