# How do you know when a stream or an advertisement is playing on iOS?

This guide explains how to determine programmatically when the player is playing, and whether it is playing a stream or a client-side advertisement. This is useful when you want different behavior, or a different UI, for content and for advertisements.

The `playing` event tells you when content or an advertisement starts playing. Its event handler is the right place to check whether an advertisement is playing.

This approach only works for client-side advertisements, not for server-side advertisements.

## Usage

The iOS SDK exposes whether an advertisement is playing through [`player.ads.playing`](https://docs-preview.optiview.dolby.com/pr-863/theoplayer/v11/api-reference/ios/Protocols/Ads#/s:13THEOplayerSDK3AdsP7playingSbvp).

```swift
playingListener = player.addEventListener(type: PlayerEventTypes.PLAYING) { [weak self] event in
    guard let self else { return }
    let adIsPlaying = self.player.ads.playing
    print("PLAYING", adIsPlaying ? "Advertisement" : "Content", event)
}
```

## Related articles

* [How to track the first play(ing) event](https://docs-preview.optiview.dolby.com/pr-863/theoplayer/how-to-guides/ios/player/track-first-playing-event.md)
