Android Question videoview and http authentication

moster67

Expert
Licensed User
Longtime User
With VideoView I have problems to get a stream to work since it requires authentication.

Using VLC for ANdroid, I can get the stream to work including username and password in the URL like this:

http://user:password@192.168.1.5:8002.....

so it seems above method of authentication is supported by the server. This type of URL does not work with the VideoView wrapper.

I searched for this and I am unsure if it is possible with VideoView although this page at StackOverFlow,
http://stackoverflow.com/questions/5898271/authentication-for-videoview-in-android
seems to propose two methods that may work, namely:

1) a method using reflection
2) or to use MediaPlayer.setDataSource(Context, Uri, Map)

Can I implement one of above solutions using the VideoView wrapper, perhaps using reflection or JavaObject? If yes, could you help with the correct reflection-code?

Thank you.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The setDataSource solution will only work on Android 4+.

It should be quite simple to call setVideoUri with JavaObject.
You will need to first create a Uri object with ContentResolver library and then create the required Map.

With these two you should call:
B4X:
Dim jo As JavaObject = VideoView1
jo.RunMethod("setVideoURI", Array As Object(Uri1, Map1))
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
I forgot to follow up on Erel's reply and let you know that what mentioned above worked perfectly.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…