
Android playerView not visible in my activity
I got an activity that display the content of a WP article : a title, a content, an image, and a video.
Image and video are url (string). I want to Instantiate a JWPlayerView programmatically, so I got no JWPlayerView tag in my xml, but i want to display it on a linearlayout.
PlayerConfig playerConfig = new PlayerConfig.Builder()
.file(urlVideo)
.build();
JWPlayerView playerView = new JWPlayerView(context, playerConfig);
linearLayout.addView(playerView);
When I launch my app, I see briefly a loading sign where the video is supposed to be played, but it quickly disappear and nothing happend after : I can't see the player.
If i add this line : playerView.setMinimumHeight(300); it works, but when I switch to fullscreen mode (when I rotate screen or click on fullscreen button), the video switch in full screen mode (everything else dissapear) but it only occuped the height define in setMinimumHeight and the remaining is fill with white background.
Is there a way to better define a specific height, and switch to full screen when needed?
Here's my onConfigurationChanged() method to switch to fullScreen :
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Log.i("orientation", String.valueOf(newConfig.orientation));
Log.i("getFullScreen", String.valueOf(playerView.getFullscreen()));
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
if(playerView.getFullscreen()) {
playerView.setFullscreen(false, true);
}
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
if(!playerView.getFullscreen()) {
playerView.setFullscreen(true, true);
}
}
}