Video Player with Fullscreen,play,pause,stop,mute,volume,progress


-------------------------------videoplayer.mxml----------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" styleName="Application" 
	paddingTop="15" paddingLeft="15" paddingRight="15" paddingBottom="15" xmlns:local="*">
			 <mx:Script source="ascript.as" />
        <mx:Style source="new.css"/>
      	<mx:ArrayCollection id="playlist">
			<mx:String>videos/AdobeBand_640.flv</mx:String>
			<mx:String>videos/phone.flv</mx:String>
			<mx:String>videos/sample.flv</mx:String>				
		</mx:ArrayCollection>	        

	 <!--<mx:ButtonBar id="tab2" dataProvider="{vs}" width="100%" itemClick="clickHandler(event)"/>-->
	 <mx:VBox width="100%" height="100%" paddingTop="10" paddingLeft="30" paddingRight="30" verticalGap="0" >

	 <mx:Image id="img" source="headerlogo.jpg" width="100%" />
	 <mx:ButtonBar id="tab2" dataProvider="{vs}" width="100%"  />

	<mx:ViewStack id="vs" width="100%" height="100%" tabIndex="0" includeInLayout="true"  >
		<mx:Canvas id="can" label="Home" backgroundColor="red"/>
		<mx:Canvas id="can1" label="Corporate" backgroundColor="green">
		</mx:Canvas>
		<mx:Canvas id="can2" label="Services" backgroundColor="black"/>
		<mx:Canvas id="can3" label="Training" backgroundColor="blue">
     <mx:VBox width="100%" height="100%">
    	<mx:HBox>
    <mx:VideoDisplay id="videoDisplay" 
            	width="260" 
            	height="220" 
            	playheadUpdate="changeProgressBar()"
            	volume="{volumesl.value}"
            	complete="reply()" 
             	doubleClickEnabled="true"
             	doubleClick="makeFullScreen()" />
    <mx:List 	id="mylist" 
             			dataProvider="{playlist}" 
             			click="loadButton_list(event)"  
             			dropEnabled="true"
             			dragEnabled="true"
             			height="100%"/>
    </mx:HBox>
      <mx:HSlider id="progress"  
    		thumbSkin="@Embed(source='skins/thumb.png')" 
    		showTrackHighlight="true" 
    		slideEasingFunction="undefined"
    		liveDragging="false"
    		tickColor="black" 
    		trackSkin="@Embed(source='skins/prg.png')"  
    		width="{videoDisplay.width}"/>
    <mx:ControlBar > 
    <mx:Button id="loadButton" 
            styleName="Play" 
            toggle="true"
            click="plyBtn(event);" /> 
    <mx:Button id="unloadButton" 
            styleName="Stop" 
            toggle="true"
            click="unloadButton_click(event);" />
    <mx:HSlider id="volumesl" 
    				minimum="0" 
    				maximum="1" 
    				width="75" 
    				snapInterval="0.1" 
    				allowTrackClick="true"
				    trackSkin="@Embed(source='skins/vol.png')" 
      				change="volchange()"
     				thumbSkin="@Embed(source='skins/thumb.png')" /> 
    <mx:Button  id="fs"
    			styleName="Fscreen"
             	toggle="true" 
             	click="makeFullScreen()"/>  
    <mx:Button id="mute"
    			toggle="true"
    			styleName="Mute" width="34"
    			click="SoundOff()"/>
	<mx:Button id="next"
    			toggle="true"
    			styleName="Next" width="34"
    			click="SoundOff()"/>
    	</mx:ControlBar>
    </mx:VBox>	
		</mx:Canvas>
		<mx:Canvas id="can4" label="Careers" backgroundColor="white">
			<mx:TextArea id="myTA" />
		</mx:Canvas>
		<mx:Canvas id="can5" label="Clients" backgroundColor="yellow"/>
		<mx:Canvas id="can6" label="Contact Us" backgroundColor="purple"/>
	</mx:ViewStack>
	</mx:VBox>
