I have an activity having two framelayouts which are replaced by two fragments. one holds a video player (using videoView) and another a list of videos. like below
video_player_activity.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
tools:context="com.example.project.android.VideoPlayerActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/rl_video_player_relativi_layout"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:id="@+id/fl_player_activity_video_surfrace_container"
>
</FrameLayout>
</RelativeLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/rl_video_player_relativi_layout"
android:layout_marginTop="10dp"
android:id="@+id/fl_player_activity_video_list_container"
></FrameLayout>
VideoPlayerActivity.java
public class VideoPlayerActivity extends ActionBarActivity {
VideoPlayerFragment videoPlayerFragment;
VideoListFragment videoListFragment;
FragmentTransaction fragmentTransaction;
Bundle intentBundle;
private String videoUrl;
private CommonFunctions commonFunctions;
private String videoSubject;
private String videoLevel;
private Context context;
private int oldOptions;
private FrameLayout flVideoSurface;
RelativeLayout.LayoutParams fllp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_player);
intentBundle = getIntent().getExtras();
/* videoUrl = intentBundle.getString(projectGlobal.videoUrl);
videoSubject= intentBundle.getString(projectGlobal.videoSubject);
videoLevel = intentBundle.getString(projectGlobal.videoLevel);*/
context=this;
flVideoSurface=(FrameLayout) findViewById(R.id.fl_player_activity_video_surfrace_container);
fllp = new RelativeLayout.LayoutParams(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
//Log.d("video url ", videoUrl);
videoPlayerFragment = new VideoPlayerFragment();
videoPlayerFragment.setArguments(intentBundle);
fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fl_player_activity_video_surfrace_container, videoPlayerFragment);
fragmentTransaction.commit();
intentBundle.putString(projectGlobal.listBy, projectGlobal.mostViewed);
videoListFragment=new VideoListFragment();
videoListFragment.setArguments(intentBundle);
fragmentTransaction=getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fl_player_activity_video_list_container, videoListFragment);
fragmentTransaction.commit();
Log.d("second commit", "end");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_video_player, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
{
fragmentTransaction= getFragmentManager().beginTransaction();
fragmentTransaction.hide(videoListFragment);
fragmentTransaction.commit();
flVideoSurface.setLayoutParams(fllp);
flVideoSurface.forceLayout();
// projectGlobal.playerActivityVideoSurface.setDimensions(720,1184);
/*oldOptions = getWindow().getDecorView().getSystemUiVisibility();
int newOptions = oldOptions;
newOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE;
newOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN;
newOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
newOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE;
newOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
getWindow().getDecorView().setSystemUiVisibility(newOptions);
getSupportActionBar().hide();*/
}
else
{
fragmentTransaction=getFragmentManager().beginTransaction();
fragmentTransaction.show(videoListFragment);
fragmentTransaction.commit();
/*getWindow().getDecorView().setSystemUiVisibility(oldOptions);
getSupportActionBar().show();*/
}
}
}
i am able to bring both the fragments into activity using fragmentTransaction. The problem is when i try to full screen the video surface using the control's full screen button , or while landscape it doesn't go full screen. below is the code i am using in VideoPlayerFragment.java to make the view full screen
displayMetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().
getMetrics(displayMetrics);
fullScreenWidth=displayMetrics.widthPixels;
fullScreenHeight=displayMetrics.heightPixels;
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Log.d("config changed to ","landscapte");
videoSurface.setDimensions(fullScreenHeight,fullScreenWidth);
isOrientationPortrat=false;
isFullScreen = true;
} else {
Log.d("config changed to ","portrait");
isOrientationPortrat=true;
}
}
can anyone please help...! Thanks in advance !