Switch audio on/off

191 views
Skip to first unread message

Arnaud

unread,
May 26, 2012, 8:04:30 PM5/26/12
to SWFObject
Hi

I am trying to have an HTML link that allow the user to switch on/off
the audio of the videos shown on the home page. Is it possible? If so
what would be the adequate code?

The current code I am using to call the different videos is the one
below:
[
var flashvars = {
xml:'../swf/xml/data.xml'
};
var params = {
menu: "false",
scale: "noScale",
allowFullscreen: "true",
allowScriptAccess: "always",
bgcolor: "",
wmode: "transparent" // can cause issues with FP settings & webcam
};
var attributes = {
id:"flash_content"
};
swfobject.embedSWF(
"../swf/smartsy.swf",
"flash_content", "256px", "381px", "10.0.0",
"../swf/expressInstall.swf",
flashvars, params, attributes);

function playVideos(_id) {
if(!userAgent.match(mobile)){
document.getElementById("flash_content").playVideo(_id);
}

}
]


You can find the current page in dev here: http://184.73.230.170/en/index.html

Thanks in advance for your help.

Aran Rhee

unread,
May 27, 2012, 12:33:15 PM5/27/12
to swfo...@googlegroups.com
So what is happening right now? The code above looks ok on first glance.

Does your swf have a js / ExternalInterface method defined called "playVideo()" ? 




--
You received this message because you are subscribed to the Google Groups "SWFObject" group.
To post to this group, send email to swfo...@googlegroups.com.
To unsubscribe from this group, send email to swfobject+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/swfobject?hl=en.


Arnaud Saint-Paul

unread,
May 27, 2012, 1:54:49 PM5/27/12
to swfo...@googlegroups.com
The videos are played correctly but I want to give the users the ability to switch audio off as it can be annoying sometimes. Beyond the function already mentioned, there is nothing else:

     function playVideos(_id) {
                       if(!userAgent.match(mobile)){
                               document.getElementById("flash_content").playVideo(_id);
                       }

       }

Can I mute/unmute the audio with javascript by clicking on a HTML link?

Nathan Mynarcik

unread,
May 27, 2012, 6:15:31 PM5/27/12
to swfo...@googlegroups.com

Your swf will need to have a listener for the JS call and will need the functionality to change the volume.

Arnaud Saint-Paul

unread,
May 27, 2012, 6:54:21 PM5/27/12
to swfo...@googlegroups.com
Thanks Nathan. How do I create a listener with the functionality to change volume?


On Sun, May 27, 2012 at 3:15 PM, Nathan Mynarcik <kicr...@gmail.com> wrote:

Your swf will need to have a listener for the JS call and will need the functionality to change the volume.

--

Nathan Mynarcik

unread,
May 27, 2012, 7:34:01 PM5/27/12
to swfo...@googlegroups.com

You will need to have access to the fla file for the swf. Create a function to change the volume. Add an ExternalInterface.addCallback and set the name of the function as it's parameters.

Look up ExternalInterface to find some examples.

If you do not have access to edit the fla file, you won't be able to do it.

Reply all
Reply to author
Forward
0 new messages