Player controls

The Wowza Flowplayer Android SDK contains built-in controls that can simplify the player's integration into your projects. You can use these controls to deliver a responsive and intuitive player interface in your Android applications. The controls are enabled by default and display over the player's user interface (UI) when incorporated.

For information related to listening to events, managing the player, and handling errors, see the following pages:

It may also be helpful to review the Flowplayer interface documentation since it contains all public functions to manage interactions with the player.

info

The code snippets on this page assume you've created a player instance and are reusing the top-level variable for your flowplayer instance throughout your project.

Manage built-in controls

The built-in controls are enabled by default and show over the FlowplayerView component of the Wowza Flowplayer Android SDK. If you wish to disable them to provide your own custom UI, you can use the setUseControls() method like so:

Copy
Copied
// Use a reference to your Wowza Flowplayer instance and setUseControls() method
flowplayer.setUseControls(false)

For additional information, see the setUseControls() reference documentation.

Configure player plugins

You can configure player plugins to replace and enhance the player's built-in controls. The following sample enables the pre-defined mute control, and adds the Speed Selection plugin with options and labels values:

Copy
Copied
// Use the PlayerControlConfig class for optional controls features
val config = PlayerControlConfig.Builder()

    // Enable mute control
    .setMuteControl(true)

    // Add the plugin with options and labels
    .enablePlugins(["speed"])
    .setCustom(key: "speed.options", value: [0.5, 1, 2, 5])
    .setCustom(key: "speed.labels", value: ["Slow", "Normal", "Double", "Fast"])
    .build()

// Use a reference to your Wowza Flowplayer instance and set optional control configurations
flowplayer.setControlConfig(config)

This table lists all supported player plugins.

Player plugin ID Description
Audio Selection asel Shows the audio selection options menu in the player's UI.
Quality Selection qsel Shows the quality selection options menu in the player's UI.
Speed Selection speed Shows the playback speed options menu in the player's UI.
Subtitles subtitles Shows the subtitles selection options menu in the player's UI.

Enter or exit full-screen mode

When the player enters full-screen mode, by default it displays on top of all other content and hides the system UI, including the system tray, the ActionBar, and the soft keys. See Customize full-screen behavior for information about managing the full-screen display.

With the default behavior, the FlowplayerView class also changes the activity's orientation to landscape every time it enters full-screen mode, and reverts to the portrait layout every time it exits the full-screen view. See Control orientation changes to learn how screen rotations affect the player's full-screen state.

Listen to key events in full-screen mode

While the player is in full-screen mode, you can't listen to key events in your activity. This happens because behind the scenes the player is moved into a full-screen dialog.

Dialogs on Android are shown in a separate window on top of the activity's window, causing the activity to lose focus for key events. When the player exits the full-screen display, the focus returns to your activity's window. If you want to listen to key events while the player is in full-screen mode, set a key listener to the player:

Copy
Copied
// Use a reference to your FlowplayerView instance and setOnKeyListener() method
flowplayerView.setOnKeyListener(listener)

Customize full-screen behavior

If you need to define a custom full-screen behavior, you can create a custom class that implements the FullscreenManager interface, which is used by the Flowplayer interface to manage full-screen behavior.

You can add your logic inside the enterFullscreen() and exitFullscreen() methods, then tell the player to use your custom manager as in the following snippet, where MyCustomFullscreenManager is your custom implementation of FullscreenManager. See the setFullscreenManager reference documentation for more.

Copy
Copied
// Create custom implementation of FullscreenManager
class MyCustomFullscreenManager: FullscreenManager {
    override fun enterFullscreen() {
        // your logic
    }

    override fun exitFullscreen() {
        // your logic
    }
}

// Use a reference to your Wowza Flowplayer instance and setFullscreenManager() method
flowplayer.setFullscreenManager(MyCustomFullscreenManager())

Every time the player enters or exits full-screen mode, your manager's enterFullscreen() and exitFullscreen() methods will be triggered.

info

The FullscreenManager interface is meant to handle layout changes as well as hide and show the system UI. Don't try to change the activity's orientation from a FullscreenManager implementation, as this may lead to unexpected results. See Control orientation changes for more information and to change the default orientation behavior.

Control orientation changes

With FlowplayerView

As mentioned, the FlowplayerView class changes the activity's orientation by default to landscape every time it enters full-screen mode, and to portrait every time it exits the full-screen view. You can disable this feature with this setting:

Copy
Copied
// Use a reference to your Wowza Flowplayer instance and setOnKeyListener() method
flowplayer.setFullscreenControlOrientation(false)

Suppose you've disabled the built-in player controls and, therefore, you only toggle the player's full-screen state programmatically. In that case, you can also tell the player to request a specific orientation whenever you change its full-screen state.

This can be achieved with a call to Flowplayer.setFullscreen(fullscreen: Boolean, requestedOrientation: Int) together with an orientation constant:

Copy
Copied
// Use a reference to your Wowza Flowplayer instance and setFullscreen() method
flowplayer.setFullscreen(true, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE)
info

The preceding info only works if you have disabled the built-in controls, since they use Flowplayer.setFullscreen(fullscreen: Boolean) and the default full-screen behavior. Otherwise, you may get unexpected results.

With FlowplayerSupportFragment

When you use FlowplayerSupportFragment, the player's full-screen state is tied to the activity's orientation by default.

This means that when the activity rotates to landscape, the player enters full-screen mode. Similarly, when the activity rotates to portrait, the player exits the full-screen view. This can be disabled by setting:

Copy
Copied
// Use a reference to your Wowza Flowplayer instance and setForceFullscreenOnLandscape() method
flowplayerFragment.setForceFullscreenOnLandscape(false)