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

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 Web SDK exposes whether an advertisement is playing through [`player.ads.playing`](https://docs-preview.optiview.dolby.com/pr-863/theoplayer/v11/api-reference/web/interfaces/Ads#playing).

```js
player.addEventListener('playing', (event) => {
  const adIsPlaying = player.ads.playing;
  console.log('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/web/player/track-first-playing-event.md)
