Android MediaPlayer works fine in Custom audio Streaming application up to Android 2.1 but not in higher versions
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.
Android 2.2 MediaPlayer is working fine with one SHOUTcast URL but not with the other one
Shoutcast mp3 streaming from Android 2.2 onwards is supported natively .
Below 2.2 the Android OS cannot play shoutcast streams natively without using a proxy on the stream end or a stream proxy class on the device to capture the stream and pass it to the audioplayer just like NPR does.
audio/aacp streaming is not supported directly . For this you can use ffmpeg, opencore or faad2 library to decode it into PCM and play using audiotrack .Reference
Android custom audio player to replace MediaPlayer with libPd or OpenSL ES or AudioTrack
In my experience OpenSL_ES would be the choice, here there is a Link that explains how to do audio streaming that you may find useful. bufferframes determines how many samples you will collect before playing, so smaller bufferframes faster response time, but you have to balance that with your device processing capabilities.
Audio File Streaming in Android not working one android 2.3
Media player in android <4.x supports only HTTP and 4.x n above support for BOTH http and https , so while using https with older API level, please think over it use http instead of https.
Android MediaPlayer error: MediaPlayer error(1, -2147483648) on Stream from internet
If you are testing on devices earlier than Android 3.1 you might not be able to play AACP (as seen on the info page for your stream (AAC+) streams.
Info page for your stream:
In order to find out what streams you can play on your targeted device check official docs: http://developer.android.com/reference/android/media/AudioManager.html
If you are looking how to handle aacp checkout following:
https://stackoverflow.com/a/8833346/200272
Related Topics
Android: Allow Portrait and Landscape for Tablets, But Force Portrait on Phone
Latest Update on Enabling and Disabling Mobile Data Programmatically
What Exactly Does the Post Method Do
Use Picasso to Get a Callback with a Bitmap
Android. How Does Notifydatasetchanged() Method and Listviews Work
Google Sign in Failed Com.Google.Android.Gms.Common.Api.Apiexception: 10:
How to Startforeground() Without Showing Notification
How to Redirect My Log Output from Logcat to the Sd-Card on an Android Device
Android Textview with Clickable Links: How to Capture Clicks
How to Programmatically Enable Auto Start and Floating Window Permissions
Callback to a Fragment from a Dialogfragment
How to Create Custom Button in Android Using Xml Styles
Spinner: Get State or Get Notified When Opens
How to Change the Color of Alertdialog Title and the Color of the Line Under It
How to Override the 'Home' Button in My Application