Marekzan
Marekzan

Reputation: 93

Android (Xamarin) stream Video from IP Cam via rtsp://

UPDATE: I solved it by using vlc-sdk for android.

So i'm facing this problem where i have a URL which provides a stream from an IP camera.

It's something like

rtsp://192.168.x.xxx:8554/BWC

Note: there is no extension like .mp4 or .mov

I tried the URL in VLC player on my Computer and with the Android application "rtsp player" and both work. They both show me the stream from the cam.

Now i need to write an Application, which also displays the stream from the cam and i have to write it with Xamarin.

I have the following code:

[Activity(Label = "StreamActivity", ScreenOrientation = ScreenOrientation.Portrait, HardwareAccelerated = true, Theme = "@style/Theme.AppCompat.Light.NoActionBar")]
public class StreamActivity : AppCompatActivity
{
    String urlPrefix = "rtsp://";
    String urlSuffix = ":8554/BWC";

    VideoView streamView { get; set; }       

    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        SetContentView(Resource.Layout.StreamView);

        var ipAddress = Intent.GetStringExtra("ip");
        var url = urlPrefix + ipAddress + urlSuffix;
        var vidUri = Android.Net.Uri.Parse(url);

        streamView = FindViewById<VideoView>(Resource.Id.view_stream);
        streamView.SetMediaController(new MediaController(this));
        streamView.SetVideoURI(vidUri);
        streamView.RequestFocus();
        streamView.Start();
    }
}

In the main activity i just enter the IP and hit a button then the StreamActivity is starting, but after i hit the button the new activity starts and i get an error message:

Can't play this video

In the LogCat i get the following Warnings and Errors:

11-11 18:14:56.594: W/MediaPlayer(18879): Couldn't open rtsp://192.168.4.103:8554/BWC: java.io.FileNotFoundException: No content provider: rtsp://192.168.4.103:8554/BWC

and

11-11 18:15:43.688: E/MediaPlayer(18879): error (100, 0)

Any help would be appreciated!

Upvotes: 1

Views: 2745

Answers (2)

Roman Leshchyshyn
Roman Leshchyshyn

Reputation: 1

You can try to add your username and password between prefix and IP

var url = urlPrefix + username + ":" + password + "@" + ipAddress + urlSuffix;

Upvotes: 0

Michael
Michael

Reputation: 1

There is a solution called Surge that may be of help - https://instil.co/surge/

Upvotes: 0

Related Questions