Hitesh Gehlot
Hitesh Gehlot

Reputation: 1347

Android 10 mediaplayer not working getting error stop called in state 1, mNative: error (-38, 0)

My code working fine in all devices below android 10. But when app run in android 10 mediaplayer not working. here my code

mplayer = new MediaPlayer();
        mplayer.setDataSource(this, Uri.fromFile(new File(SongPathlocation)));
        mplayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mplayer.prepare();

        mplayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {

                mplayer.start();

            }
        });

Upvotes: 3

Views: 545

Answers (1)

Richard
Richard

Reputation: 11

Try to add to AndroidManifest.xml file, in application section this:

android:requestLegacyExternalStorage="true"

Upvotes: 1

Related Questions