Exoplayer: Redirections (302) doesn't work

Created on 26 Jan 2016  路  4Comments  路  Source: google/ExoPlayer

Hi,

I try to play the following mp3: http://www.ivoox.com/03-nuestros-horrores-favoritos-h-p-lovecraft-el-templo_mn_10103734_api_1.mp3 and the demo app don't play it. It seems that a Response code: 302 (redirection) doesn't like. Following I paste the logcat:

Internal track renderer error.
    com.google.android.exoplayer.ExoPlaybackException: com.google.android.exoplayer.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 302
    at com.google.android.exoplayer.SampleSourceTrackRenderer.maybeThrowError(SampleSourceTrackRenderer.java:154)
    at com.google.android.exoplayer.SampleSourceTrackRenderer.maybeThrowError(SampleSourceTrackRenderer.java:145)
    at com.google.android.exoplayer.ExoPlayerImplInternal.incrementalPrepareInternal(ExoPlayerImplInternal.java:283)
    at com.google.android.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:205)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.os.HandlerThread.run(HandlerThread.java:61)
    at com.google.android.exoplayer.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40)
Caused by: com.google.android.exoplayer.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 302
    at com.google.android.exoplayer.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:210)
    at com.google.android.exoplayer.upstream.DefaultUriDataSource.open(DefaultUriDataSource.java:135)
    at com.google.android.exoplayer.extractor.ExtractorSampleSource$ExtractingLoadable.load(ExtractorSampleSource.java:741)
    at com.google.android.exoplayer.upstream.Loader$LoadTask.run(Loader.java:209)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    at java.lang.Thread.run(Thread.java:841)

Thanks!

question

Most helpful comment

It's working as intended that ExoPlayer doesn't follow cross-protocol redirects by default. In this case there are three redirects (not ideal to start with). The second one is a cross-protocol http->https redirect.

http://www.ivoox.com/03-nuestros-horrores-favoritos-h-p-lovecraft-el-templo_mn_10103734_api_1.mp3
-> http://files.ivoox.com/listen/10103734
-> https://archive.org/download/TyNM2015Otros/03NuestrosHorroresFavoritosH.p.lovecraft-ElTemplo.mp3
-> https://ia801505.us.archive.org/13/items/TyNM2015Otros/03NuestrosHorroresFavoritosH.p.lovecraft-ElTemplo.mp3

Ideally I think you should fix your serving infrastructure to not perform cross-protocol redirects. However if you can't do this, you can enable following of cross-protocol redirects in ExoPlayer by passing allowCrossProtocolRedirects=true to the DefaultUriDataSource constructor.

All 4 comments

It's working as intended that ExoPlayer doesn't follow cross-protocol redirects by default. In this case there are three redirects (not ideal to start with). The second one is a cross-protocol http->https redirect.

http://www.ivoox.com/03-nuestros-horrores-favoritos-h-p-lovecraft-el-templo_mn_10103734_api_1.mp3
-> http://files.ivoox.com/listen/10103734
-> https://archive.org/download/TyNM2015Otros/03NuestrosHorroresFavoritosH.p.lovecraft-ElTemplo.mp3
-> https://ia801505.us.archive.org/13/items/TyNM2015Otros/03NuestrosHorroresFavoritosH.p.lovecraft-ElTemplo.mp3

Ideally I think you should fix your serving infrastructure to not perform cross-protocol redirects. However if you can't do this, you can enable following of cross-protocol redirects in ExoPlayer by passing allowCrossProtocolRedirects=true to the DefaultUriDataSource constructor.

Yes, it works. I have to use the allowCrossProtocolRedirects param because the link is from a external server.

Thanks!

@icastell how you use allowCrossProtocolRedirects param ? can i look to your code ?
i get HttpDataSource$InvalidResponseCodeException: Response code: 302 too, please

I am using ExoPlayer1
@ojw28 I use a HLS Renderer and as suggested I have passed true in the constructor

new ManifestFetcher<>(url, new DefaultUriDataSource(context, null, userAgent, true),
                    parser);

I get this error:

Throwing OutOfMemoryError "Failed to allocate a 28 byte allocation with 6 free bytes and 6B until OOM" (recursive case)
 "JDWP" daemon prio=5 tid=4 Runnable
| group="system" sCount=0 dsCount=0 obj=0x22c18100 self=0x567ee008
| sysTid=16936 nice=0 cgrp=default sched=0/0 handle=0x56444008
| state=R schedstat=( 0 0 0 ) utm=337 stm=15 core=1 HZ=100
| stack=0x5593f000-0x55941000 stackSize=1012KB
| held mutexes= "mutator lock"(shared held)
at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)
at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:146)
at java.lang.StringBuilder.append(StringBuilder.java:216)
at java.lang.Throwable.toString(Throwable.java:360)
at java.lang.Throwable.printStackTrace(Throwable.java:315)
at java.lang.Throwable.printStackTrace(Throwable.java:282)
at java.lang.Throwable.printStackTrace(Throwable.java:236)
JNI WARNING: java.lang.OutOfMemoryError thrown while calling printStackTrace
Clamp target GC heap from 99MB to 96MB

If i dont pass true, it gives me 301

Was this page helpful?
0 / 5 - 0 ratings

Related issues

orcunkobal picture orcunkobal  路  3Comments

talklittle picture talklittle  路  3Comments

petitTrung picture petitTrung  路  3Comments

0x410c picture 0x410c  路  3Comments

AndrewJack picture AndrewJack  路  3Comments