RootEncoder icon indicating copy to clipboard operation
RootEncoder copied to clipboard

[Question] rtmpdisplay disconnect self suddenly

Open RX1226 opened this issue 8 years ago • 2 comments

Device: HTC_A9u Android 7.0 IDE: Android Studio 3.1.3 on Mac with Java 8.0 Sdk Version: min = 21, target = 27, compile = 27

I want to screencast my playing game app and stream it to server.

code step: // I try it in (a.) activity and (b.) IntentService (c.) use getApplicationContext(), when onCreate()

  1. rtmpDisplay = new RtmpDisplay(this, false,this);
  2. startActivityForResult(rtmpDisplay.sendIntent(), REQUEST_SCREEN_RECORD);
  3. rtmpDisplay.prepareAudio() && rtmpDisplay.prepareVideo(width, height, 30, 1000 * 1024, 0, 320)
  4. rtmpDisplay.setIntentResult(resultCode, data);
  5. rtmpDisplay.startStream(rtmpUrl); then I can start rtmp success I open a ALERT_WINDOW to control the rtmp. The connect will disconnect self suddenly(about 1s ~ 30m) when I open other app.

I don't want it stop by itself. Is any wrong or step I need to do for this case? Thank you for watch it.

RX1226 avatar Sep 27 '18 04:09 RX1226

Is my example working for you? Remember that you can't close app totally (only send to background) or your rtmpdisplay object will be recycled. For example, in my example, start stream and press home button to send background (you know that work because when you reopen app and go to activity you will see stop stream instead of start stream).

Other way is do a service that no die when you close app (foreground service): https://stackoverflow.com/questions/42126979/cannot-keep-android-service-alive-after-app-is-closed

pedroSG94 avatar Sep 27 '18 06:09 pedroSG94

I use foreground service success, thank you.

RX1226 avatar Sep 28 '18 06:09 RX1226