Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7593517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:11:22+00:00 2026-05-30T21:11:22+00:00

I have a MediaPlayer that plays with the following code: private void playVideo() {

  • 0

I have a MediaPlayer that plays with the following code:

 private void playVideo() {
    if (videoURI == null) {
        showToast("Please, set the video URI in HelloAndroidActivity.java in onClick(View v) method");
    } else {
        new Thread(new Runnable() {
            public void run() {
                try {
                    player.setOnErrorListener(new OnErrorListener()
                    {
                        @Override
                        public boolean onError(MediaPlayer mp,
                                int what, int extra) {
                            Log.e("MEDIAPLAYER ERRORS",
                            "what: " + what + "  extra: "   + extra);

                          return false;
                        }
                    });
                    Log.d("video","---+ in main run");
                    player.setDataSource(videoURI);
                    player.prepare();
                    player.reset();
                } catch (IllegalArgumentException e) {
                    Log.d("video","---+ illegal arg");
                    showToast("Error while playing video");
                    Log.i(TAG, "==========              IllegalArgumentException ===========");
                    e.printStackTrace();
                } catch (IllegalStateException e) {
                    Log.d("video","---+ illegal state");
                    showToast("Error while playing video");
                    Log.i(TAG, "========== IllegalStateException ===========");
                    e.printStackTrace();
                } catch (IOException e) {
                    Log.d("video","---+ general error");
                    showToast("Error while playing video. Please, check your network connection.");
                    Log.i(TAG, "========== IOException ===========");
                    e.printStackTrace();
                }
            }
        }).start();
    }
}

On error, my app goes into an infinite error loop with the following messages:

 03-05 13:27:23.035: E/MediaPlayer(6289): stop called in state 0
 03-05 13:27:23.035: E/MediaPlayer(6289): error (-38, 0)
 03-05 13:27:23.035: E/MediaPlayer(6289): Error (-38,0)
 03-05 13:27:23.043: E/MEDIAPLAYER ERRORS(6289): what: -38  extra: 0

What is the best way to recover from the error that is caught? Should I abort the mediaplayer and if so how do I accomplish this? Also how can I stop from going into this error loop in the first place?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:11:24+00:00Added an answer on May 30, 2026 at 9:11 pm

    Is there something missing from your code? It doesn’t seem to me like it would ever actually start the MediaPlayer anywhere in what you’ve posted.

    It also seems odd to me that you call

    player.reset();
    

    after the others. I would think this would undo the setDataSource(), and prepare() that you just got finished with. Try moving reset so that it is the first one called.

    and try putting this in your onErrorListener callback:

    player.reset();
    player.setDataSource(videoURI);
    player.prepare();
    

    That way it will just try to remake the whole thing when it gets this error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that plays a video from the sdcard with MediaPlayer. I
I have the following code: AssetFileDescriptor afd = getAssets().openFd(AudioFile.mp3); player = new MediaPlayer(); player.setDataSource(afd.getFileDescriptor());
I have two applications that play video. in one of them the JWplayer plays
I have a mediaplayer object inside an activity that plays from mp3 files situated
I have a mediaplayer that can only read samba shared files. I would like
I made an WPF app that plays sounds using the MediaPlayer class. This works
i have this code package com.tct.soundTouch; import android.app.Activity; import android.media.MediaPlayer; import android.os.Bundle; import android.view.MotionEvent;
I have a list of songs that I'm streaming using the MediaPlayer. Some of
I have made a Android streaming application that plays media from online URL's. For
I have written an app which plays background music with MediaPlayer. I am now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.