-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Exercise 9: Loading Audio via Javascript | ||
|
||
In this exercise, you will include an audio player via Javascript so that you can | ||
go through multiple audio files. Use the skeleton in `exercises/09_js_audio/exercise.html`. | ||
|
||
In this exercise, I defined a list of stimuli in the file `stims.js`. You don't need | ||
to edit this file but take a look at it, so that you know the structure of each | ||
stimulus. | ||
|
||
# Steps | ||
|
||
1. Complete the function `loadNextAudio`. You just have to update the title and | ||
you have to include the HTML for the audio player with the correct audio. (Hint: | ||
use the `text` and `html` functions). | ||
|
||
Also, try to understand what is happening with the variable `i` and why you can | ||
loop through the list multiple times. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Audio and Javscript</title> | ||
<script src="js/jquery.js" charset="utf-8"></script> | ||
<script src="js/stims.js" charset="utf-8"></script> | ||
<script src="js/functions.js" charset="utf-8"></script> | ||
|
||
</head> | ||
<body> | ||
<h1> Audio and Javascript</title> | ||
<h3 id="title"></h3> | ||
<div id="audio-container"> | ||
|
||
</div> | ||
|
||
<p><input type="button" onclick="loadNextAudio();" value="Next"/> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
var i = 0; | ||
|
||
|
||
function loadNextAudio() { | ||
|
||
stim = stims[i]; | ||
|
||
//your code goes here | ||
|
||
i = (i + 1) % stims.length; | ||
} | ||
|
||
|
||
|
||
$(document).ready(function() { | ||
loadNextAudio(); | ||
}); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var stims = [ | ||
|
||
{audio: "boogalooo", title: "Boogalooo"}, | ||
{audio: "flamingo", title: "Flamingo"}, | ||
{audio: "twist", title: "Twist"} | ||
] |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
var i = 0; | ||
|
||
|
||
function loadNextAudio() { | ||
|
||
stim = stims[i]; | ||
|
||
$("#audio-container").html(' \ | ||
<audio controls> \ | ||
<source src="audio/'+ stim.audio + '.ogg" type="audio/ogg"> \ | ||
<source src="audio/'+ stim.audio + '.mp3" type="audio/mpeg"> \ | ||
Your browser does not support the audio element. \ | ||
</audio> \ | ||
'); | ||
|
||
$("#title").text(stim.title); | ||
|
||
i = (i + 1) % stims.length; | ||
} | ||
|
||
|
||
|
||
$(document).ready(function() { | ||
loadNextAudio(); | ||
}); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var stims = [ | ||
|
||
{audio: "boogalooo", title: "Boogalooo"}, | ||
{audio: "flamingo", title: "Flamingo"}, | ||
{audio: "twist", title: "Twist"} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Audio and Javscript</title> | ||
<script src="js/jquery.js" charset="utf-8"></script> | ||
<script src="js/stims.js" charset="utf-8"></script> | ||
<script src="js/functions.js" charset="utf-8"></script> | ||
|
||
</head> | ||
<body> | ||
<h1> Audio and Javascript</title> | ||
<h3 id="title"></h3> | ||
<div id="audio-container"> | ||
|
||
</div> | ||
|
||
<p><input type="button" onclick="loadNextAudio();" value="Next"/> | ||
</body> | ||
</html> |