</mx:Application>
-----------------------------------------New.css---------------------------------------
Application
{
	background-image:Embed(source='skins/DarkRed.png');
}
Canvas
{
		borderThicknessLeft: 14;
		borderThicknessRight: 14;
		borderThicknessTop: 2;
		borderThicknessBottom: 12;
		headerHeight: 28;
		backgroundAlpha: 0;
		cornerRadius: 28;
		titleStyleName: "mypanelTitle";
		roundedBottomCorners: true;
	    backgroundAlpha: 0;
	    highlightAlphas: 0, 0;

}
.Play
{
	  	skin:Embed(source='skins/play.png');
		over-skin : Embed('skins/play pushed.png');
		downSkin: Embed('skins/pause hot.png');
		 selectedUpSkin: Embed('skins/pause hot.png');
		selectedOverSkin: Embed('skins/pause pushed.png');
		selectedDownSkin: Embed('skins/play.png'); 	
}
.Play1
{
	  	skin:Embed(source='skins/play.png');
}
.Mute
{
		skin:Embed(source="skins/sound1.png");
		over-skin : Embed('skins/sound2.png');
		selected-up-skin:Embed('skins/sound3.png');
		down-skin:Embed('skins/sound3.png'); 
}
.Stop
{
	  	skin:Embed(source='skins/stop hot.png');
		over-skin : Embed('skins/stop pushed.png');
}
.Fscreen
{
	  	skin:Embed(source='skins/FS.png');
}
.Next
{
	skin:Embed(source='skins/next2.png');
	over-skin : Embed('skins/next1.png');
}

/* CSS file */
-----------------------------------------ascript.as------------------------------------
			import flash.events.*;
			 public static var vol:int;
			 public var cvi:int;

			private function reply():void 
            { 
              /*  var j:String=(mylist.selectedIndex+1).toString();
               videoDisplay.source=j.toString(); */

               var ind:int = cvi++;
                /* var url1:String=mylist.selectedIndex(ind); */
               videoDisplay.source =  mylist.selectedIndex.toString();
               videoDisplay.play();

               SoundOff();

            } 
           	public function loadButton_click(evt:MouseEvent):void 
           	{ 
           		volumesl.value=vol;
             	var url:String =mylist.selectedItem.toString();
                cvi= mylist.selectedIndex;
                videoDisplay.source =  url;
                vol=volumesl.value;
                 if (loadButton.selected )
				{
					//status.text="Now Playing";
					videoDisplay.play();
					/* progress.minimum=0;
					progress.maximum=i; */
					vol=volumesl.value;
				}
				else
				{
					videoDisplay.pause();
					//status.text="Video Pause";
				} 
            }     
            public function plyBtn(evt1:MouseEvent):void 
           	{ 
           		volumesl.value=vol;
             	//var url:String =mylist.selectedItem.toString();
                videoDisplay.source =  "videos/sample.flv";
                vol=volumesl.value;
                 if (loadButton.selected )
				{
					videoDisplay.play();
					vol=volumesl.value;
				}
				else
				{
					videoDisplay.pause();
				} 
            }     
            public function loadButton_list(evt:MouseEvent):void 
           	{
           	/* 	 var i:int; =mylist.selectedIndex;  */  
           		var url:String  =mylist.selectedItem.toString(); 
           		  videoDisplay.source = url;
           		 var i:int=videoDisplay.source.length;
                    progress.minimum=0;
					progress.maximum=i;
                	videoDisplay.play();
          }
           public function SoundOff():void
            {
            	 if (mute.selected)
            	{
            		videoDisplay.volume=0;
            	}
            	else
            	{
            		videoDisplay.volume=volumesl.value;
            	} 
            }
             public function volchange():void
            {
            	vol=volumesl.value;
            	mute.selected=false;
            	//Alert.show(vol.toString());
            }
            private function unloadButton_click(evt:MouseEvent):void 
            { 
                videoDisplay.close(); 
                videoDisplay.source = null; 
                videoDisplay.mx_internal::videoPlayer.clear(); 
                videoDisplay.volume=0;
                progress.value=0;
                loadButton.selected=false;

            } 
            private function changeProgressBar(): void
			{
				progress.value = videoDisplay.playheadTime
			}
			private function makeFullScreen():void
			{
				//Application.application.width=1024;
				/* videoDisplay.height=Application.application.height; */
				fs.enabled=false;
			       if(stage.displayState == StageDisplayState.FULL_SCREEN)
				{
					stage.displayState = StageDisplayState.NORMAL
					videoDisplay.width=260;
					videoDisplay.height=220;
				}
				else
				{
				     stage.displayState = StageDisplayState.FULL_SCREEN
					videoDisplay.width=790;
					videoDisplay.height=500;
				}

			} 
Advertisements

~ by mjcprasad2000 on January 16, 2009.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

 
%d bloggers like this: