1
votes

Hi all I developed xamarin media player by help of this link its working perfectly https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/video-player/ but I want to know how can I add a fullscreen icon and make it work in Xamarin video player . please Help enter image description here

1
It that renderer using a native video lib. or is it webview-based? – SushiHangover
using a native video librery (VideoPlayerRenderer) – Maalik

1 Answers

2
votes

You can use a custom renderer refer to this

To make the custom renderer work, I made some modification on the code:

First, replace the video renderer in your Android project with the custom video renderer, then move code in init method into VideoRenderer construcor and delete the init method, change the _context variable to Context and remove static:

Context _context;
double deviceWidth;
double deviceHeight;

then, use _context.GetActivity().RequestedOrientation instead of _context.RequestedOrientation in related method.

At last, icons need to be added to resource/drawable in Android, you can find the icon in the github issue link.

To make it full screen, need to hide extra UIs like:

var uiOpts = SystemUiFlags.LayoutStable 
                | SystemUiFlags.LayoutFullscreen 
                | SystemUiFlags.HideNavigation 
                | SystemUiFlags.LightStatusBar
                | SystemUiFlags.Immersive
                | SystemUiFlags.LayoutHideNavigation
                | SystemUiFlags.Fullscreen;

window.DecorView.SystemUiVisibility = (StatusBarVisibility)uiOpts;

and when exit full screen, clear the flags accordingly, here's a google doc for full screen

Hope it helps.