Package com.jwplayer.pub.api
Class JWPlayerFragment
java.lang.Object
Fragment
com.jwplayer.pub.api.JWPlayerFragment
- All Implemented Interfaces:
EventListener
,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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
getPlayerAsync
(Context context, LifecycleOwner lifecycleOwner, JWPlayerImpl.PlayerInitializationListener listener) static JWPlayerFragment
Creates a new JWPlayerFragment with a default configuration.static JWPlayerFragment
newInstance
(PlayerConfig playerConfig) Creates a new JWPlayerFragment with the given configuration.void
onConfigurationChanged
(Configuration newConfig) void
onCreate
(Bundle savedInstanceState) View
onCreateView
(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) void
onFullscreen
(FullscreenEvent fullscreenEvent) Fired when the player toggles fullscreen mode.void
setFullscreenOnDeviceRotate
(boolean fullscreenOnDeviceRotate)
-
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(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
-
getPlayer
-
getPlayerAsync
public void getPlayerAsync(Context context, LifecycleOwner lifecycleOwner, JWPlayerImpl.PlayerInitializationListener listener) -
onFullscreen
Fired when the player toggles fullscreen mode. Used to hide the action bar.- Specified by:
onFullscreen
in interfaceVideoPlayerEvents.OnFullscreenListener
- Parameters:
fullscreenEvent
- The payload that accompanies the onFullscreen() event.
-