Search code examples
vb.netwinformsxamarinmemorystream

How to send Memorystream from http socket


I have a VB WinForms application, I got frames from somewhere. App is not developed by me.

_ImageList = New Queue(Of MemoryStream)

Dim bmpdecode As New Bitmap(nWidth, nHeight)
Dim ms As New MemoryStream

bmpdecode.Save(ms, Imaging.ImageFormat.Jpeg)

_ImageList.Enqueue(ms)

PictureBox1.BeginInvoke(New DelPintarImagen(AddressOf DrawImage), New Object() {bmpdecode})

DrawImage is a bitmap type.

What I want is to get from a Xamarin android app VideoView or ImageView what I see in PictureBox1

After a days of research I have not been able to find anything that works minimally.

I can see the stream by http in web browser but I can't get from any VideoView or ImageView.


Solution

  • I got a solution for this, it's simple but it works.

    I used a WebView to display the stream in my Xamarin App disabling the zoom option, so for the user, it seems like a stream playing.

    C# code:

    var wPlayer = FindViewById<WebView>(Resource.Id.webView1);
    //Zoom Out for stretch the content by the 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>