iLearningGlobal – Audio Autorun
The code below does an interesting thing. It is basically a cookie detector for first time visitors on the iLearningGlobal website I run.
The problem I had was that I wanted to automatically run the audio the first time someone visited the site, and then require them to push play on later visits. (See the iLearningGlobal website for the example)
Finally, I added it to the sidebar with a cookie setter and this if statement. It looks like a lot, but take out the audio player and it is really not that much. The two options are the same, with only the auto-play feature different. echo means print in PHP.
<?phpif (isset($_COOKIE["user"]))
echo ‘<object type=”application/x-shockwave-flash” data=”http://www.liquidlearning.com/wp-content/plugins/pb-embedflash/swf/mediaplayer.swf?width=250&height=190″ width=”250″ height=”190″ class=”embedflash”><param name=”movie” value=”http://www.liquidlearning.com/wp-content/plugins/pb-embedflash/swf/mediaplayer.swf?width=250&height=190″ /><param name=”allowfullscreen” value=”true” /><param name=”allowscriptaccess” value=”always” /><param name=”flashvars” value=”searchbar=false&image=http://www.liquidlearning.com/wp-content/uploads/2009/01/ilearning-global-contact2.gif&shownavigation=true&autostart=false&file=http://www.liquidlearning.com/wp-content/uploads/2009/01/webintro.mp3″ /><small>(Either JavaScript is not active or you are using an old version of Adobe Flash Player. <a href=”http://www.adobe.com/”>Please install the newest Flash Player</a>.)</small></object><br>’;
else
echo ‘<object type=”application/x-shockwave-flash” data=”http://www.liquidlearning.com/wp-content/plugins/pb-embedflash/swf/mediaplayer.swf?width=250&height=190″ width=”250″ height=”190″ class=”embedflash”><param name=”movie” value=”http://www.liquidlearning.com/wp-content/plugins/pb-embedflash/swf/mediaplayer.swf?width=250&height=190″ /><param name=”allowfullscreen” value=”true” /><param name=”allowscriptaccess” value=”always” /><param name=”flashvars” value=”searchbar=false&image=http://www.liquidlearning.com/wp-content/uploads/2009/01/ilearning-global-contact2.gif&shownavigation=true&autostart=true&file=http://www.liquidlearning.com/wp-content/uploads/2009/01/webintro.mp3″ /><small>(Either JavaScript is not active or you are using an old version of Adobe Flash Player. <a href=”http://www.adobe.com/”>Please install the newest Flash Player</a>.)</small></object><br>’;$expire=time()+60*60*24*90;
setcookie(“user”, “yes”, $expire);
?>
The end result is higher conversion because people hear a welcoming audio on the first visit to this iLearningGlobal website – and I do not loose much in the way of bouncing visitors because it does not play on the next page they visit.
Programming Note: I am sure this code can be improved upon by a programmer. I do not program full time any more. Feel free to leave a comment on how to make it better if you so wish.


![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=49f70570-f901-48cc-b88e-7075f616fb9b)




