# Audio Only Stream: Live advertising insertion

**URL:** https://community.wowza.com/t/audio-only-stream-live-advertising-insertion/631
**Category:** Wowza Streaming Engine
**Created:** [November 4, 2014, 10:24am UTC](https://community.wowza.com/t/audio-only-stream-live-advertising-insertion/631 "2014-11-04T10:24:07Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/system/32/447_2.png) [@system](https://community.wowza.com/u/system)
#### Post date: [November 4, 2014, 10:24am UTC](https://community.wowza.com/t/audio-only-stream-live-advertising-insertion/631/1 "2014-11-04T10:24:07Z")

</div>

We have a continuous live stream we are running through Wowza Streaming Engine and transcoding to a few bitrates and pushing the RTMP to Akamai. I’d like to be able to programmatically insert a 30 second mp3 promo/ad into the stream, then switch back to the original live source, without stopping the stream or restarting the application.

The closest forum I see is:

[https://www.wowza.com/docs/how-to-switch-streams-using-stream-class-streams](https://www.wowza.com/docs/how-to-switch-streams-using-stream-class-streams) however, this appears to create multiple playlists, one for each asset.

I’ve coded it so we have an HTTProvider2Base that I can pass which promo I’d like to switch to, then be able to switch back to the live stream.

I’m seeing a few things that I don’t understand:

1.) When I make a call to switch playlists, it takes about 5 seconds for the new assets to start playing, and there is buffering before it begins to play.

2.) If I create a playlist that is a promo, then the live stream in the same playlist, the transition is instantaneous. Why is this different than #1?

3.) We are trying to push our transcoded streams to Akamai, but it appears every time you switch the playlist, the transcoder is reset, and this seems to break the stream Akamai is trying to read.

4.) The publishStream doesn’t seem to start right away. Do I need to be waiting for a callback before the startMediaCasterStream is finished before I can push that playlist into a stream?

Here is some of the code we are using:

```auto
	String theStreamName = "publishStream";
	String streamName = "audio_stream.stream";
	if( action.equalsIgnoreCase( "start" ) )
	{						
		appInstance.startMediaCasterStream(streamName, streamType);
		
		Stream stream = Stream.createInstance(appInstance, theStreamName);						
		appInstance.getProperties().setProperty(theStreamName, stream);
		Playlist start_playlist = new Playlist("start");
		start_playlist.open(stream);
		
		WMSLoggerFactory.getLogger(null).info("AMVDM.API: startMediaCasterStream: streamName: " + streamName + " & streamType: " + streamType);
		retStr = "<html><head><title>" + streamName
				+ "</title></head><body>" + streamName + " has been started</body></html>";
		
	}
	else if( action.equalsIgnoreCase( "stop" ) )
	{
		
		appInstance.stopMediaCasterStream(streamName);
		WMSLoggerFactory.getLogger(null).info("AMVDM.API: stopMediaCasterStream: streamName: " + streamName);
		retStr = "<html><head><title>" + streamName
				+ "</title></head><body>" + streamName + " has been stopped</body></html>";
	}
	else if( action.equalsIgnoreCase( "play_promo" ))
	{
		
		Playlist promo_playlist = new Playlist("promo");
		promo_playlist.addItem("mp3:psa.mp3", 0, -1);
		promo_playlist.addItem( streamName, -2, -1);
		
		appInstance.getProperties().setProperty( promo_playlist.getName(), promo_playlist );
		Stream stream = (Stream)appInstance.getProperties().getProperty(theStreamName);
		promo_playlist.open(stream);
		
		WMSLoggerFactory.getLogger(null).info( "AMVDM.API: switching to promo: streamName: " + streamName );
		retStr = "<html><head><title>" + streamName
				+ "</title></head><body>" + streamName + " has been switched to a promo</body></html>";
	}
	else if( action.equalsIgnoreCase( "play_live_stream" ))
	{
		
		Playlist livestream_playlist = new Playlist("livestream");
		livestream_playlist.addItem( streamName, -2, -1);
		
		appInstance.getProperties().setProperty( livestream_playlist.getName(), livestream_playlist );
		Stream stream = (Stream)appInstance.getProperties().getProperty( theStreamName);
		livestream_playlist.open(stream);
		
		WMSLoggerFactory.getLogger(null).info( "AMVDM.API: switching to live stream: streamName: " + streamName );
		retStr = "<html><head><title>" + streamName
				+ "</title></head><body>" + streamName + " has been switched to the live stream</body></html>";
	}
	
}

```

---

<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: [November 21, 2014, 9:09am UTC](https://community.wowza.com/t/audio-only-stream-live-advertising-insertion/631/2 "2014-11-21T09:09:30Z")

</div>

Hello

I’d suggest taking a look at our [scheduler](https://www.wowza.com/docs/how-to-schedule-streaming-with-wowza-streaming-engine-streampublisher%28ServerListenerStreamPublisher%29) (source is within the module collection). This should accomplish more of what you are looking to do.

Thanks,

Matt
