Class JWPlayerFragment

java.lang.Object
Fragment
com.jwplayer.pub.api.JWPlayerFragment
All Implemented Interfaces:
EventListener, VideoPlayerEvents.OnFullscreenListener

public class JWPlayerFragment extends Fragment implements VideoPlayerEvents.OnFullscreenListener
This fragment is the simplest way to use a JW Player in your application. It's a wrapper around the JWPlayerView that takes care of it's lifecycle needs.

Being a fragment you can add this fragment to your layout using the following code below:

 
 <fragment
 	class="com.jwplayer.pub.api.JWPlayerFragment"
 	android:layout_width="match_parent"
 	android:layout_height="match_parent"/>
 
 

It is assumed that the enclosing android.app.Activity inherits (directly or indirectly) from androidx.appcompat.app.AppCompatActivity.

  • Constructor Details

    • JWPlayerFragment

      public JWPlayerFragment()
  • Method Details

    • newInstance

      public static JWPlayerFragment newInstance()
      Creates a new JWPlayerFragment with a default configuration.
      Returns:
      A new JWPlayerFragment containing a default JWPlayerView.
    • newInstance

      public static JWPlayerFragment newInstance(PlayerConfig playerConfig)
      Creates a new JWPlayerFragment with the given configuration.
      Parameters:
      playerConfig - the configuration to apply to the JWPlayerView.
      Returns:
      A new JWPlayerFragment with the applied configuration.
    • onCreate

      public void onCreate(Bundle savedInstanceState)
    • onCreateView

      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    • onConfigurationChanged

      public void onConfigurationChanged(Configuration newConfig)
    • setFullscreenOnDeviceRotate

      public void setFullscreenOnDeviceRotate(boolean fullscreenOnDeviceRotate)
      Parameters:
      fullscreenOnDeviceRotate - Whether device rotations should trigger fullscreen.
    • getPlayerView

      public JWPlayerView getPlayerView()
    • getPlayer

      public JWPlayer getPlayer()
    • getPlayerAsync

      public void getPlayerAsync(Context context, LifecycleOwner lifecycleOwner, JWPlayerImpl.PlayerInitializationListener listener)
    • onFullscreen

      public void onFullscreen(FullscreenEvent fullscreenEvent)
      Fired when the player toggles fullscreen mode. Used to hide the action bar.
      Specified by:
      onFullscreen in interface VideoPlayerEvents.OnFullscreenListener
      Parameters:
      fullscreenEvent - The payload that accompanies the onFullscreen() event.