We help IT Professionals succeed at work.

Flex 3: Get volume level of FLVPlayBack control

rbichon
rbichon asked
on
Medium Priority
965 Views
Last Modified: 2012-05-06
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.
Comment
Watch Question

Commented:
<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)
Siva Prasanna KumarPrincipal Solutions Architect
CERTIFIED EXPERT
Top Expert 2006

Commented:

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.

Commented:
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

Author

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

Commented:
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.

Author

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?

Author

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));

Commented:
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?

Author

Commented:
The volume level is not the problem. I am unable to mute the movie when it loads.

Commented:
OK well if you can change the volume then set it to 0?

Author

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.

Author

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?
 
Commented:
Make a button.  Then on click do myPlayer.volume = 0;

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
That does seem to be the best way...aside from creating my own custom buttons. Thanks.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.