# What is the preferred way to use play/onPlay methods?

**URL:** <https://community.wowza.com/t/what-is-the-preferred-way-to-use-play-onplay-methods/43815>\
**Category:** Wowza Streaming Engine\
**Created:** [September 24, 2014, 5:28pm UTC](https://community.wowza.com/t/what-is-the-preferred-way-to-use-play-onplay-methods/43815 "2014-09-24T17:28:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mauricio\_Antunes](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@Mauricio\_Antunes](https://community.wowza.com/u/Mauricio_Antunes)\
**Post date:** [September 24, 2014, 5:28pm UTC](https://community.wowza.com/t/what-is-the-preferred-way-to-use-play-onplay-methods/43815/1 "2014-09-24T17:28:57Z")

</div>

I am trying to create something like this:

[https://www.wowza.com/docs/how-to-log-play-statistics-on-a-timer](https://www.wowza.com/docs/how-to-log-play-statistics-on-a-timer)

But for RTMP, RTSP and HTTP inside the same module.

I am using onPlay to create a “watchdog” for RTMP and RTSP. Should I use play/onDisconnect to RTMP? Should I use onRTPSessionCreate/Destroy for RTSP? Should I use onHTTPSessionCreate/Destroy for HTTP (san jose, cuppertino, etc)?

---

<div class="post-metadata">

**Author:** ![Mauricio\_Antunes](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@Mauricio\_Antunes](https://community.wowza.com/u/Mauricio_Antunes)\
**Post date:** [September 25, 2014, 7:30pm UTC](https://community.wowza.com/t/what-is-the-preferred-way-to-use-play-onplay-methods/43815/2 "2014-09-25T19:30:31Z")

</div>

Ping.

---

<div class="post-metadata">

**Author:** ![Matt\_Young](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/matt_young/32/389_2.png) [@Matt\_Young](https://community.wowza.com/u/Matt_Young)\
**Post date:** [September 26, 2014, 3:42am UTC](https://community.wowza.com/t/what-is-the-preferred-way-to-use-play-onplay-methods/43815/3 "2014-09-26T03:42:11Z")

</div>

You could take a look at the following to extend that example accordingly:

See [Richard’s response](https://www.wowza.com/forums/showthread.php?10676-Article-How-to-log-play-statistics-on-a-timer&p=130956#post130956) and note the following:

> For RTSP, utilize the [IRTSPActionNotify](https://www.wowza.com/docs/how-to-use-the-irtspactionnotify-interface-to-listen-for-rtsp-stream-events) interface of which leverages the onRTPSessionCreate.

> For HTTP, you can use the onHTTPSessionCreate event handler as you’ve suggested as well (should cover all http related protocols).

> RTMP is the default mechanism involved here, so you can keep this as-is.

Alternatively, you could create a general thread that executes every ‘x’ number of seconds and iterates through all the clients to get the corresponding information and reports it in a similar fashion. You can see how to obtain a count/list of connected clients by protocol via the HTTP Provider found [here](https://www.wowza.com/docs/how-to-get-detailed-server-info-with-an-http-provider) (see second example).

Thanks,

Matt

---

<div class="post-metadata">

**Author:** ![Matt\_Young](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/matt_young/32/389_2.png) [@Matt\_Young](https://community.wowza.com/u/Matt_Young)\
**Post date:** [September 30, 2014, 5:31am UTC](https://community.wowza.com/t/what-is-the-preferred-way-to-use-play-onplay-methods/43815/4 "2014-09-30T05:31:21Z")

</div>

Sorry for the confusion, I was suggesting that the module referred to [here](https://www.wowza.com/docs/how-to-log-play-statistics-on-a-timer) utilizes the IMediaStreamActionNotify3 interface of which will handle rtmp play events.

---

<div class="post-metadata">

**Author:** ![Mauricio\_Antunes](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@Mauricio\_Antunes](https://community.wowza.com/u/Mauricio_Antunes)\
**Post date:** [September 26, 2014, 9:41am UTC](https://community.wowza.com/t/what-is-the-preferred-way-to-use-play-onplay-methods/43815/5 "2014-09-26T09:41:32Z")

</div>

The problem with the HTTP Provider is that it has the overhead of HTTP protocol.

Also, it does not catch events like play/stop.

Thanks for the answer though. That IRTSPActionNotify looks useful.

---

<div class="post-metadata">

**Author:** ![Mauricio\_Antunes](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@Mauricio\_Antunes](https://community.wowza.com/u/Mauricio_Antunes)\
**Post date:** [September 26, 2014, 2:19pm UTC](https://community.wowza.com/t/what-is-the-preferred-way-to-use-play-onplay-methods/43815/6 "2014-09-26T14:19:30Z")

</div>

What do you mean by:

> RTMP is the default mechanism involved here, so you can keep this as-is.

?

---

<div class="post-metadata">

**Author:** ![Mauricio\_Antunes](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@Mauricio\_Antunes](https://community.wowza.com/u/Mauricio_Antunes)\
**Post date:** [September 29, 2014, 11:58am UTC](https://community.wowza.com/t/what-is-the-preferred-way-to-use-play-onplay-methods/43815/7 "2014-09-29T11:58:22Z")

</div>

Any feedback?
