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

  • Home
  • SEARCH
  • 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 8291093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:00:43+00:00 2026-06-08T13:00:43+00:00

I am trying to playback a file test3.mid that is generated by the same

  • 0

I am trying to playback a file test3.mid that is generated by the same app and is in the cache directory (I have verified that the file is there with filemanager)

I read here that setDataSource(string) can cause errors, so I opted to use filedesciptor. The code only gives errors (see below) when I add the prepare() method.

Am I making an error somewhere? I see ‘NullPointerException‘. Does that mean it does not find the file? What could I try?

I

   try {
       String filePath = getCacheDir() + "/test3.mid";
       File file = new File(filePath);
       FileInputStream inputStream = new FileInputStream(file);
       mediaPlayer.setDataSource(inputStream.getFD());
       inputStream.close();
    } catch (Exception e1) {
        e1.printStackTrace();
    }
    try {
        mediaPlayer.prepare();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

Logcat output is:

07-25 10:36:44.264: E/AndroidRuntime(31467): FATAL EXCEPTION: main
07-25 10:36:44.264: E/AndroidRuntime(31467): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.optimuse/com.example.optimuse.MainActivity}: java.lang.NullPointerException
07-25 10:36:44.264: E/AndroidRuntime(31467):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
07-25 10:36:44.264: E/AndroidRuntime(31467):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
07-25 10:36:44.264: E/AndroidRuntime(31467):    at android.app.ActivityThread.access$600(ActivityThread.java:123)
07-25 10:36:44.264: E/AndroidRuntime(31467):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
07-25 10:36:44.264: E/AndroidRuntime(31467):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-25 10:36:44.264: E/AndroidRuntime(31467):    at android.os.Looper.loop(Looper.java:137)
07-25 10:36:44.264: E/AndroidRuntime(31467):    at android.app.ActivityThread.main(ActivityThread.java:4424)
07-25 10:36:44.264: E/AndroidRuntime(31467):    at java.lang.reflect.Method.invokeNative(Native Method)
07-25 10:36:44.264: E/AndroidRuntime(31467):    at java.lang.reflect.Method.invoke(Method.java:511)
07-25 10:36:44.264: E/AndroidRuntime(31467):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-25 10:36:44.264: E/AndroidRuntime(31467):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-25 10:36:44.264: E/AndroidRuntime(31467):    at dalvik.system.NativeStart.main(Native Method)
07-25 10:36:44.264: E/AndroidRuntime(31467): Caused by: java.lang.NullPointerException
07-25 10:36:44.264: E/AndroidRuntime(31467):    at com.example.optimuse.MainActivity.onCreate(MainActivity.java:127)
07-25 10:36:44.264: E/AndroidRuntime(31467):    at android.app.Activity.performCreate(Activity.java:4465)
07-25 10:36:44.264: E/AndroidRuntime(31467):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
07-25 10:36:44.264: E/AndroidRuntime(31467):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
  • 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-06-08T13:00:45+00:00Added an answer on June 8, 2026 at 1:00 pm

    This is completely stupid, but I forgot

    mediaPlayer = new MediaPlayer();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app that plays an mp3 file and I'm trying to update
I'm trying to get smooth audio playback for an app that needs to play
I have an app that plays audio in the background. I'm trying to use
I am trying to write an iPhone app that playback mp3 audio streamed by
I am trying to play a asx file with Java SE. I have read
Background: I have encoded a raw h264 file using ffmpeg. I'm trying to create
I am trying to develop app, which records audio & playback.I am able to
I'm making an app that must slow down the playback of audio files. The
I'm trying to play a 24bit audio file with my AutoHotkey app. It just
I have a hidden embedded QuickTime object on my page that I'm trying to

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.