<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex Examples &#187; volume</title>
	<atom:link href="http://blog.flexexamples.com/tag/volume/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Detecting when the volume changes on a Spark VideoPlayer control in Flex 4</title>
		<link>http://blog.flexexamples.com/2009/06/11/detecting-when-the-volume-changes-on-a-spark-videoplayer-control-in-flex-4/</link>
		<comments>http://blog.flexexamples.com/2009/06/11/detecting-when-the-volume-changes-on-a-spark-videoplayer-control-in-flex-4/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 06:45:42 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta1]]></category>
		<category><![CDATA[VideoPlayer (Spark)]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[volume]]></category>
		<category><![CDATA[volumeChanged]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2009/06/11/detecting-when-the-volume-changes-on-a-spark-videoplayer-control-in-flex-4/</guid>
		<description><![CDATA[<p>The following example shows how you can determine when the volume has changed on a Spark VideoPlayer control in Flex 4 by listening for the internal volumeChanged event.</p> <p>Full code after the jump.</p> <p></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2009/06/11/detecting-when-the-volume-changes-on-a-spark-videoplayer-control-in-flex-4/ --&#62; &#60;s:Application name="Spark_VideoPlayer_volumeChanged_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"&#62; &#60;fx:Script&#62; &#60;![CDATA[ private function init():void { videoPlayer.addEventListener("volumeChanged", videoPlayer_volumeChanged); } private [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can determine when the volume has changed on a Spark VideoPlayer control in Flex 4 by listening for the internal <code>volumeChanged</code> event.</p>
<p>Full code after the jump.</p>
<p><span id="more-1107"></span></p>
<p class="alert">The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see <a href="http://bit.ly/crThlI">http://www.adobe.com/products/flex/</a>. To download the latest nightly build of the Flex 4 SDK, see <a href="http://bit.ly/Flex4SDK">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4</a>.<br/><strong>For more information on getting started with Flex 4 and Flash Builder 4, see the official <a href="http://bit.ly/dCkecm">Adobe Flex Team blog</a>.</strong></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2009/06/11/detecting-when-the-volume-changes-on-a-spark-videoplayer-control-in-flex-4/ --&gt;
&lt;s:Application name="Spark_VideoPlayer_volumeChanged_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"&gt;

    &lt;fx:Script&gt;
        &lt;![CDATA[
            private function init():void {
                videoPlayer.addEventListener("volumeChanged", videoPlayer_volumeChanged);
            }

            private function videoPlayer_volumeChanged(evt:Event):void {
                var obj:Object = {};
                obj.type = evt.type;
                obj.volume = evt.currentTarget.volume.toFixed(2);
                obj.time = new Date().toTimeString().split(" ")[0];
                arrList.addItemAt(obj, 0);
            }
        ]]&gt;
    &lt;/fx:Script&gt;

    &lt;fx:Declarations&gt;
        &lt;s:ArrayList id="arrList" /&gt;
    &lt;/fx:Declarations&gt;

    &lt;s:HGroup left="20" right="20"
            verticalCenter="0"
            gap="20"&gt;
        &lt;s:VideoPlayer id="videoPlayer"
                source="http://helpexamples.com/flash/video/cuepoints.flv"
                muted="true"
                initialize="init();" /&gt;
        &lt;mx:DataGrid id="dataGrid"
                dataProvider="{arrList}"
                verticalScrollPolicy="on"
                width="100%"
                height="100%"&gt;
            &lt;mx:columns&gt;
                &lt;mx:DataGridColumn dataField="type" /&gt;
                &lt;mx:DataGridColumn dataField="volume" /&gt;
                &lt;mx:DataGridColumn dataField="time" /&gt;
            &lt;/mx:columns&gt;
        &lt;/mx:DataGrid&gt;
    &lt;/s:HGroup&gt;

&lt;/s:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/spark/Spark_VideoPlayer_volumeChanged_test/bin/srcview/">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/spark/Spark_VideoPlayer_volumeChanged_test/bin/main.html" width="100%" height="400"></iframe></p>
<p>Due to popular demand, here is the &#8220;same&#8221; example in a more ActionScript friendly format:</p>
<p class="download"><a href="">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2009/06/11/detecting-when-the-volume-changes-on-a-spark-videoplayer-control-in-flex-4/ --&gt;
&lt;s:Application name="Spark_VideoPlayer_volumeChanged_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"
        initialize="init();"&gt;

    &lt;fx:Script&gt;
        &lt;![CDATA[
            import mx.events.FlexEvent;
            import spark.components.HGroup;
            import mx.core.ScrollPolicy;
            import mx.controls.dataGridClasses.DataGridColumn;
            import mx.collections.ArrayList;
            import mx.controls.DataGrid;
            import spark.components.VideoPlayer;

            [Bindable]
            private var arrList:ArrayList;
            private var videoPlayer:VideoPlayer;
            private var dataGrid:DataGrid;

            private function init():void {
                arrList = new ArrayList();

                videoPlayer = new VideoPlayer();
                videoPlayer.source = "http://helpexamples.com/flash/video/cuepoints.flv";
                videoPlayer.muted = true;
                videoPlayer.addEventListener("volumeChanged", videoPlayer_volumeChanged);

                var cols:Array = [];
                cols.push(new DataGridColumn("type"));
                cols.push(new DataGridColumn("volume"));
                cols.push(new DataGridColumn("time"));

                dataGrid = new DataGrid();
                dataGrid.dataProvider = arrList;
                dataGrid.columns = cols;
                dataGrid.verticalScrollPolicy = ScrollPolicy.ON;
                dataGrid.percentWidth = 100;
                dataGrid.percentHeight = 100;

                var hGr:HGroup = new HGroup();
                hGr.gap = 20;
                hGr.left = 20;
                hGr.right = 20;
                hGr.verticalCenter = 0;
                hGr.addElement(videoPlayer);
                hGr.addElement(dataGrid);
                addElement(hGr);
            }

            private function videoPlayer_volumeChanged(evt:Event):void {
                var obj:Object = {};
                obj.type = evt.type;
                obj.volume = evt.currentTarget.volume.toFixed(2);
                obj.time = new Date().toTimeString().split(" ")[0];
                arrList.addItemAt(obj, 0);
            }
        ]]&gt;
    &lt;/fx:Script&gt;

&lt;/s:Application&gt;
</pre>
<p class="alert">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.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Detecting when the volume changes on a Spark VideoPlayer control in Flex 4 on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/06/11/detecting-when-the-volume-changes-on-a-spark-videoplayer-control-in-flex-4/',contentID: 'post-1107',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'Gumbo,volume,volumeChanged',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2009/06/11/detecting-when-the-volume-changes-on-a-spark-videoplayer-control-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting the volume on a VideoDisplay control in Flex</title>
		<link>http://blog.flexexamples.com/2008/08/24/setting-the-volume-on-a-videodisplay-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/08/24/setting-the-volume-on-a-videodisplay-control-in-flex/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 06:38:42 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[VideoDisplay]]></category>
		<category><![CDATA[volume]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/08/24/setting-the-volume-on-a-videodisplay-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can control the volume on a Flex VideoDisplay control by setting the volume property.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/VideoDisplay_volume_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/08/24/setting-the-volume-on-a-videodisplay-control-in-flex/ --&#62; &#60;mx:Application name="VideoDisplay_volume_test" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:ApplicationControlBar dock="true"&#62; &#60;mx:Form styleName="plain"&#62; &#60;mx:FormItem label="volume:"&#62; &#60;mx:HSlider id="slider" minimum="0.0" maximum="1.0" value="0.7" snapInterval="0.01" tickInterval="0.1" [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can control the volume on a Flex VideoDisplay control by setting the <code>volume</code> property.</p>
<p>Full code after the jump.</p>
<p><span id="more-762"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/VideoDisplay_volume_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/08/24/setting-the-volume-on-a-videodisplay-control-in-flex/ --&gt;
&lt;mx:Application name="VideoDisplay_volume_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
         layout="vertical"
         verticalAlign="middle"
         backgroundColor="white"&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="volume:"&gt;
                &lt;mx:HSlider id="slider"
                        minimum="0.0"
                        maximum="1.0"
                        value="0.7"
                        snapInterval="0.01"
                        tickInterval="0.1"
                        liveDragging="true" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:VideoDisplay id="videoDisplay"
            source="http://www.helpexamples.com/flash/video/cuepoints.flv"
            volume="{slider.value}"
            autoPlay="false" /&gt;

    &lt;mx:Button id="playBtn"
            label="Play"
            click="videoDisplay.play();"
            enabled="{!videoDisplay.playing}" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/VideoDisplay_volume_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/VideoDisplay_volume_test/bin/main.html" width="100%" height="350"></iframe></p>
<p>Due to popular demand, here is the &#8220;same&#8221; example in a more ActionScript friendly format:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/VideoDisplay_volume_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/08/24/setting-the-volume-on-a-videodisplay-control-in-flex/ --&gt;
&lt;mx:Application name="VideoDisplay_volume_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
         layout="vertical"
         verticalAlign="middle"
         backgroundColor="white"
         initialize="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.containers.ApplicationControlBar;
            import mx.containers.Form;
            import mx.containers.FormItem;
            import mx.controls.Button;
            import mx.controls.HSlider;
            import mx.controls.VideoDisplay;
            import mx.controls.sliderClasses.Slider;
            import mx.events.SliderEvent;
            import mx.events.VideoEvent;

            private var slider:HSlider;
            private var videoDisplay:VideoDisplay;
            private var playBtn:Button;

            private function init():void {
                slider = new HSlider();
                slider.minimum = 0.0;
                slider.maximum = 1.0;
                slider.value = 0.7; /* 70% */
                slider.snapInterval = 0.01;
                slider.tickInterval = 0.1;
                slider.liveDragging = true;
                slider.addEventListener(SliderEvent.CHANGE, slider_change);

                videoDisplay = new VideoDisplay();
                videoDisplay.source = "http://www.helpexamples.com/flash/video/cuepoints.flv";
                videoDisplay.volume = slider.value;
                videoDisplay.autoPlay = false;
                videoDisplay.addEventListener(VideoEvent.PLAYHEAD_UPDATE, videoDisplay_playheadUpdate);

                playBtn = new Button();
                playBtn.label = "Play";
                playBtn.enabled = !videoDisplay.playing;
                playBtn.addEventListener(MouseEvent.CLICK, playBtn_click);

                var formItem:FormItem = new FormItem();
                formItem.label = "volume:";
                formItem.addChild(slider);

                var form:Form = new Form();
                form.styleName = "plain";
                form.addChild(formItem);

                var appControlBar:ApplicationControlBar;
                appControlBar = new ApplicationControlBar();
                appControlBar.dock = true;
                appControlBar.addChild(form);
                Application.application.addChildAt(appControlBar, 0);

                addChild(videoDisplay);
                addChild(playBtn);
            }

            private function slider_change(evt:SliderEvent):void {
                videoDisplay.volume = evt.value;
            }

            private function playBtn_click(evt:MouseEvent):void {
                videoDisplay.play();
            }

            private function videoDisplay_playheadUpdate(evt:VideoEvent):void {
                playBtn.enabled = !videoDisplay.playing;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting the volume on a VideoDisplay control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/08/24/setting-the-volume-on-a-videodisplay-control-in-flex/',contentID: 'post-762',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'volume',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/08/24/setting-the-volume-on-a-videodisplay-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

