Android Question Can Exoplayer work with cookie?

dune3000

Member
Licensed User
Longtime User
Here are the working flow and exoplayer's not working flow
 

Attachments

  • official.png
    official.png
    494.5 KB · Views: 334
  • exoplayer.png
    exoplayer.png
    301.4 KB · Views: 304
Upvote 0

dune3000

Member
Licensed User
Longtime User
Solved.

Refer to https://www.b4x.com/android/forum/threads/exoplayer-user-agent.86695/
Add few lines to inline java

B4X:
import java.net.CookieHandler;
import java.net.CookieManager;
import java.net.CookiePolicy;
public static class MySimpleExoPlayerWrapper extends SimpleExoPlayerWrapper {
  private static final CookieManager DEFAULT_COOKIE_MANAGER;
  static {
    DEFAULT_COOKIE_MANAGER = new CookieManager();
    DEFAULT_COOKIE_MANAGER.setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER);
  }
@Override
public DefaultDataSourceFactory createDefaultDataFactory() {
  if (CookieHandler.getDefault() != DEFAULT_COOKIE_MANAGER) {
    CookieHandler.setDefault(DEFAULT_COOKIE_MANAGER);
  }
 return new DefaultDataSourceFactory(BA.applicationContext, "Mozilla/5.0 AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16");
 }
}
 
Upvote 0
Top