Page 1 of 1

Issue with reattaching libvlc to new Surface

Posted: 13 Apr 2015 20:33
by tylerjroach
Hi,

I have been using libvlc 0.9.9 in an Android app for a while now. It has been working well, except for 4.4 devices and below hanging in some scenarios when calling vlc.stop(). It looks like the issue relates to the link here: http://comments.gmane.org/gmane.comp.vi ... evel/96116

I have attempted to upgrade to the newest version and all works well, except during device rotation. Here is the strategy I am using.

I am using a retainedFragment inside an Activity. I am creating the vlc player inside the retainedFragment. On rotation, I allow the activity to be destroyed, and the retainedFragment to be re-attached. The reason I am doing this is because the views are completely different for portrait and landscape. I would much prefer to use this approach rather than not allowing the activity to be destroyed and having to manually add and remove the portrait vs landscape views. I also did this in order to keep the video playing in the background while waiting for the new surface to come available.

In 0.9.9, I was able to call libvlc.detach() in SurfaceDestroyed and libvlc.attachSurface(mSurface, this) in SurfaceChanged(). By doing this, libvlc would attach itself to the newly created surface. However, the new versions of libvlc I have tried, including the most current, will not reattach to the newly created surface. Here's an example of what shows in the logs.

04-13 14:05:18.860 14767-15341/com.sparc.stream E/Surface﹕ dequeueBuffer failed (No such device)
04-13 14:05:18.860 14767-15341/com.sparc.stream W/VLC﹕ [7d8909cc] yuv_rgb_neon filter: can't get output picture

I'm not sure if anyone else is using the retained fragment method, but if so, could you share if you have gotten this working. I can work on posting code examples if that would help.

Thanks!

Tyler

Re: Issue with reattaching libvlc to new Surface

Posted: 14 Apr 2015 18:02
by rkrishnan2012
I am having the exact same issue on the latest build of VLC as well for android Lollipop. When i say setSurface() its not actually drawing on the new surface.

Re: Issue with reattaching libvlc to new Surface

Posted: 14 Apr 2015 23:15
by Jean-Baptiste Kempf
You cannot do that, of course, because of hardware decoding. You need to disable the video track first.

Re: Issue with reattaching libvlc to new Surface

Posted: 20 Apr 2015 16:52
by tylerjroach
Ahh, okay. Thank you! I'm assuming this will work like the new background playback I see in the recent commits and the ability to call setVideoTrack(). I'll update once I try this in case anyone else was curious.

Re: Issue with reattaching libvlc to new Surface

Posted: 20 Apr 2015 21:42
by Jean-Baptiste Kempf
in the end, yes, this is the goal.

Re: Issue with reattaching libvlc to new Surface

Posted: 21 Apr 2015 16:54
by tylerjroach
The suggestion worked perfectly!

libvlc.setVideoTrack(-1)
libvlc.setVideoTrack(0)

I do have one suggestion, however, unless I am missing something.
There is no getter such as libvlc.getVideoTrack(int track), or libvlc.getVideoTracks(int[] tracks).

On some videos that I have to play, the video track is 0, and others, the track is 1. In order to correctly reset the video track, I have to getAudioTrack() and set the opposite of whichever the audio track is.

Thank you!

Tyler