public/audiojs/audio.js
function(wrapper, audio) {
      if (!audio.settings.createPlayer) return;
      var player = audio.settings.createPlayer,
          playPause = getByClass(player.playPauseClass, wrapper),
          scrubber = getByClass(player.scrubberClass, wrapper),
          leftPos = function(elem) {
            var curleft = 0;
            if (elem.offsetParent) {
              do { curleft += elem.offsetLeft; } while (elem = elem.offsetParent);
            }
            return curleft;
          };

      container[audiojs].events.addListener(playPause, 'click', function(e) {
        audio.playPause.apply(audio);
      });

      container[audiojs].events.addListener(scrubber, 'click', function(e) {
        var relativeLeft = e.clientX - leftPos(this);
        audio.skipTo(relativeLeft / scrubber.offsetWidth);
      });

      // _If flash is being used, then the following handlers don't need to be registered._
      if (audio.settings.useFlash) return;

      // Start tracking the load progress of the track.
      container[audiojs].events.trackLoadProgress(audio);

      container[audiojs].events.addListener(audio.element, 'timeupdate', function(e) {
        audio.updatePlayhead.apply(audio);
      });

      container[audiojs].events.addListener(audio.element, 'ended', function(e) {
        audio.trackEnded.apply(audio);
      });

      container[audiojs].events.addListener(audio.source, 'error', function(e) {
        // on error, cancel any load timers that are running.
        clearInterval(audio.readyTimer);
        clearInterval(audio.loadTimer);
        audio.settings.loadError.apply(audio);
      });

    }
function(wrapper, audio) {
      if (!audio.settings.createPlayer) return;
      var player = audio.settings.createPlayer,
          playPause = getByClass(player.playPauseClass, wrapper),
          scrubber = getByClass(player.scrubberClass, wrapper),
          leftPos = function(elem) {
            var curleft = 0;
            if (elem.offsetParent) {
              do { curleft += elem.offsetLeft; } while (elem = elem.offsetParent);
            }
            return curleft;
          };

      container[audiojs].events.addListener(playPause, 'click', function(e) {
        audio.playPause.apply(audio);
      });

      container[audiojs].events.addListener(scrubber, 'click', function(e) {
        var relativeLeft = e.clientX - leftPos(this);
        audio.skipTo(relativeLeft / scrubber.offsetWidth);
      });

      // _If flash is being used, then the following handlers don't need to be registered._
      if (audio.settings.useFlash) return;

      // Start tracking the load progress of the track.
      container[audiojs].events.trackLoadProgress(audio);

      container[audiojs].events.addListener(audio.element, 'timeupdate', function(e) {
        audio.updatePlayhead.apply(audio);
      });

      container[audiojs].events.addListener(audio.element, 'ended', function(e) {
        audio.trackEnded.apply(audio);
      });

      container[audiojs].events.addListener(audio.source, 'error', function(e) {
        // on error, cancel any load timers that are running.
        clearInterval(audio.readyTimer);
        clearInterval(audio.loadTimer);
        audio.settings.loadError.apply(audio);
      });

    }
function ( wrapper , audio ) { if ( ! audio . settings . createPlayer ) return ; var player = audio . settings . createPlayer , playPause = getByClass ( player . playPauseClass , wrapper ) , scrubber = getByClass ( player . scrubberClass , wrapper ) , leftPos = function ( elem ) { var curleft = 0 ; if ( elem . offsetParent ) { do { curleft += elem . offsetLeft ; } while ( elem = elem . offsetParent ) ; } return curleft ; } ; container [ audiojs ] . events . addListener ( playPause , 'click' , function ( e ) { audio . playPause . apply ( audio ) ; } ) ; container [ audiojs ] . events . addListener ( scrubber , 'click' , function ( e ) { var relativeLeft = e . clientX - leftPos ( this ) ; audio . skipTo ( relativeLeft / scrubber . offsetWidth ) ; } ) ; // _If flash is being used, then the following handlers don't need to be registered._ if ( audio . settings . useFlash ) return ; // Start tracking the load progress of the track. container [ audiojs ] . events . trackLoadProgress ( audio ) ; container [ audiojs ] . events . addListener ( audio . element , 'timeupdate' , function ( e ) { audio . updatePlayhead . apply ( audio ) ; } ) ; container [ audiojs ] . events . addListener ( audio . element , 'ended' , function ( e ) { audio . trackEnded . apply ( audio ) ; } ) ; container [ audiojs ] . events . addListener ( audio . source , 'error' , function ( e ) { // on error, cancel any load timers that are running. clearInterval ( audio . readyTimer ) ; clearInterval ( audio . loadTimer ) ; audio . settings . loadError . apply ( audio ) ; } ) ; }
Attaches useful event callbacks to an `audiojs` instance.
Attaches useful event callbacks to an audiojs instance .