text: 
  'use strict';
  
  var utils = require('../utils');
  var onFileProgress = utils.onFileProgress;
  var handleFileUpload = require('../handlefileupload').handleFileUpload;
  var initSocket = require('../socket').initSocket;
  var showError = require('./showerror').showError;
  var effects = require('./effects');
  
  
  var LOOKUP_TABLE = {
    a: ['STH.flac', 'Us_English_Broadband_Sample_2.wav'],
  };
  
  var playSample = (function() {
  
    var running = false;
    localStorage.setItem('currentlyDisplaying', false);
  
    return function(token, imageTag, iconName, url, callback) {
  
      $.publish('clearscreen');
  
      var currentlyDisplaying = JSON.parse(localStorage.getItem('currentlyDisplaying'));
  
      console.log('CURRENTLY DISPLAYING', currentlyDisplaying);
  
      // This error handling needs to be expanded to accomodate
      // the two different play samples files
      if (currentlyDisplaying) {
        console.log('HARD SOCKET STOP');
        $.publish('socketstop');
        localStorage.setItem('currentlyDisplaying', false);
        effects.stopToggleImage(timer, imageTag, iconName);
        effects.restoreImage(imageTag, iconName);
        running = false;
        return;
      }
  
      if (currentlyDisplaying && running) {
        showError('Currently another file is playing, please stop the file or wait until it finishes');
        return;
      }
  
      localStorage.setItem('currentlyDisplaying', true);
      running = true;
  
      var timer = setInterval(effects.toggleImage, 750, imageTag, iconName);
  
      var xhr = new XMLHttpRequest();
      xhr.open('GET', url, true);
      xhr.responseType = 'blob';
      xhr.onload = function(e) {
        var blob = xhr.response;
        var currentModel = localStorage.getItem('currentModel') || 'en-US_BroadbandModel';
        var reader = new FileReader();
        var blobToText = new Blob([blob]).slice(0, 4);
        reader.readAsText(blobToText);
        reader.onload = function() {
          var contentType = reader.result === 'fLaC' ? 'audio/flac' : 'audio/wav';
          console.log('Uploading file', reader.result);
          var mediaSourceURL = URL.createObjectURL(blob);
          var audio = new Audio();
          audio.src = mediaSourceURL;
          audio.play();
          $.subscribe('hardsocketstop', function() {
            audio.pause();
            audio.currentTime = 0;
          });
          $.subscribe('socketstop', function() {
            audio.pause();
            audio.currentTime = 0;
          });
          handleFileUpload(token, currentModel, blob, contentType, function(socket) {
            var parseOptions = {
              file: blob
            };
            onFileProgress(parseOptions,
              // On data chunk
              function(chunk) {
                socket.send(chunk);
              },
              // On file read error
              function(evt) {
                console.log('Error reading file: ', evt.message);
                // showError(evt.message);
              },
              // On load end
              function() {
                socket.send(JSON.stringify({'action': 'stop'}));
              });
          }, 
          // On connection end
            function(evt) {
              effects.stopToggleImage(timer, imageTag, iconName);
              effects.restoreImage(imageTag, iconName);
              localStorage.getItem('currentlyDisplaying', false);
            }
          );
        };
      };
      xhr.send();
    };
  })();
  
  
  exports.initPlaySample = function(ctx) {
  
    (function() {
      var fileName = 'audio/' + LOOKUP_TABLE.a[0];
      var el = $('.play-sample-1');
      var progressName = $('.intro-text');
      el.off('click');
      var iconName = 'play';
      var imageTag = el.find('img');
      var startRecord = progressName.find(".start-record");
      var recording = progressName.find(".recording");
      var preparing = progressName.find(".preparing");
  
      preparing.hide();
      startRecord.show();
      recording.hide();
  
      el.click( function(evt) {
          startRecord.hide();
          preparing.show();
          recording.hide();
        playSample(ctx.token, imageTag, iconName, fileName, function(result) {
          console.log('Play sample result', result);
        });
      });
    })(ctx, LOOKUP_TABLE);
  
  };