NodeMedia RTMP/RTMFP/RTSP/HTTP Play/Publish Client SDK for Android
A simple, high-performance, low-latency live streaming SDK.
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.NodeMedia:NodeMediaClient-Android:3.2.9'
}
<uses-permission android:name="android.permission.INTERNET" />
<FrameLayout
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
private NodePlayer np;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_playview);
FrameLayout vv = findViewById(R.id.video_view);
np = new NodePlayer(this,"");
np.attachView(vv);
np.start("rtmp://192.168.0.2/live/demo");
}
@Override
protected void onDestroy() {
super.onDestroy();
np.detachView();
np.stop();
}
That’s it. Very simple!
<uses-feature android:name="android.hardware.camera.any" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
private static final String[] PERMISSIONS = new String[]{
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.CAMERA,
Manifest.permission.RECORD_AUDIO};
private static final int REQUEST_PERMISSION_CODE = 0XFF00;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
requestPermission();
……………………
}
private void requestPermission() {
ActivityCompat.requestPermissions(MainActivity.this, PERMISSIONS, REQUEST_PERMISSION_CODE);
}
<FrameLayout
android:id="@+id/camera_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
private NodePublisher np;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_publish_view);
FrameLayout fl = findViewById(R.id.camera_view);
np = new NodePublisher(this, "");
np.setAudioCodecParam(NodePublisher.NMC_CODEC_ID_AAC, NodePublisher.NMC_PROFILE_AUTO, 48000, 1, 64_000);
np.setVideoOrientation(NodePublisher.VIDEO_ORIENTATION_PORTRAIT);
np.setVideoCodecParam(NodePublisher.NMC_CODEC_ID_H264, NodePublisher.NMC_PROFILE_AUTO, 480, 854, 30, 1_000_000);
np.attachView(fl);
np.openCamera(true);
Button publishBtn = findViewById(R.id.publish_btn);
publishBtn.setOnClickListener((v) -> {
np.start("rtmp://192.168.0.2/live/demo");
});
}
@Override
protected void onDestroy() {
super.onDestroy();
np.detachView();
np.closeCamera();
np.stop();
}
https://cdn.nodemedia.cn/NodeMediaClient/NodeMediaClient-AndroidDemo.zip
A commercial license is required.
https://www.nodemedia.cn/product/nodemediaclient-android/