Package com.jwplayer.pub.api
Class JWPlayerFragment
java.lang.Object
androidx.fragment.app.Fragment
com.jwplayer.pub.api.JWPlayerFragment
- All Implemented Interfaces:
android.content.ComponentCallbacks,android.view.View.OnCreateContextMenuListener,androidx.lifecycle.LifecycleOwner,androidx.lifecycle.ViewModelStoreOwner,androidx.savedstate.SavedStateRegistryOwner,EventListener,VideoPlayerEvents.OnFullscreenListener
public class JWPlayerFragment
extends androidx.fragment.app.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 Activity inherits (directly or indirectly) from
AppCompatActivity.
-
Nested Class Summary
Nested classes/interfaces inherited from class androidx.fragment.app.Fragment
androidx.fragment.app.Fragment.InstantiationException, androidx.fragment.app.Fragment.SavedState -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgetPlayerAsync(android.content.Context context, androidx.lifecycle.LifecycleOwner lifecycleOwner, JWPlayerImpl.PlayerInitializationListener listener) static JWPlayerFragmentCreates a new JWPlayerFragment with a default configuration.static JWPlayerFragmentnewInstance(PlayerConfig playerConfig) Creates a new JWPlayerFragment with the given configuration.voidonConfigurationChanged(android.content.res.Configuration newConfig) voidonCreate(android.os.Bundle savedInstanceState) android.view.ViewonCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState) voidonFullscreen(FullscreenEvent fullscreenEvent) Fired when the player toggles fullscreen mode.voidsetFullscreenOnDeviceRotate(boolean fullscreenOnDeviceRotate) Methods inherited from class androidx.fragment.app.Fragment
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLayoutInflater, getLifecycle, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSavedStateRegistry, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, getViewLifecycleOwner, getViewLifecycleOwnerLiveData, getViewModelStore, hashCode, hasOptionsMenu, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isMenuVisible, isRemoving, isResumed, isStateSaved, isVisible, onActivityCreated, onActivityResult, onAttach, onAttach, onAttachFragment, onContextItemSelected, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroy, onDestroyOptionsMenu, onDestroyView, onDetach, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, onResume, onSaveInstanceState, onStart, onStop, onViewCreated, onViewStateRestored, postponeEnterTransition, postponeEnterTransition, registerForContextMenu, requestPermissions, requireActivity, requireArguments, requireContext, requireFragmentManager, requireHost, requireParentFragment, requireView, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenu
-
Constructor Details
-
JWPlayerFragment
public JWPlayerFragment()
-
-
Method Details
-
newInstance
Creates a new JWPlayerFragment with a default configuration.- Returns:
- A new JWPlayerFragment containing a default JWPlayerView.
-
newInstance
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(android.os.Bundle savedInstanceState) - Overrides:
onCreatein classandroidx.fragment.app.Fragment
-
onCreateView
@Nullable public android.view.View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState) - Overrides:
onCreateViewin classandroidx.fragment.app.Fragment
-
onConfigurationChanged
public void onConfigurationChanged(android.content.res.Configuration newConfig) - Specified by:
onConfigurationChangedin interfaceandroid.content.ComponentCallbacks- Overrides:
onConfigurationChangedin classandroidx.fragment.app.Fragment
-
setFullscreenOnDeviceRotate
public void setFullscreenOnDeviceRotate(boolean fullscreenOnDeviceRotate) - Parameters:
fullscreenOnDeviceRotate- Whether device rotations should trigger fullscreen.
-
getPlayerView
-
getPlayer
-
getPlayerAsync
public void getPlayerAsync(android.content.Context context, androidx.lifecycle.LifecycleOwner lifecycleOwner, JWPlayerImpl.PlayerInitializationListener listener) -
onFullscreen
Fired when the player toggles fullscreen mode. Used to hide the action bar.- Specified by:
onFullscreenin interfaceVideoPlayerEvents.OnFullscreenListener- Parameters:
fullscreenEvent- The payload that accompanies the onFullscreen() event.
-