Android RTSP player using libVLC: how to resume play output after activity resume?
Posted: 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!
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!