android – Pass stream by IntPtr pointer to VideoView

Question:

How can I pass an argument of type IntPtr to a VideoView in Xamarin?

I get a stream from a video recorder using the manufacturer's own libraries (which don't have much documentation) and I can't implement the stream to a VideoView as I say.

I'm really not sure how I have done it so I am going to leave the code that works for me in C # in a Windows Forms project that works for me, and in turn I put the part of what I am trying in Xamarin .

C # Windows Forms functional code:

//Por aquí arriba hay configuración de direcciones ip y credenciales para el objeto. 
var info = new CHCNetSDK.LPNET_DVR_PREVIEWINFO();
info.hPlayWnd = VideoBox.Handle; //Declaro por donde se va a reproducir el Stream
CHCNetSDK.NET_DVR_RealPlay_V40(idConexion,ref info, null, User); //Inicia el Stream

VideoBox is (PictureBox)

NO functional code in Xamarin :

Attempt 1 using MediaController :

var mediaController = new MediaController();
info.hPlayWnd = mediaController.Handle;
videoView.setMediaController(mediaController);
CHCNetSDK.NET_DVR_RealPlay_V40(idConexion,ref info, null, User);
videoView.Start();

Attempt 2 removing MediaController only with VideoView

When I have tried it with the videoView the only difference is that I have removed the lines in which the mediaController is referenced mediaController doing:

info.hPlayWnd = videoView.Handle; 
videoView.Start();

Try 3 using ImageView as PictureBox

info.hPlayWnd = imageView.Handle;
CHCNetSDK.NET_DVR_RealPlay_V40(idConexion,ref info, null, User);

As I say, in no case has it worked for me. It does not return any type of exception, the VideoView simply goes black. I can ensure that the resource I am trying to connect to works 100%.

Any ideas to port the code from Windows Forms to Android or any alternative?

Answer:

I have found a solution for this, as the stream can be seen from any browser I have chosen to use WebView to be able to visualize the "stream" which actually appears to be a sequence of images and deny the zoom and movements of the webview to make it look like this. a video.

C # code:

var wPlayer = FindViewById<WebView>(Resource.Id.webView1);
//Zoom Out para ajustar contenido a pantalla por width
wPlayer.Settings.LoadWithOverviewMode = true; 
wPlayer.Settings.UseWideViewPort = true;
wPlayer.SetPadding(0, 0, 0, 0);

wPlayer.LoadUrl("http://ip:port/?params");

Axml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_main">

<android.webkit.WebView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/webView1"
/>


</RelativeLayout>
Scroll to Top