https://github.com/perthcpe23/android-mjpeg-view
Custom View to display MJPEG
https://github.com/perthcpe23/android-mjpeg-view
android android-mjpeg ip-cam ip-camera ipcam ipcamera mjpeg mjpeg-stream
Last synced: 5 months ago
JSON representation
Custom View to display MJPEG
- Host: GitHub
- URL: https://github.com/perthcpe23/android-mjpeg-view
- Owner: perthcpe23
- License: mit
- Created: 2015-05-06T10:48:04.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2025-12-26T11:41:39.000Z (5 months ago)
- Last Synced: 2025-12-27T23:38:38.062Z (5 months ago)
- Topics: android, android-mjpeg, ip-cam, ip-camera, ipcam, ipcamera, mjpeg, mjpeg-stream
- Language: Java
- Size: 2.13 MB
- Stars: 65
- Watchers: 8
- Forks: 21
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# android-mjpeg-view
Android custom View for displaying MJPEG stream.
- This custom view only requires a specific http(s) url.
- Supported image scaling methods are fit width, fit height, original size, stretch and best fit.
- Only boundary is used to separate each jpeg image (i.e. each frame) from a stream. Content-length is ignored.
- A boundary must be specified in an HTTP headr (Content-type), otherwise a default boundary pattern will be used.
Basic usage
1. This library is hosted on Maven Central, so make sure you added `mavenCentral()` as one of repositories
```gradle
dependencyResolutionManagement {
...
repositories {
...
mavenCentral()
}
}
```
2. Include a library in to your project by adding this to app level build.gradle file.
```gradle
dependencies {
...
implementation 'com.perthcpe23.dev:android-mjpeg-view:1.1.2'
}
```
3. Add a view to XML layout:
````xml
````
4. Specify mjpeg source and start streaming
````java
MjpegView viewer = (MjpegView) findViewById(R.id.mjpegview);
viewer.setMode(MjpegView.MODE_FIT_WIDTH);
viewer.setAdjustHeight(true);
viewer.setSupportPinchZoomAndPan(true);
viewer.setUrl("https://app.punyapat.me/mjpeg-server/mjpeg");
viewer.startStream();
//when user leaves application
viewer.stopStream();
````
5. Or Android Compose (skip #3 and #4)
```kotlin
MyApplicationTheme {
Surface(
modifier = Modifier.fillMaxSize(),
) {
AndroidView(
modifier = Modifier.fillMaxSize(),
factory = { context ->
MjpegView(context).apply {
mode = MjpegView.MODE_FIT_WIDTH
isAdjustHeight = true
supportPinchZoomAndPan = true
setUrl("https://app.punyapat.me/mjpeg-server/mjpeg")
startStream()
}
},
)
}
}
```
6. Don't forget to add internet access permission to Android manifests file
````java
````
* You can also download .aar at https://github.com/perthcpe23/android-mjpeg-view/tree/master/aar
# Contact
perth.s28@gmail.com