# Open Fullscreen Player

The `FireworkSdk.startPlayer()` method launches a fullscreen video player in a separate activity. This is useful when you want to play videos directly without embedding a FwVideoFeedView or FwStoryblock in your layout.

## Overview

Unlike `FwVideoFeedView` and `FwStoryBlockView`, which are embedded views, `FireworkSdk.startPlayer()` launches a standalone player activity that takes over the entire screen. This approach is ideal for:

* Opening specific videos from deep links
* Playing videos from custom UI elements (buttons, banners, etc.)
* Handling video notifications
* Creating custom video entry points

## Usage

`FireworkSdk.startPlayer()` has two variants:

### 1. Start Player with URL

Launch a specific video directly using its URL:

```kotlin
val viewOptions = ViewOptions.Builder()
    .playerOption(
        PlayerOption.Builder()
            .showShareButton(true)
            .enablePipMode(true)
            .build()
    )
    .build()

val result = FireworkSdk.startPlayer(
    viewOptions = viewOptions,
    url = "https://your-video-url"
)

when (result) {
    is PlayerLaunchResult.Success -> {
        // Player launched successfully
    }
    is PlayerLaunchResult.Failure -> {
        // Handle launch failure
        Log.e("Player", "Failed to launch player: ${result.message}")
    }
}
```

### 2. Start Player with Feed Configuration

Launch the player with a feed configuration, allowing users to browse through multiple videos:

```kotlin
val viewOptions = ViewOptions.Builder()
    .baseOption(
        BaseOption.Builder()
            .feedResource(FeedResource.Discovery)
            .build()
    )
    .playerOption(
        PlayerOption.Builder()
            .showShareButton(true)
            .enablePipMode(true)
            .build()
    )
    .build()

val result = FireworkSdk.startPlayer(viewOptions)

when (result) {
    is PlayerLaunchResult.Success -> {
        // Player launched successfully
    }
    is PlayerLaunchResult.Failure -> {
        // Handle launch failure
        Log.e("Player", "Failed to launch player: ${result.message}")
    }
}
```

## Using Kotlin DSL

For more concise syntax, use the DSL:

```kotlin
val viewOptions = viewOptions {
    baseOptions {
        feedResource(FeedResource.Discovery)
    }
    playerOptions {
        showShareButton(true)
        enablePipMode(true)
        autoPlayOnComplete(true)
    }
}

val result = FireworkSdk.startPlayer(viewOptions)
```

## Launch Result

Both variants return a `PlayerLaunchResult` that indicates success or failure:

```kotlin
sealed class PlayerLaunchResult {
    object Success : PlayerLaunchResult()
    class Failure(val message: String) : PlayerLaunchResult()
}
```

### Handling Results

```kotlin
when (val result = FireworkSdk.startPlayer(viewOptions, url)) {
    is PlayerLaunchResult.Success -> {
        // Player launched successfully
        // The player activity is now running
    }
    is PlayerLaunchResult.Failure -> {
        // Launch failed
        Toast.makeText(
            context,
            "Failed to open video: ${result.message}",
            Toast.LENGTH_SHORT
        ).show()
    }
}
```

## Configuration

The player can be configured using `ViewOptions`. Key options include:

### Player Appearance

```kotlin
val viewOptions = viewOptions {
    playerOptions {
        // Player mode
        playerMode(PlayerMode.FULL_BLEED_MODE)
        
        // UI elements
        showShareButton(true)
        showMuteButton(true)
        showFireworkLogo(false)
        
        // Playback behavior
        autoPlayOnComplete(true)
        autoplay(true)
    }
}
```

### Content Source

When not using a specific URL, configure the content source:

```kotlin
val viewOptions = viewOptions {
    baseOptions {
        // Discovery feed
        feedResource(FeedResource.Discovery)
        
        // Or specific playlist
        // feedResource(
        //     FeedResource.Playlist(
        //         channelId = "your_channel_id",
        //         playlistId = "your_playlist_id"
        //     )
        // )
    }
}
```

### Picture-in-Picture

Enable PIP mode to allow users to minimize the player:

```kotlin
val viewOptions = viewOptions {
    playerOptions {
        enablePipMode(true)
    }
}
```

## Player Launch Modes

You can configure the player activity launch mode:

```kotlin
// Set globally for all players
FireworkSdk.setPlayerLaunchMode(FwPlayerActivityLaunchMode.SINGLE_TASK)

// Then launch player
FireworkSdk.startPlayer(viewOptions)
```

Available launch modes:

* `SINGLE_TASK` - Standard single task launch mode
* `SINGLE_INSTANCE` - Single instance launch mode for complete isolation
* `SINGLE_TASK_WITH_OWN_AFFINITY` - Single task with custom affinity for separation

## Important Notes

* The SDK must be initialized before calling `startPlayer()`
* The player launches in a new activity, separate from your app's activity stack
* Always handle `PlayerLaunchResult.Failure` to provide user feedback
* ViewOptions can customize all aspects of player behavior
* The player handles its own lifecycle - no manual cleanup required
* URL variant is useful for specific videos, feed variant for browsing multiple videos

## Comparison with Other Widgets

| Feature                  | FwVideoFeedView | FwStoryBlockView | startPlayer()     |
| ------------------------ | --------------- | ---------------- | ----------------- |
| **Embedding**            | Embedded view   | Embedded view    | Separate activity |
| **Layout Control**       | Full control    | Full control     | No control        |
| **Thumbnail Display**    | Yes             | No               | No                |
| **Lifecycle Management** | Automatic       | Manual           | Automatic         |
| **Content Selection**    | User selects    | Auto-play        | Direct play       |
| **Return Result**        | No              | No               | Yes               |

## See Also

* [ViewOptions Configuration](/firework-for-developers/android-sdk/integration-guide/configuration.md) - Complete configuration options
* [PlayerOption](/firework-for-developers/android-sdk/integration-guide/configuration/player-options.md) - Player customization
* [BaseOption](/firework-for-developers/android-sdk/integration-guide/configuration/base-options.md) - Feed source configuration
* [Feed Sources](/firework-for-developers/android-sdk/integration-guide/feed-sources.md) - Available content sources


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.firework.com/firework-for-developers/android-sdk/integration-guide/fullscreen-player.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
