iOS Question VideoPlayer - how to change user agent?

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've uploaded v1.62 of iUI8 to the build servers. The updated XML is not important in this case.
It will be included in B4i v7.80.

This allows you to set the player item yourself:
B4X:
Dim headers As Map = CreateMap("User-Agent": "Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion")

Dim AVURLAsset As NativeObject
Dim nsurl As NativeObject
nsurl = nsurl.Initialize("NSURL").RunMethod("URLWithString:", Array(url))
Dim options As Map = CreateMap("AVURLAssetHTTPHeaderFieldsKey": headers.As(NativeObject).RunMethod("ToDictionary", Null))
AVURLAsset = AVURLAsset.Initialize("AVURLAsset").RunMethod("URLAssetWithURL:options:", Array(nsurl, options.As(NativeObject).RunMethod("ToDictionary", Null)))
Dim PlayerItem As NativeObject
PlayerItem = PlayerItem.Initialize("AVPlayerItem").RunMethod("playerItemWithAsset:", Array(AVURLAsset))
VideoPlayer1.As(NativeObject).RunMethod("setPlayerImpl:", Array(PlayerItem))

Note that AVURLAssetHTTPHeaderFieldsKey is not a documented API. It looks like many developers use it.
 
Upvote 0
Top