Android MJPEG stream

天大地大妈咪最大 提交于 2019-12-01 21:46:06

I have implemented a library to play MJPEG video streaming on Android. All source code is available on GitHub ipcam-view.

Add the dependency to your app

compile 'com.github.niqdev:mjpeg-view:0.3.3'

Here an example of how use it, add MjpegSurfaceView to your layout

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  // ADD THIS
  xmlns:stream="http://schemas.android.com/apk/res-auto"
  ...>

  <com.github.niqdev.mjpeg.MjpegSurfaceView
    android:id="@+id/VIEW_NAME"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    stream:type="stream_default OR stream_native" />

</RelativeLayout>

and read the stream in your activity/fragment

Mjpeg.newInstance()
 .credential("USERNAME", "PASSWORD")
 .open("IPCAM_URL.mjpg")
 .subscribe(inputStream -> {
    mjpegView.setSource(inputStream);
    mjpegView.setDisplayMode(DisplayMode.BEST_FIT);
    mjpegView.showFps(true);
 });

Check the URL, I think problem with the URL. If you want to check the streaming ,you can check with your browser or VLC player which has to stream the link. I had used the same code which is perfectly streaming from the camera which is connected to the Robot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!