The following example shows how you can set the full-screen control bar auto hide delay on the Spark VideoPlayer control in Flex 4 by setting the fullScreenHideControlsDelay style.

The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see http://www.adobe.com/products/flex/. To download the latest nightly build of the Flex 4 SDK, see http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4.
For more information on getting started with Flex 4 and Flash Builder 4, see the official Adobe Flex Team blog.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/06/06/setting-the-full-screen-control-bar-auto-hide-delay-on-the-spark-videoplayer-control-in-flex-4/ -->
<s:Application name="Spark_VideoPlayer_fullScreenHideControlsDelay_test"
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/halo">

    <mx:ApplicationControlBar width="100%" cornerRadius="0">
        <mx:Form styleName="plain">
            <mx:FormItem label="fullScreenHideControlsDelay:">
                <s:HSlider id="slider"
                        minimum="1000"
                        maximum="10000"
                        dataTipPrecision="0" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>

    <s:VideoPlayer id="videoPlayer"
            source="http://helpexamples.com/flash/video/cuepoints.flv"
            fullScreenHideControlsDelay="{slider.value}"
            horizontalCenter="0"
            verticalCenter="0" />

</s:Application>

View source is enabled in the following example.

You can also set the fullScreenHideControlsDelay style in an external .CSS file or <Style/> block, as seen in the following example:

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/06/06/setting-the-full-screen-control-bar-auto-hide-delay-on-the-spark-videoplayer-control-in-flex-4/ -->
<s:Application name="Spark_VideoPlayer_fullScreenHideControlsDelay_test"
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/halo">

    <fx:Style>
        @namespace s "library://ns.adobe.com/flex/spark";

        s|VideoPlayer {
            fullScreenHideControlsDelay: 10000;
        }
    </fx:Style>

    <s:VideoPlayer id="videoPlayer"
            source="http://helpexamples.com/flash/video/cuepoints.flv"
            muted="true"
            horizontalCenter="0"
            verticalCenter="0" />

</s:Application>

Or, you can set the fullScreenHideControlsDelay style using ActionScript, as seen in the following example:

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/06/06/setting-the-full-screen-control-bar-auto-hide-delay-on-the-spark-videoplayer-control-in-flex-4/ -->
<s:Application name="Spark_VideoPlayer_fullScreenHideControlsDelay_test"
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/halo">

    <fx:Script>
        <![CDATA[
            private function slider_change(evt:Event):void {
                videoPlayer.setStyle("fullScreenHideControlsDelay", slider.value);
            }
        ]]>
    </fx:Script>

    <mx:ApplicationControlBar width="100%" cornerRadius="0">
        <mx:Form styleName="plain">
            <mx:FormItem label="fullScreenHideControlsDelay:">
                <s:HSlider id="slider"
                        minimum="1000"
                        maximum="10000"
                        dataTipPrecision="0"
                        change="slider_change(event);" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>

    <s:VideoPlayer id="videoPlayer"
            source="http://helpexamples.com/flash/video/cuepoints.flv"
            muted="true"
            horizontalCenter="0"
            verticalCenter="0"
            initialize="slider.value = videoPlayer.getStyle('fullScreenHideControlsDelay');" />

</s:Application>

This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.

 
Tagged with:
 
About The Author

Peter deHaan

Peter deHaan currently works for Adobe on the Flex SDK QA team. While not working on Flex, Flash, and ColdFusion applications, Peter enjoys making up bios and writing in 3rd person. Peter's rarely updated blog can be found at blogs.adobe.com/pdehaan/, actionscriptexamples.com, airexamples.com, and coldfusionexamples.com.

5 Responses to Setting the full-screen control bar auto hide delay on the Spark VideoPlayer control in Flex 4

  1. Karan says:

    Nice codes

  2. Nick says:

    Thanks for this code, related to full screen mode…

    I am using:
    Flash Player version 10,0,32,18
    Firefox 3.5.2
    Mac OS X 10.5.8

    Every now and then the control bar disappears, have you seen that happen? It seems to happen after I come back from full screen mode. The controls are gone but the background bar for the controls stays where it should be. Perhaps it’s a bug?

  3. I am trying to hide the controls on rollOut and show on rollOver. I can affect the alpha of the controls, but it seems that the position of the controls is protected somehow. How do I set the x and y of the playerControls?

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree