简体   繁体   English

Android(Xamarin)通过rtsp://从IP Cam流视频

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

UPDATE: I solved it by using vlc-sdk for android. 更新:我通过为Android使用vlc-sdk解决了它。

So i'm facing this problem where i have a URL which provides a stream from an IP camera. 所以我面对这个问题,因为我有一个提供来自IP摄像机的流的URL。

It's something like 就像

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

Note: there is no extension like .mp4 or .mov 注意:没有像.mp4或.mov这样的扩展名

I tried the URL in VLC player on my Computer and with the Android application "rtsp player" and both work. 我在计算机上的VLC播放器中尝试使用该URL,并在Android应用程序“ rtsp player”中尝试了该URL,两者都可以正常工作。 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. 现在,我需要编写一个应用程序,该应用程序还显示来自凸轮的流,并且我必须使用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: 在主要活动中,我只需输入IP并点击一个按钮,然后StreamActivity就会启动,但是在我按下按钮后,新的活动就会开始,并且我会收到一条错误消息:

Can't play this video 无法播放此视频

In the LogCat i get the following Warnings and Errors: 在LogCat中,我收到以下警告和错误:

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 11-11 18:14:56.594:W / MediaPlayer(18879):无法打开rtsp://192.168.4.103:8554 / BWC:java.io.FileNotFoundException:无内容提供者:rtsp://192.168.4.103: 8554 /生物武器公约

and

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

Any help would be appreciated! 任何帮助,将不胜感激!

有一个名为Surge的解决方案可能会有所帮助-https://instil.co/surge/

您可以尝试在前缀和IP之间添加用户名和密码

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM