[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 953
  • Last Modified:

Flex 3: Get volume level of FLVPlayBack control

Is there a way in Flex 3 to determine the volume level of the built in FLVPlayBack control? I would prefer not to make my own slider if it is possible. Thanks.
0
rbichon
Asked:
rbichon
  • 7
  • 7
1 Solution
 
Jones911Commented:
<mx:VideoDisplay id="vp" source="test.flv" />

<mx:Label x="150" y="417" text="{vp.volume}"/>

Where vp.volume is between 0 (min) and 1 (max)
0
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:

all you need is a very simple slider as shown below

<mx:VideoDisplay id="vd" source="video.flv" />

 <mx:HSlider id="slider"  minimum="0.0"  maximum="1.0"  value="{vd.volume}"/> (this will position to default value automatically.
0
 
Jones911Commented:
Actually that wont change the volume.  It will default the slider to the current volume level.

To use the slider to change the volume check out this code example.  liveDragging will increase/decrease the volume as you move the slider rather then on release or the mouse.
<mx:VideoDisplay id="vd" source="video.flv" voulume="{slider.value} />
<mx:HSlider id="slider"  minimum="0.0"  maximum="1.0"  value="{vd.volume}" liveDragging="true"/>

Open in new window

0
Prepare for an Exciting Career in Cybersecurity

Help prevent cyber-threats and provide solutions to safeguard our global digital economy. Earn your MS in Cybersecurity. WGU’s MSCSIA degree program curriculum features two internationally recognized certifications from the EC-Council at no additional time or cost.

 
rbichonAuthor Commented:
I am not actually using the VideoDisplay item. I have an flv player skinned with Flash that I use in Flex. I can easily send commands that will set the volume on the control. But I also need to get feedback from its slider so that I can have flash remember volume settings. Is this possible? Is there an easier way that I am overlooking?
Here is some code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*" width="330" height="250" backgroundGradientAlphas="[0.0, 0.0]" backgroundColor="#FFFFFF" creationComplete="initVars()">
	<local:myVideoPlayer
		id="myPlayer"
		width="330" height="250" x="5" y="5" />
	<mx:Script>
	<![CDATA[
		private function initVars():void {
			//do stuff
		}
	]]>
	</mx:Script>
</mx:Application>

Open in new window

0
 
Jones911Commented:
Well I'll assume that    <local:myVideoPlayer  is a custome build of the flex video player but without seeign the code fo that component its a black box for us and we would just be guessing.
0
 
rbichonAuthor Commented:
It is the FLVPlayBack control in Flash which is published as an swc file. Flex references that file as an object.
Assuming I switch over to your control, is there an event that is raised when the slider is moved from side to side?
0
 
Jones911Commented:
0
 
rbichonAuthor Commented:
I have found a way to embed the FLVPlayback control using:

<video:FLVPlayback  />
As long as the swc file is in the /libs/ folder, Flex will recognize it. The only thing that isn't built in is the ability to mute the movie which is really stupid. You can click the mute button manually, but that is about it. I tried sending the button a CLICK event, but that didn't work. It seems that it isn't actually a button at all but a Sprite. Any suggestions?
myPlayer.muteButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
0
 
Jones911Commented:
I'm sure there is a method that is exposed to alter the volume level.  Are you able to post a link of the code of the video player?
0
 
rbichonAuthor Commented:
The volume level is not the problem. I am unable to mute the movie when it loads.
0
 
Jones911Commented:
OK well if you can change the volume then set it to 0?
0
 
rbichonAuthor Commented:
To change the volume, all I have to do is this:
myPlayer.volume = 0.5; //Sets volume to 50%
Unfortunately, there is no way that I can find to simply mute the movie. There is an instance called "MuteButton" but have been unable to use it programmatically. I tried sending it a click event with this:
myPlayer.MuteButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
When it executes, it returns true indicating that it should have worked. However, the button does not change and the movie does not mute. Also, it is worth noting that MuteButton is not actually a button...it is a Sprite. I don't know what a Sprite is but maybe that difference is why thing thing won't work.
0
 
rbichonAuthor Commented:

I would do that but when the user physically clicks the mute button, it does not change the volume slider. Maybe I am just being stubborn, but shouldn't I be able to do both independently?
 
0
 
Jones911Commented:
Make a button.  Then on click do myPlayer.volume = 0;
0
 
rbichonAuthor Commented:
That does seem to be the best way...aside from creating my own custom buttons. Thanks.
0

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

  • 7
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now