StreamLayer Element Visibility Guide

Respond to StreamLayer Element visibility changes in your iOS app to adjust your UI accordingly.

When the StreamLayer Element opens or closes, your app may need to adjust its interface — for example, hiding player controls or resizing the video. The SLROverlayDelegate provides a callback for tracking these visibility changes.

Detect Visibility Changes

Implement the handleActionShown delegate method to respond when the StreamLayer Element opens or closes:

SLRVideoPlayer: SLROverlayDelegate {
  
  public func handleActionShown(_ action: SLRActionShown) {
    if action.source == .overlay {
      if action.isShown {
        print("overlay opened")
      } else {
        print("overlay closed")
      }
    }
  }

}

Use the action.source property to distinguish between different types of visibility events, and action.isShown to determine whether the element is now visible or hidden.


Related