# Floating Window (Android)

## Setting Up `Floating Window`

To set up the Floating Window the host application must invoke the `init()` function, which requires both the context and the embed Id. These are essential fields, embed id  can be obtained from the live2.ai dashboard.

```kotlin
Kotlin:

val floatingWindow: FloatingWindow = findViewById(R.id.floatingWindow)
floatingWindow.init(this, FLOATING_WINDOW_EMBED)
```

## Floating Window Layout

&#x20;XML Layout:

```xml
<com.live2.media.ui.floatingwindow.FloatingWindow
        android:id="@+id/floatingWindow"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:autoplayNextVideo="true"
        app:enableDrag="true"
        >
    </com.live2.media.ui.floatingwindow.FloatingWindow>
```

* If `autoplayNextVideo="true"`, videos will automatically play one after another. If set to "false," the next video won't play automatically.
* Setting `autoplayNextVideo` to "true" ensures continuous playback of videos without manual intervention. Setting it to "false" stops this functionality.
* If `enableDrag="true"`, you can drag the video across the entire L1 screen. If set to "false," this feature is disabled.
* The `enableDrag` attribute allows for video repositioning on the screen when set to "true"; disabling it restricts movement.

## Note: &#x20;

Setting `android:layout_width="match_parent"` and `android:layout_height="match_parent"` is essential, without it, the video won't be draggable.
