Play m3u8 with referer and use-ragent on android studio

Viewed 342

I am trying to run a broadcast link, but this link only works with the so-called user-agent and referer How can I add it this Option

1 Answers

You should be able to set it with the HttpDataSourceFactory. n.b. this is against Media3, but I believe it's almost the same.

    val dataSourceFactory = DefaultHttpDataSource.Factory()
            .setUserAgent("XXX")
            .setDefaultRequestProperties(mapOf("Referer" to "https://example.org/"))

    player =
      ExoPlayer.Builder(this)
        .setMediaSourceFactory(DefaultMediaSourceFactory(dataSourceFactory))
        .build()
Related