Package com.oorian.html.js.fullscreen
Class FullscreenApi
java.lang.Object
com.oorian.html.js.JavaScriptApi
com.oorian.html.js.fullscreen.FullscreenApi
Provides access to the browser's Fullscreen API from server-side Java code.
This class wraps the browser's Fullscreen API, enabling server-side code to request fullscreen mode for elements or the entire document.
Usage:
public class VideoPage extends HtmlPage implements FullscreenListener {
private Div videoContainer;
@Override
protected void createBody(Body body) {
videoContainer = new Div();
videoContainer.registerListener(this, FullscreenChangeEvent.class);
body.addElement(videoContainer);
Button fullscreenBtn = new Button("Fullscreen");
fullscreenBtn.registerListener((MouseClickedEvent e) -> {
FullscreenApi.requestFullscreen(videoContainer);
}, MouseClickedEvent.class);
body.addElement(fullscreenBtn);
}
@Override
public void onEvent(FullscreenChangeEvent event) {
if (event.isFullscreen()) {
// Entered fullscreen
} else {
// Exited fullscreen
}
}
}
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidExits fullscreen mode using the current page context.static voidexitFullscreen(HtmlPage page) Exits fullscreen mode.static voidrequestDocumentFullscreen(Element element) Requests fullscreen mode for the document using the current page context.static voidrequestDocumentFullscreen(HtmlPage page, Element element) Requests fullscreen mode for the document.static voidrequestFullscreen(Element element) Requests fullscreen mode for an element using the current page context.static voidrequestFullscreen(HtmlPage page, Element element) Requests fullscreen mode for an element.static voidtoggleFullscreen(Element element) Toggles fullscreen mode for an element using the current page context.static voidtoggleFullscreen(HtmlPage page, Element element) Toggles fullscreen mode for an element.
-
Constructor Details
-
FullscreenApi
public FullscreenApi()
-
-
Method Details
-
requestFullscreen
Requests fullscreen mode for an element using the current page context.- Parameters:
element- The element to display in fullscreen mode.
-
requestFullscreen
Requests fullscreen mode for an element.- Parameters:
page- The page context.element- The element to display in fullscreen mode.
-
requestDocumentFullscreen
Requests fullscreen mode for the document using the current page context.- Parameters:
element- The element that will receive fullscreen events.
-
requestDocumentFullscreen
Requests fullscreen mode for the document.- Parameters:
page- The page context.element- The element that will receive fullscreen events.
-
exitFullscreen
public static void exitFullscreen()Exits fullscreen mode using the current page context. -
exitFullscreen
Exits fullscreen mode.- Parameters:
page- The page context.
-
toggleFullscreen
Toggles fullscreen mode for an element using the current page context.- Parameters:
element- The element to toggle fullscreen mode for.
-
toggleFullscreen
Toggles fullscreen mode for an element.- Parameters:
page- The page context.element- The element to toggle fullscreen mode for.
-