Back to Parent

<!DOCTYPE HTML>
<html>

<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" type="text/css" href="style.css">
  <!-- uncomment lines below to include extra p5 libraries -->
  <!--<script language="javascript" src="libraries/p5.dom.js"></script>-->
  <!--<script language="javascript" src="libraries/p5.sound.js"></script>-->
  <!-- this line removes any default padding and style. you might only need one of these values set. -->
  <style> body {padding: 0; margin: 0;} </style>
  <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
   <!-- Latest compiled and minified CSS -->
</script>

</head>

<body>

	<div id="particle-login" />

    <P>Event name:<input type="text" name="eventNameBox" id="evText" value="rme2017-lovelock-triggered">
    <br><br>
    <button id="connectbutton" onclick="start()">Connect</button>
    <br><br>
<div class="bl">
<img src="lockslonger.gif"> </img>
</div>


    <audio controls id="voices">
      <source src="voices_mixdown.mp3" type="audio/mpeg">
      Your browser does not support the audio element.
    </audio>

    <audio controls id="waterfall" preload class="songs">
      <source src="waterfall.mp3" type="audio/mpeg">
      Your browser does not support the audio element.
    </audio>

    <audio controls id="thunderstorm" preload class="songs">
      <source src="thunderstorm.m4a" type="audio/mpeg">
      Your browser does not support the audio element.
    </audio>

    <pre><code id="datalog"></code></pre>


    <script type="text/javascript">



    // Go to Particle Build

    // Access Settings

    // And add your access token here


    //cut from here


    var accessToken = "362761d3b8d4980d024c05ace52781d454295a95";



    function start(objButton) {
        document.getElementById("connectbutton").innerHTML = "Running";
        var eventName = document.getElementById('evText').value;
		var requestURL = "https://api.particle.io/v1/events/rme2017-lovelock?access_token=" + accessToken;

        var eventSource = new EventSource(requestURL);

        eventSource.addEventListener('open', function(e) {
            console.log("Opened!"); },false);

        eventSource.addEventListener('error', function(e) {
            console.log("Errored!"); },false);

        eventSource.addEventListener(eventName, function(e) {
            var eventData = JSON.parse(e.data);

            var data = eventData['data'];

            datalog.prepend( data + "\n" );

            if( data == "Info" ){
              $("#voices").trigger('play');
              crickets.loop = false;
              $(".bl").show();
            }else if( data == "plate" ){
              $("#waterfall").trigger('play');
            }else if( data == "fork" ){
              $("#fork").trigger('play');
            }

        }, false);
    }


//to here

    function stopAudio(){
      //pause playing

      $("#fork").trigger('pause');
      //set play time to 0

      $("#fork").prop("currentTime",0);
    }

    </script>
</body>
</html>
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0