Skip to content

VIDplayer()

A basic video player framework

package com.drpunchlogic
{
	/*
	---------------------------------------
		Import classes
	---------------------------------------
	*/
	import flash.display.*;
	import flash.net.*;
	import flash.media.Video;
	// events
	import flash.events.MouseEvent;
	import flash.events.Event;
	import flash.events.AsyncErrorEvent;
	import flash.events.NetStatusEvent;

	/*
	---------------------------------------
		Public Class
	---------------------------------------
	*/
	public class VIDplayer
	{
		/*
		---------------------------------------
			Variables
		---------------------------------------
		*/
		// connect to network
		private var		_nc:NetConnection;
		private var		_ns:NetStream;
		// url of the video
		private var		_www:String;
		// video player
		private var 	_vid:Video;
		// info object
		private var 	_info:Object;

		// player buttons
		private var		_isPlaying:Boolean;

		private var		_btnPlay:Object;
		private var		_btnStop:Object;
		private var		_btnPause:Object;

		// seek buttons
		private var		_isSlidingSeek:Boolean;

		private var		_seek:Number;
		private var		_seekSlider:Object;
		private var		_seekThumb:Object;

		// volume buttons
		private var		_isSlidingVol:Boolean;

		private var		_vol:Number;
		private var		_volSlider:Object;
		private var		_valThumb:Object;

		// parent
		private var 	_containter:Object;

		/*
		---------------------------------------
			Function
		---------------------------------------
		*/
		public function VIDplayer( containter:Object, www:String )
		{
			// set the parent containter
			_containter = containter;
			// set the link to the file
			_www = www;

			// set up the connection
			_nc = new NetConnection();
			_nc.connect( null );
			_ns = new NetStream( _nc );

			//
			_info = new Object();
			/*
			_info.onMetaData = onMetaData;
			_info.onCuePoint = onCuePoint;
			*/

			_ns.client = _info;

			_nc.addEventListener( NetStatusEvent.NET_STATUS , onNetStatus );
			_nc.addEventListener( AsyncErrorEvent.ASYNC_ERROR , onAsyncError );
			_ns.addEventListener( NetStatusEvent.NET_STATUS , onNetStatus );
			_ns.addEventListener( AsyncErrorEvent.ASYNC_ERROR , onAsyncError );

			// add the video to the stream
			_vid = new Video();
			_vid.attachNetStream( _ns );
			_ns.play( _www );

		}

		/*
		---------------------------------------
			Modules
		---------------------------------------
		*/
		private function onNetStatus( e:Event )
		{
			trace( "\t{ VID: " + e.target + " }" );
		}

		private function onAsyncError( e:Event )
		{
			trace( "\t{ VID: " + e.target + " }" );
		}

	}
}

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*