

/**
 * AudioPlayer.js
 * 
 * @package MPEGAudio
 * @copyright 2007 SCREAMDESIGN GmbH
 * @link http://www.screamdesign.de/
 * @version $Id: AudioPlayer.js 181 2007-06-08 08:31:04Z pschillinger $
 */

function AudioPlayer()
{
   if (navigator.appName.indexOf('Microsoft') != -1)
   {
      this.player = document.getElementById('AudioPlayerObject');
   } else {
      this.player = document.getElementById('AudioPlayerEmbed');
   }

   this.player.AudioPlayer = this;
   
   this.getBytesLoaded = function()
   {
      return this.player.GetVariable('bytesLoaded');
   }

   this.getBytesTotal = function()
   {
      return this.player.GetVariable('bytesTotal');
   }

   this.getVolume = function()
   {
      return this.player.GetVariable('volume');
   }

   this.setVolume = function(value)
   {
      this.player.SetVariable('volume', value);
      this.player.SetVariable('command', 'volume');
   }

   this.loadAudio = function(url)
   {
      this.player.SetVariable('url', url);
   }

   this.play = function()
   {
      this.player.SetVariable('command', 'play');
   }

   this.stop = function()
   {
      this.player.SetVariable('command', 'stop');
   }

   this.getDuration = function()
   {
      return this.player.GetVariable('duration');
   }

   this.getPosition = function()
   {
      return this.player.GetVariable('position');
   }

   this.setPosition = function(value)
   {
      this.player.SetVariable('position', value);
      this.player.SetVariable('command', 'position');
   }

   this.onFinishedPlaying = function()
   {
   }

}

function finishedPlaying()
{
   var player;
   if (navigator.appName.indexOf('Microsoft') != -1)
   {
      player = document.getElementById('AudioPlayerObject');
   } else {
      player = document.getElementById('AudioPlayerEmbed');
   }
   if (player && player.AudioPlayer && player.AudioPlayer.onFinishedPlaying)
   {
      player.AudioPlayer.onFinishedPlaying();
   }
}