4.0: Video surface is not visible although vout window opened with the correct size
Description
With the simple example code from libvlc-android-sample, the display is black until the phone is rotated.
@Override
protected void onStart() {
super.onStart();
mMediaPlayer.attachViews(mVideoLayout, null, ENABLE_SUBTITLES, USE_TEXTURE_VIEW);
final Media media = new Media(mLibVLC, Uri.parse("http://192.168.1.19:8000/dog_meme.mp4"));
mMediaPlayer.setMedia(media);
media.release();
mMediaPlayer.play();
assert(mMediaPlayer.getVLCVout().areViewsAttached());
}
A workaround is actually possible in the application through the handling of the following event, and is actually what the VLC for Android application is doing.
@Override
public void onEvent(MediaPlayer.Event event) {
switch(event.type) {
case MediaPlayer.Event.Vout:
mMediaPlayer.updateVideoSurfaces()
break;
default:
break;
}
}
I'll integrate this workaround in the libvlc binding to avoid every application to handle this undocumented case, but the real issue will remain.
My wild guess is that the layout are not updated in sync and the resizing events are getting to libvlc (in a blocking mode) before the actual video views are resized, thus calling updateVideoSurfaces()
before libvlc is opening doesn't change anything whereas posting it in the handler of the main thread fixes the issue.
Expected behavior
The video appears on the screen.
Actual behavior
The video appears black until the screen is rotated, although libvlc opens the vout window and vout display with the correct size.
Steps to reproduce
- Compile libvlc-android-sample with libvlc 4
- Launch