FullScreen is not working
See original GitHub issueThis lib is awesome, video plaing very well, but i can not do the fullscreen. I used helper class from sample, but all that changes is screen orientation, and that all. My manifest contains this line android:configChanges=“orientation|screenSize|keyboardHidden|smallestScreenSize|screenLayout”
This is my code:
package shop.arvaal.com.shop;
public class CardProduct extends Fragment {
private String attribute_text;
private TextView attrib;
private TextView tvPrice;
private TextView currentColorText;
private TextView tvPriceSpecial;
private TextView option_hint;
private FullScreenYouTube fullScreenHelper;
private ArrayList<String> imageUrls;
private JSONObject product;
private ArrayList<String> currentColor;
private YouTubePlayerView youtubePlayerView;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.card_product, container, false);
fullScreenHelper = new FullScreenYouTube(getActivity());
mRecyclerView = view.findViewById(R.id.my_recycler_view);
mLayoutManager = new LinearLayoutManager(getActivity(),LinearLayoutManager.HORIZONTAL, false);
SnapHelper snapHelper = new LinearSnapHelper();
snapHelper.attachToRecyclerView(mRecyclerView);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setHasFixedSize(true);
indicator = view.findViewById(R.id.circleIndicator);
youtubePlayerView = view.findViewById(R.id.youtube_player_view);
getLifecycle().addObserver(youtubePlayerView);
final TextView button_text = view.findViewById(R.id.description_text_button);
button_text.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
button_text.setText(decription_product.isExpanded() ? R.string.expand : R.string.collapse);
decription_product.toggle();
}
});
makeJsonObjectRequest(urlJsonObj+getArguments().getInt("someInt")+key);
return view;
}
******************************
if(product.getString("youtube_code").equals("empty")){
youtubeContainer.setVisibility(View.GONE);
}else {
youtubePlayerView.initialize(new YouTubePlayerInitListener() {
@Override
public void onInitSuccess(@NonNull final YouTubePlayer initializedYouTubePlayer) {
initializedYouTubePlayer.addListener(new AbstractYouTubePlayerListener() {
@Override
public void onReady() {
initializedYouTubePlayer.cueVideo(product.optString("youtube_code"), 0);
}
});
addFullScreenListenerToPlayer(initializedYouTubePlayer);
}
}, true);
}
*********************************************
private void addFullScreenListenerToPlayer(final YouTubePlayer youTubePlayer) {
youtubePlayerView.addFullScreenListener(new YouTubePlayerFullScreenListener() {
@Override
public void onYouTubePlayerEnterFullScreen() {
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
fullScreenHelper.enterFullScreen()
}
@Override
public void onYouTubePlayerExitFullScreen() {
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
fullScreenHelper.exitFullScreen();
}
});
}
@Override public void onDestroy() {
super.onDestroy();
youtubePlayerView.release()
}
}
This is helper class:
package shop.arvaal.com.shop;
import android.app.Activity;
import android.view.View;
public class FullScreenYouTube{
private Activity context;
private View[] views;
/**
* @param context
* @param views to hide/show
*/
public FullScreenYouTube(Activity context, View ... views) {
this.context = context;
this.views = views;
}
/**
* call this method to enter full screen
*/
public void enterFullScreen() {
View decorView = context.getWindow().getDecorView();
hideSystemUI(decorView);
for(View view : views) {
view.setVisibility(View.GONE);
view.invalidate();
}
}
/**
* call this method to exit full screen
*/
public void exitFullScreen() {
View decorView = context.getWindow().getDecorView();
showSystemUI(decorView);
for(View view : views) {
view.setVisibility(View.VISIBLE);
view.invalidate();
}
}
private void hideSystemUI(View mDecorView) {
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
private void showSystemUI(View mDecorView) {
mDecorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
9 Tested Ways to Fix Chrome if Full Screen Is Not Working
What can I do if Full Screen isn't working on Google Chrome? · 1. Update Chrome · 2. Reinstall Chrome · 3. Disable...
Read more >11 Ways To Fix Full Screen Not Working On Chrome
How to Fix Full Screen Not Working · Refresh the Chrome Tab · Restart Chrome · Update Your Chrome · Uninstall Your Chrome...
Read more >Chrome Won't Go Full Screen - Easy Fixes! - Silicophilic
Fix: Chrome Won't Go Fullscreen · Fix 1: Check The Flash Players · Fix 2: Clear Chrome Browsing history And Check In Incognito...
Read more >Full Screen issues on Windows 10? - Help Center
1. Go to the Options / Menu / Settings inside the game (not all games have this). Select Full-Screen On (or Off). ·...
Read more >Chrome Full screen is not working [Fixed] - The Windows Club
Fix Chrome Full screen is not working · Restart Chrome · Disable Hardware Acceleration · Delete Browsing Data and Cache · Reset Chrome...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @edward1988, The problem is with the recyclerView item and its’ height. You should either change recyclerView Item’s heigth on ‘full screen’ click, or navigate to other Activity/Fragment which has only YoutubePlayerView.
so how can i full screen the video pls help