# Publish and play a live stream from API

**URL:** https://community.wowza.com/t/publish-and-play-a-live-stream-from-api/37425
**Category:** Wowza Streaming Engine
**Tags:** server-administration
**Created:** [October 14, 2011, 1:58pm UTC](https://community.wowza.com/t/publish-and-play-a-live-stream-from-api/37425 "2011-10-14T13:58:39Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Gari\_Lixo](https://avatars.discourse-cdn.com/v4/letter/g/5fc32e/32.png) [@Gari\_Lixo](https://community.wowza.com/u/Gari_Lixo)
#### Post date: [October 14, 2011, 1:58pm UTC](https://community.wowza.com/t/publish-and-play-a-live-stream-from-api/37425/1 "2011-10-14T13:58:39Z")

</div>

Hello,

I would like to know how to do this: [https://www.wowza.com/docs/how-to-set-up-live-streaming-using-a-native-rtp-encoder-with-sdp-file](https://www.wowza.com/docs/how-to-set-up-live-streaming-using-a-native-rtp-encoder-with-sdp-file)

In an automatized way. I mean I’ll have to create that kind of live streaming on-the-fly so I need a way to do that part where you access the http://[wowza-address]:8086/streammanager and start the stream but using the API.

I have checked the documentation but its so big (a great thing :D) but idk where to start if someone can give me a hint it would be appreciated.

Thanks!

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [October 14, 2011, 5:08pm UTC](https://community.wowza.com/t/publish-and-play-a-live-stream-from-api/37425/2 "2011-10-14T17:08:51Z")

</div>

You can use the MediaCaster API in a Wowza module or HTTProvider or ServerListener:

[https://www.wowza.com/docs/how-to-use-the-wowza-streaming-engine-java-api-to-start-and-stop-mediacaster-streams](https://www.wowza.com/docs/how-to-use-the-wowza-streaming-engine-java-api-to-start-and-stop-mediacaster-streams)

And there is another approach that might work for you here:

[https://www.wowza.com/docs/how-to-monitor-content-folder-for-sdp-and-stream-files-to-start-publishing-streams-serverlistenerstartupstreamsmonitor](https://www.wowza.com/docs/how-to-monitor-content-folder-for-sdp-and-stream-files-to-start-publishing-streams-serverlistenerstartupstreamsmonitor))

Richard

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [October 14, 2011, 6:47pm UTC](https://community.wowza.com/t/publish-and-play-a-live-stream-from-api/37425/3 "2011-10-14T18:47:09Z")

</div>

Cool, you’re welcome. Glad that was right for you.

Richard

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [November 4, 2011, 7:12pm UTC](https://community.wowza.com/t/publish-and-play-a-live-stream-from-api/37425/4 "2011-11-04T19:12:34Z")

</div>

Here is a HTTProvider example with MediaCaster API usage:

[https://www.wowza.com/docs/how-to-parse-post-or-get-variables-in-an-http-provider](https://www.wowza.com/docs/how-to-parse-post-or-get-variables-in-an-http-provider)

In a Module you might have a IClient or IMediaStream or other parameter, and you can always get to the application instance somehow.

```auto
public void doSomething(IClient client, RequestFunction function,
		AMFDataList params) {
	
	IApplicationInstance appInstance = client.getAppInstance();
}

```

Richard

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [November 4, 2011, 9:15pm UTC](https://community.wowza.com/t/publish-and-play-a-live-stream-from-api/37425/5 "2011-11-04T21:15:12Z")

</div>

Adam,

A Wowza application starts when it is used in some way then will unload after a minute of inactivity, by default. You can increase Application.xml /ApplicationTimeout, or set it to “0” to never timeout once it is started, and you can use this method to start an application when Wowza starts:

[https://www.wowza.com/docs/how-to-use-a-server-listener-to-load-and-lock-an-appinstance-serverlistenerloadandlockappinstances](https://www.wowza.com/docs/how-to-use-a-server-listener-to-load-and-lock-an-appinstance-serverlistenerloadandlockappinstances)

Richard

---

<div class="post-metadata">

### Author: ![Gari\_Lixo](https://avatars.discourse-cdn.com/v4/letter/g/5fc32e/32.png) [@Gari\_Lixo](https://community.wowza.com/u/Gari_Lixo)
#### Post date: [October 14, 2011, 3:37pm UTC](https://community.wowza.com/t/publish-and-play-a-live-stream-from-api/37425/6 "2011-10-14T15:37:43Z")

</div>

> You can use the MediaCaster API in a Wowza module or HTTProvider or ServerListener:
> 
> [Start and stop MediaCaster streams](https://www.wowza.com/docs/how-to-use-the-wowza-streaming-engine-java-api-to-start-and-stop-mediacaster-streams)
> 
> And there is another approach that might work for you here:
> 
> [Monitor an application's content folder](https://www.wowza.com/docs/how-to-monitor-content-folder-for-sdp-and-stream-files-to-start-publishing-streams-serverlistenerstartupstreamsmonitor))
> 
> Richard

Omg, this second approach is amazing, I would never find it if wasnt for you, tyvm.

I wonder if it works for Wowza Media Server 3?

---

<div class="post-metadata">

### Author: ![adam\_anderson](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@adam\_anderson](https://community.wowza.com/u/adam_anderson)
#### Post date: [November 4, 2011, 11:02am UTC](https://community.wowza.com/t/publish-and-play-a-live-stream-from-api/37425/7 "2011-11-04T11:02:38Z")

</div>

Hey Richard,

What you posted there looks very helpful to me for my application (which is a enterprise java app that will be used to programmatically control wowza). I had stumbled across the MediaCaster API and it looks like exactly what I need.

What I don’t understand is how I would get a reference to my applications (my IApplicationInstance implementations) to begin with? Thanks in advance.

- Adam

---

<div class="post-metadata">

### Author: ![adam\_anderson](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@adam\_anderson](https://community.wowza.com/u/adam_anderson)
#### Post date: [November 4, 2011, 1:08pm UTC](https://community.wowza.com/t/publish-and-play-a-live-stream-from-api/37425/8 "2011-11-04T13:08:12Z")

</div>

Richard,

Thanks for the reply. It looks like access to the applications is readily available when implementing a module. I’m going to start looking into the HTTPProvider interface next.

In regards to working with an implementation of IModuleOnApp: events are fired when an App starts and stops and thats when the onAppStart() and onAppStop() methods are called, correct?

When does Wowza consider an app to have ‘started’? ‘Stopped’? Does the app have to be actively streaming? Or is it simply that by virtue of being one of the defined/configured in the ‘conf’ directory it is ‘started’ when Wowza Media Server is started?

Is there a case when an app would be started after the server is running or stopped before the server is stopped?

Thanks in advance.

- Adam
