Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirections (302) #581

Closed
vinecole27 opened this issue Mar 20, 2018 · 8 comments
Closed

Redirections (302) #581

vinecole27 opened this issue Mar 20, 2018 · 8 comments
Labels

Comments

@vinecole27
Copy link

I am experiencing exactly same issue with google/ExoPlayer#1190
but I am not sure how to pass allowCrossProtocolRedirects=true to the DefaultUriDataSource constructor.
Can you help?

@brianwernick
Copy link
Owner

You can specify a DataSourceProvider with ExoMedia#setDataSourceFactoryProvider() that provides your customized data source that handles cross origin and cross protocol redirects

@vinecole27
Copy link
Author

@brianwernick I am only using AudioPlayer class

@brianwernick
Copy link
Owner

That doesn't matter, the ExoMedia#setDataSourceFactoryProvider() will affect both the AudioPlayer and VideoView

@vinecole27
Copy link
Author

Can you write the code here how to do that?

@brianwernick
Copy link
Owner

See #86

@vinecole27
Copy link
Author

ExoMedia.setDataSourceFactoryProvider(new ExoMedia.DataSourceFactoryProvider() {
            @NonNull
            @Override
            public DataSource.Factory provide(@NonNull String userAgent, @Nullable TransferListener<? super DataSource> listener) {
                
            }
        });

@brianwernick How to handle cross origin and protocol redirects here?

@brianwernick
Copy link
Owner

brianwernick commented Mar 23, 2018

You need to provide a DataSource.Factory that correctly handles the cross origin redirects.

If you are using OkHttp then you can use

OkHttpClient httpClient = new OkHttpClient().newBuilder().followRedirects(true).followSslRedirects(true).build();
return new OkHttpDataSourceFactory(httpClient, userAgent, listener);

or if you want to use the default client then

// The last argument `true` is what indicates that we allow cross origin redirects
return new DefaultHttpDataSourceFactory(userAgent, listener, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS, DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, true);

@vinecole27
Copy link
Author

@brianwernick Thanks a lot!! it worked!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants