Class FullscreenApi

java.lang.Object
com.oorian.html.js.JavaScriptApi
com.oorian.html.js.fullscreen.FullscreenApi

public class FullscreenApi extends JavaScriptApi
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 Details

    • FullscreenApi

      public FullscreenApi()
  • Method Details

    • requestFullscreen

      public static void requestFullscreen(FullscreenListener listener, Element element)
      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

      public static void requestFullscreen(HtmlPage page, FullscreenListener listener, Element element)
      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

      public static void requestDocumentFullscreen(FullscreenListener listener)
      Requests fullscreen mode for the document using the current page context.
      Parameters:
      listener - The listener that will receive fullscreen events.
    • requestDocumentFullscreen

      public static void requestDocumentFullscreen(HtmlPage page, FullscreenListener listener)
      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

      public static void exitFullscreen(HtmlPage page)
      Exits fullscreen mode.
      Parameters:
      page - The page context.
    • toggleFullscreen

      public static void toggleFullscreen(FullscreenListener listener, Element element)
      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

      public static void toggleFullscreen(HtmlPage page, FullscreenListener listener, Element element)
      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.