Get your own customer support community
 

Calling SM2 from 2nd Javascript function

I have set up SM2 and everything is working PERFECTLY. I have a sound that plays on loading the page, which can also be toggled. A second sound responds to mouseover/out elsewhere on the page.

I would like to set up SM2 to play only once per session. I have a working cookie detect.create script, but I just cannot get this 2nd script to call SM2 to play onload (1st time roun, i.e. no cookie).

Here is the code I am using for SM2:

// SM2
soundManager.url = 'audio/';
soundManager.debugMode = false;
soundManager.onload = function() {
var mySound = soundManager.createSound({
id: 'sound',
url: 'audio/eagle.feather.mp3',
volume: 80,
autoPlay: false
});


And the code for the cookie finder/creator:

// Run once per Session
var key_value = "myTestCookie=true";
var foundCookie = 0;

// Get all the cookies from this site and store in an array
var cookieArray = document.cookie.split(';');
// Walk through the array
for(var i=0;i < cookieArray.length;i++)
{
var checkCookie = cookieArray[i];
// Remove any leading spaces
while (checkCookie.charAt(0)==' ')
{
checkCookie = checkCookie.substring(1,checkCookie.length);
}
// Look for cookie set by key_value
if (checkCookie.indexOf(key_value) == 0)
{
soundManager.play('sound');
// alert("Found Cookie");
// The cookie was found so set the variable
foundCookie = 1;
}
}
// Check if a cookie has been found
if ( foundCookie == 0)
{
// The key_value cookie was not found so set it now
document.cookie = key_value;
// alert("Setting Cookie");
}


I have also tried combinations using GetElementbyID, createSound.

The sounds load fine, as they still respond to mouse events, but I just cannot get SM2 to play based on this cookie script.

PS
I am not java programmer, so the verious website that delve into java theory just give me a headache!!

Surely there is a simple call function/syntax that will call the play function of SM2 from within this script?

Thanks in advance.

And great product, congrats to the development team :o)

PAUL
 
sad I’m frustrated
Inappropriate?
1 person has this question

User_default_medium