Android RTSP player using libVLC: how to resume play output after activity resume?

This forum is about all development around libVLC.
bismackvlc
New Cone
New Cone
Posts: 2
Joined: 30 Nov 2024 05:58

Android RTSP player using libVLC: how to resume play output after activity resume?

Postby bismackvlc » 30 Nov 2024 08:42

I have an Android app using libVLC to play RTSP stream and attach a Surface as the video output; I want the libvlc player to continue receiving and decoding the RTSP stream when the app is sent to background temporarily, so that it can resume video output as soon as it becomes foreground again.

But when the app is sent to background, the output Surface will get destroyed and playback fails. So I am searching for any solution to "dynamically" setup or switch the VLC video output; here is what have been tried but not work:
call detachViews() in Actiivty.onPause() then call attachViews() in Activity.onResume(), android reports error "Failed to connect to surface err -19". it seems that the recreated Surface for video output is not actually updated to the libvlc player by the call to attachViews() in Activity.onResume().
Also from the comments of IVLCVout.attachviews: "This must be called afters views are set and before the MediaPlayer is first started". It seems that after the MediaPlayer is first started, no more attachViews() can be done to switch or update the Vout.

Is there any existing solution in libvlc to implement it?
Does libVLC for Android design consider such situation: during video playback, the Vout becomes unavailable, and the user wants it to continue the playback (by throwing away the decoded frames?), and create another Vout for it to resume the video output?
Thanks!

mfkl
Developer
Developer
Posts: 746
Joined: 13 Jun 2017 10:41

Re: Android RTSP player using libVLC: how to resume play output after activity resume?

Postby mfkl » 02 Dec 2024 13:11

Please study the vlc-android code which accounts for this use case, as you can test in the VLC Android app.
https://mfkl.github.io

bismackvlc
New Cone
New Cone
Posts: 2
Joined: 30 Nov 2024 05:58

Re: Android RTSP player using libVLC: how to resume play output after activity resume?

Postby bismackvlc » 04 Dec 2024 07:40

I did do some study of the code and test with Android app. The Surface can be changed by the call to attachView() or setVideoSurface(), but that change only happens inside the AWindow class, and it then depends on the native layer to call its getVideoSurface() to get the changed Surface. But how to trigger the native layer to do so without restart the MediaPlayer? Or any other APIs?
Could you give some hint or keywords for me to continue? Thanks
Please study the vlc-android code which accounts for this use case, as you can test in the VLC Android app.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 4 guests