ask_you_ask_me
ask_you_ask_me

Reputation: 21

catching browser's volume event

I'm running an external flash video player on client side, and want to keep it muted all the time. I'm having difficulties to control the player's volume while playing an external swf (VPAID ads). Is there a way, through JavaScript, to tell if the browser's volume raised? I'm not using HTML5.

Thanks

Upvotes: 2

Views: 383

Answers (1)

zyexal
zyexal

Reputation: 1579

No and yes. Afaig, there is no global 'browserVolumeChange' event, which is catchable after some swf on page has changed volume etc.

But, you can teach your player to submit any event to javascript. For volume, the VPAID will possibly dispatch AdVolumeChange, which you can react on.

Add event listener for 'AdVolumeChange' to your loaded swf:

_vpaidSWF.addEventListener(YourVPAIDEventImpl.AdVolumeChange, onAdVolumeChange);

You can't be sure, that the swf you've loaded is implemented well, so maybe you will not receive anything, if volume has changed. You could try to find out by yourself, but keep in mind, that the swf is potentially just a wrapper and loads another vpaid-swf, and this one loads another, a.s.o...

Implement listener for this, too:

private function onAdVolumeChange(e:YourVPAIDEventImpl):void {
    // here you can send custom notice to your js via ExternalInterface or <----- !
    // try to mute/whatever directly
}

Keep in mind to send tracking for (un)mute etc ... !!!

To set volume for VPAID. You could implement something like that:

public function set volume( arg:Number ):void {
    _volume = arg;
    if( _vpaidSWF == null )
        return;
    try {
        _vpaidSWF.adVolume = arg;
    } catch(e:*){}
}

If you want to have the player muted by default, listen on AdImpression, AdVideoStart, etc and set volume to zero ... But as said before, unfortunately you can't be sure that these events will arrive.
Got swf whose first event was AdVideoMidpoint -.-

Summary: Afaig no default event, so create it yourself.

Hope this was somehow helpful :)


EDIT
I really would like to have a VPAID tag here ;)
http://www.iab.net/vpaid

Upvotes: 1

Related Questions