Home » Android » How to change default User-agent in mediaplayer of the android

How to change default User-agent in mediaplayer of the android

Posted by: admin May 14, 2020 Leave a comment

Questions:

In which file of the android repo do i have to change the default user-agent?
I need to set this string as default user-agent for the media-player:
HTC Streaming Player vodafone_uk / 1.0 / htc_bravo / 2.2

How to&Answers:
public void setDataSource (Context context, Uri uri, Map<String, String> headers);

In you app which controls MediaPlayer instance, pass the user agent in the header map as follows:

Map<String, String> headerMap = new HashMap<String, String>();;
headerMap.put("User-Agent", "my user agent value");
mediaPlayer.setDataSource(context, uri, headerMap);