Version: 2.67.0

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

Thequestion above is related to the following questions:

  • How do you know when a video plays?
  • How do I know whether the playing event is triggered for an advertisement, or for the main content/stream?

You can use the playing event to know when content (or an ad) starts playing. The playingevent is described at Player API.  Its event handler is the correct scope to check whether an advertisement is playing through the property.


function playingEventHandler(event) {
var adIsPlaying =;
console.log("PLAYING", adIsPlaying ? "Advertisement" : "Content", event);
player.addEventListener("playing", playingEventHandler);

Android SDK

final EventListener<PlayingEvent> playingEventHandler = new EventListener<PlayingEvent>() {
public void handleEvent(PlayingEvent playingEvent) {
tpv.getPlayer().getAds().requestPlaying( new RequestCallback<Boolean>() {
public void handleResult(Boolean adIsPlaying) {
System.out.println("PLAYING " + (adIsPlaying ? "Advertisement" : "Content"));
tpv.getPlayer().addEventListener(PlayerEventTypes.PLAYING, playingEventHandler);

Please refer to How can we track the first play(ing) event?to read more about capturing the first playing event.