I have this type of stream: http://radiohoryzont.jgora.pl:8050. The problem is, that when I try to play it using ExoPlayer, following exception is thrown.
E/ExoPlayerImplInternal: Internal track renderer error. com.google.android.exoplayer.ExoPlaybackException: com.google.android.exoplayer.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to http://radiohoryzont.jgora.pl:8050
Strange thing is, that on another mobile phone it seems to be working (it is working on Android 6, but not on Android 4). Could somebody help me with this?
I am using EMAudioPlayer.
mediaPlayer = new EMAudioPlayer(getApplicationContext());
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(getApplicationContext(), myURI);
Thanks in advance for your help.
I've been solving the very same issue recently and found the solution.
The URL which fails for you is a ShoutCast and these are not working well with HttpDataSource
on Android 4. However if you manage to replace this with OkHttpDataSource
, data will be retrieved correctly.
You are using EMAudioPlayer
, which uses ExoPlayer
to stream music (for API level 16+). You can easily replace HttpDataSource
with OkHttpDataSource
:
TrackSelector trackSelector = new DefaultTrackSelector( new Handler(), new AdaptiveVideoTrackSelection.Factory( new DefaultBandwidthMeter() ) ); mediaPlayer = ExoPlayerFactory.newSimpleInstance( getApplicationContext(), trackSelector, new DefaultLoadControl() ); MediaSource source = new ExtractorMediaSource( myURI, new OkHttpDataSourceFactory( new OkHttpClient(), userAgent, null ), new DefaultExtractorsFactory(), null, null ); mediaPlayer.prepare(source); mediaPlayer.setPlayWhenReady(true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With