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();
body.addElement(videoContainer);
Button fullscreenBtn = new Button("Fullscreen");
fullscreenBtn.registerListener(this, MouseClickedEvent.class);
body.addElement(fullscreenBtn);
}
@Override
public void onEvent(MouseClickedEvent event)
{
FullscreenApi.requestFullscreen(this, videoContainer);
}
@Override
public void onEvent(FullscreenChangeEvent event)
{
if (event.isFullscreen())
{
// Entered fullscreen
}
else
{
// Exited fullscreen
}
}
@Override
public void onEvent(FullscreenErrorEvent event)
{
showMessage("Fullscreen failed: " + event.getMessage());
}
}
- 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(HtmlPage page, FullscreenListener listener) Requests fullscreen mode for the document.static voidrequestDocumentFullscreen(FullscreenListener listener) Requests fullscreen mode for the document using the current page context.static voidrequestFullscreen(HtmlPage page, FullscreenListener listener, Element element) Requests fullscreen mode for an element.static voidrequestFullscreen(FullscreenListener listener, Element element) Requests fullscreen mode for an element using the current page context.static voidtoggleFullscreen(HtmlPage page, FullscreenListener listener, Element element) Toggles fullscreen mode for an element.static voidtoggleFullscreen(FullscreenListener listener, Element element) Toggles fullscreen mode for an element using the current page context.
-
Constructor Details
-
FullscreenApi
public FullscreenApi()
-
-
Method Details
-
requestFullscreen
Requests fullscreen mode for an element using the current page context.- Parameters:
listener- The listener that will receive fullscreen events.element- The element to display in fullscreen mode.
-
requestFullscreen
Requests fullscreen mode for an element.- Parameters:
page- The page context.listener- The listener that will receive fullscreen events.element- The element to display in fullscreen mode.
-
requestDocumentFullscreen
Requests fullscreen mode for the document using the current page context.- Parameters:
listener- The listener that will receive fullscreen events.
-
requestDocumentFullscreen
Requests fullscreen mode for the document.- Parameters:
page- The page context.listener- The listener 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:
listener- The listener that will receive fullscreen events.element- The element to toggle fullscreen mode for.
-
toggleFullscreen
Toggles fullscreen mode for an element.- Parameters:
page- The page context.listener- The listener that will receive fullscreen events.element- The element to toggle fullscreen mode for.
-