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 7018643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:04:43+00:00 2026-05-27T23:04:43+00:00

EDIT: Android 2.2 MediaPlayer is working fine with one SHOUTcast URL but not with

  • 0

EDIT:

Android 2.2 MediaPlayer is working fine with one SHOUTcast URL but not with the other one

I need to play audio files from external URLs(shoutcast stream). Currently the audio files are downloaded incrementally & are played as soon as we get enough audio in phone local temporary storage. i am using the StreamingMediaPlayer class.

Check this piece of code:

    private MediaPlayer createMediaPlayer(File mediaFile)
            throws IOException {
        MediaPlayer mPlayer = new MediaPlayer();
        //example of mediaFile =/data/data/package/cache/playingMedia0.dat
        FileInputStream fis = new FileInputStream(mediaFile);
        mPlayer.setDataSource(fis.getFD());
        mPlayer.prepare();
        return mPlayer;
    }

Current status:

1- It works fine from Android 1.6 to 2.1 but not in the higher versions like Android 2.2.

2- The “mPlayer.setDataSource(fis.getFD())” is the line which throws the error.

3- The error is “Unable to to create media player”

Other Solution tried:

I tried below alternate solution but nothing worked so far.

Android 2.2 MediaPlayer is working fine with one SHOUTcast URL but not with the other one

What i am looking for?

My goal is to have a peace of code which can work on Android 2.1 & higher.

This issue is also discussed here:

1- Inconsistent 2.2 Media Player Behavior

2- android code for streaming shoutcast stream breaks in 2.2

3- This issue is also discussed in a lot of questions on this site, but i found the answer no where.

4- markmail.org

LogCat trace:

Unable to to create media player
Error copying buffered conent.
java.lang.NullPointerException
com.ms.iradio.StreamingMediaPlayer.startMediaPlayer(StreamingMediaPlayer.java:251)
com.ms.iradio.StreamingMediaPlayer.access$2(StreamingMediaPlayer.java:221)
com.ms.iradio.StreamingMediaPlayer$2.run(StreamingMediaPlayer.java:204)
android.os.Handler.handleCallback(Handler.java:587)
android.os.Handler.dispatchMessage(Handler.java:92)
android.os.Looper.loop(Looper.java:123)
android.app.ActivityThread.main(ActivityThread.java:3683)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:507)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
dalvik.system.NativeStart.main(Native Method)
  • 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-27T23:04:43+00:00Added an answer on May 27, 2026 at 11:04 pm

    The StreamingMediaPlayer class is using a double-buffering technique to get around limitations in pre-1.2 releases of Android. All production releases of Android OS have included a MediaPlayer that supports streaming media(1). I would recommend doing that rather than using this double-buffering technique to get around the problem.

    Android OS 2.2 replaced the old media player code with the FrightCast player which probably is acting differently in this case.

    The line numbers in your stack trace don’t map to the file you link to, so I assume there’s a different version that you’re actually using. I’m going to guess that that NullPointerException is being reported by MediaPlayer but neither the FileInputStream nor the returned FileDescriptor can be null.

    (1) Prior to version 2.2 the media player wouldn’t recognize ShoutCast streams with an “ICY/1.1” version header in the response. By creating a proxy that replaces this with “HTTP/1.1” you can resolve that. See the StreamProxy class here for an example.

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

Sidebar

Related Questions

I have to achieve the following layout in one of my android applications: Edit:
I'm building an Android App where users need to be able to edit their
I gave android:singleLine=true option on EditTextPreference , and when the edit box in the
EDIT 1 I apologize but after reading the 2 suggested articles I still don't
EDIT: This post was originally specific to ASP.NET, but after thinking about it I'm
I am making a game for android which needs to play a small beep
Forgive me if my question is stupid, but I'm not a web programmer and
I have a edit text, whose input type is number. in emulator its working
When I add the ViewPagerIndicator library to a working android project, the project force
i want to allow only numbers and period(.) in a android edit text. How

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.