3

I am using exoplayer 2.7.3 and when i am trying to play some url i get below error:

E/ExoPlayerImplInternal: Source error.
com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 401

I can able to play same url in some other place in app. But at this place this issue happens.

Can anyone help me what might be wrong?

vivek
  • 141
  • 3
  • 18

2 Answers2

0

First, try to play the streaming on some web browser, if it fails, the problem is with this link.

The error 401 means that you not have permission to access this content.

Daniel Beltrami
  • 756
  • 9
  • 22
  • Any updates on this issue? I am also facing the same problem. My chrome browser loads the stream but exo gives 401 error – viper Jul 27 '21 at 12:41
0

Because you haven't set token for your data source. Set token like this :

    // Create a data source factory.
    val headersMap: MutableMap<String, String> = HashMap()
    headersMap["Authorization"] = "Bearer ${"your token"}"
    val dataSourceFactory: DataSource.Factory =          
  DefaultHttpDataSource.Factory().setDefaultRequestProperties(headersMap)
Javad Shirkhani
  • 343
  • 6
  • 11