# Shoutcast and NetStream

**URL:** <https://forum.kirupa.com/t/shoutcast-and-netstream/305123>\
**Category:** flash\
**Created:** [February 19, 2010, 12:59pm UTC](https://forum.kirupa.com/t/shoutcast-and-netstream/305123 "2010-02-19T12:59:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Binji](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@Binji](https://forum.kirupa.com/u/Binji)\
**Post date:** [February 19, 2010, 12:59pm UTC](https://forum.kirupa.com/t/shoutcast-and-netstream/305123/1 "2010-02-19T12:59:12Z")

</div>

I would like to create a Shoutcast player in Flex using NetStream and NetConnection classes. Looking at examples like this: [http://livedocs.adobe.com/flex/3/langref/flash/net/NetStream.html#includeExamplesSummary](http://livedocs.adobe.com/flex/3/langref/flash/net/NetStream.html#includeExamplesSummary) everything seemed pretty much straightforward.  
When i try it however it doesnt work.  
Everything connects however i cant hear anything. So i tried extending my controller class to Video and adding it to the application but then it crashes on init with Type Coercion failed exception.

This is my controller:

```auto

package controller
{
	import flash.events.NetStatusEvent;
	import flash.media.Video;
	import flash.net.NetConnection;
	import flash.net.NetStream;
	
	public class ShoutcastController extends Video
	{
		private var _streamUrl:String;
		private var _connUrl:String;
		
		private var _netConnection:NetConnection;
		private var _stream:NetStream;
		
		private var _player:Video;
		
		public function ShoutcastController(streamUrl:String)
		{
			_streamUrl = streamUrl;
			_connUrl = "rtmp://conn.url";
				
		}
		public function playStream():void
		{
			_netConnection = new NetConnection();
			_netConnection.addEventListener(NetStatusEvent.NET_STATUS, netEventsHandler);
			
			_netConnection.connect(_connUrl);
			
		}
		
		private function netEventsHandler(event:NetStatusEvent):void
		{
			if (event.info.code == "NetConnection.Connect.Success")
		        playShoutcast();

		}
		private function streamEventsHandler(event:NetStatusEvent):void
		{
			trace(event);
		}
		private function playShoutcast():void
		{
			_stream = new NetStream(_netConnection);
			
			_stream.addEventListener(NetStatusEvent.NET_STATUS, streamEventsHandler);
			
			var streamClient:CustomStreamClient = new CustomStreamClient();
			
			_stream.bufferTime = 2;
			
			
			this.attachNetStream(_stream);
			
			_stream.play(_streamUrl);
			
			trace(_stream.time);
		}
		
		
	}
	
}

```

and this is how i call it on creationComplete:

```auto

	_shoutcastController = new ShoutcastController("http://stream.url:8000");
	_shoutcastController.playStream();
	
	this.addChild(_shoutcastController);

```

Any ideas?
