|
| 1 | +<html> |
| 2 | + <head> |
| 3 | + <meta charset="UTF-8" /> |
| 4 | + <link href="../Styles/prettify.css" rel="stylesheet" type="text/css" /> |
| 5 | + <link href="../Styles/desert.css" rel="stylesheet" type="text/css"> |
| 6 | + <link href="../Styles/styles.css" rel="stylesheet" type="text/css" /> |
| 7 | + <style type="text/css"> |
| 8 | + .centerTitle |
| 9 | + { |
| 10 | + margin-left: auto; |
| 11 | + margin-right: auto; |
| 12 | + width: 90%; |
| 13 | + background-color: #b0e0e6; |
| 14 | + text-align: center; |
| 15 | + height: 50px; |
| 16 | + font-size: xx-large; |
| 17 | + } |
| 18 | + .centerImage |
| 19 | + { |
| 20 | + margin-left: auto; |
| 21 | + margin-right: auto; |
| 22 | + width: 100%; |
| 23 | + margin-top: 25px; |
| 24 | + } |
| 25 | + </style> |
| 26 | + </head> |
| 27 | + <body onload="prettyPrint()"> |
| 28 | + <header> |
| 29 | + <h1> |
| 30 | + Live Demo Steps |
| 31 | + </h1> |
| 32 | + <nav> |
| 33 | + <ul> |
| 34 | + <li> |
| 35 | + <button id="prev-btn" title="Previous slide"> |
| 36 | + Previous Slide</button></li> |
| 37 | + <li><span id="slide-number"></span>/<span id="slide-total"></span></li> |
| 38 | + <li> |
| 39 | + <button id="next-btn" title="Next Slide"> |
| 40 | + Next Slide</button></li> |
| 41 | + </ul> |
| 42 | + </nav> |
| 43 | + </header> |
| 44 | + <div id="deck"> |
| 45 | + <!-- Begin slides --> |
| 46 | + <section> |
| 47 | + <center> <h1> |
| 48 | + Let's Code!!!</h1></center> |
| 49 | + <img src="../Images/letsCode.jpg" alt="#"> |
| 50 | + |
| 51 | + </section> |
| 52 | + |
| 53 | + <section> |
| 54 | + <h2> |
| 55 | + Start:</h2> |
| 56 | + <ul> |
| 57 | + <li>We need to create a html document with the default tags</li> |
| 58 | + </ul> |
| 59 | + <pre class="prettyprint"> |
| 60 | +<span class="tag"><!DOCTYPE html></span> |
| 61 | +<span class="tag"><html lang="en"></span> |
| 62 | + <span class="tag"><head></span> |
| 63 | + <span class="tag"><meta charset="utf-8" /></span> |
| 64 | +<span class="tag"><title><span class="tag"></title></span></span> |
| 65 | + <span class="tag"></head></span> |
| 66 | + <span class="tag"><body></span><span class="tag"></body></span> |
| 67 | +<span class="tag"></html></span> |
| 68 | + </pre> |
| 69 | + </section> |
| 70 | + |
| 71 | + |
| 72 | + <section> |
| 73 | + <h2> |
| 74 | + Step 1:</h2> |
| 75 | + <ul> |
| 76 | + <li>Add the HTML element audio.</li> |
| 77 | + <li>We add the source that has the song path.</li> |
| 78 | + </ul> |
| 79 | + |
| 80 | + <pre class="prettyprint"> |
| 81 | +<span class="tag"><audio</span> id="myMusicPlayer" preload="auto" tabindex="0" controls=""> |
| 82 | + <span class="tag"><source</span> src="..\Music\Fixed Frequencies.mp3" |
| 83 | + type="audio/mpeg" /> |
| 84 | +<span class="tag"></audio</span>> |
| 85 | + </pre> |
| 86 | + </section> |
| 87 | + |
| 88 | + <section> |
| 89 | + <h2> |
| 90 | + Step 2:</h2> |
| 91 | + <ul> |
| 92 | + <li>Create the list with the songs.</li> |
| 93 | + <li>For this we add a unordered list and inside an anchor element with the song path.</li> |
| 94 | + </ul> |
| 95 | + <pre class="prettyprint"> |
| 96 | +<span class="tag"><ul id="myPlayList"></span> |
| 97 | + <span class="tag"><li></span> |
| 98 | + <span class="tag"><a href="..\Music\Fixed Frequencies.mp3">Fixed Frequencies<span class="tag"></a></span></span> |
| 99 | + <span class="tag"></li></span> |
| 100 | +... |
| 101 | +<span class="tag"></ul></span> |
| 102 | + </pre> |
| 103 | + </section> |
| 104 | + |
| 105 | + <section> |
| 106 | + <h2> |
| 107 | + Step 3:</h2> |
| 108 | + <ul> |
| 109 | + <li>We need the jquery library.</li> |
| 110 | + </ul> |
| 111 | + <pre class="prettyprint"> |
| 112 | +<span class="tag"><script src="../Scripts/jquery-1.9.0.js" type="text/javascript"> |
| 113 | + <span class="tag"></script></span></span></pre> |
| 114 | + <ul> |
| 115 | + <li>We have to asociate the anchor click event with the audio element.</li> |
| 116 | + <li>We have to add some javascript code.<br></li> |
| 117 | + <li>When we click on an anchor link the song should be loaded.</li> |
| 118 | + </ul> |
| 119 | + </section> |
| 120 | + |
| 121 | + <section> |
| 122 | + <h2>Step 3:</h2> |
| 123 | + <pre class="prettyprint"> |
| 124 | +var myPlayList = $('#myPlayList'); |
| 125 | +var playListIndex = 0; |
| 126 | +myPlayList.find('a').click(function(e) |
| 127 | +{ |
| 128 | + e.preventDefault(); |
| 129 | + var link = $(this); |
| 130 | + playListIndex = link.parent().index(); |
| 131 | + play(link); // we have to create the function play. |
| 132 | +}); |
| 133 | + </pre> |
| 134 | + </section> |
| 135 | + |
| 136 | + <section> |
| 137 | + <h2>Step 4:</h2> |
| 138 | + <ul> |
| 139 | + </br> |
| 140 | + <li>We will create the function play.</li> |
| 141 | + <li>The function play first assign the source of the audio element with the value of the link(in this case is the song path)<br></li> |
| 142 | + <li>Then it's loading the song in the audio element</li> |
| 143 | + <li>Finally,it executes the play function for starting reproduce the song.</li> |
| 144 | + </ul> |
| 145 | + </section> |
| 146 | + <section> |
| 147 | + <h2>Step 4: Create the function play</h2> |
| 148 | + </br> |
| 149 | + <pre class="prettyprint"> |
| 150 | +var myMusicPlayer = $('#myMusicPlayer'); |
| 151 | +function play(link) |
| 152 | +{ |
| 153 | + myMusicPlayer[0].src = link.attr('href'); |
| 154 | + myMusicPlayer[0].load(); |
| 155 | + myMusicPlayer[0].play(); |
| 156 | +} </pre> |
| 157 | + </section> |
| 158 | + |
| 159 | + <section> |
| 160 | + <h2>Step 5:</h2> |
| 161 | + <ul></br> |
| 162 | + <li>Now we have to add a function for reproduce the next song when the current finish.</li> |
| 163 | + <li>For this, we will add a javascript eventlistener to the audio element when executes the 'ended' function. </li> |
| 164 | + <li>We search the next item in the playlist, and then we call the play function.</li> |
| 165 | + </ul> |
| 166 | + </section> |
| 167 | + |
| 168 | + <section> |
| 169 | + <h2>Step 5: Adding EventListener</h2> |
| 170 | + <pre class="prettyprint"> |
| 171 | +var tracks = myPlayList.find('li a'); |
| 172 | +var playListLength = tracks.length; |
| 173 | +myMusicPlayer[0].addEventListener('ended', function() |
| 174 | +{ |
| 175 | + var link; playListIndex++; |
| 176 | + if (playListIndex >= playListLength){ playListIndex = 0; |
| 177 | + link = myPlayList.find('a')[0]; } |
| 178 | + else { link = myPlayList.find('a')[playListIndex];} |
| 179 | + play($(link));}); |
| 180 | +</pre> |
| 181 | + </section> |
| 182 | + |
| 183 | + |
| 184 | + <section> |
| 185 | + <h2>Step 6:Adding drag and drop</h2> |
| 186 | + <ul></br> |
| 187 | + <li>We will add the ability to drag a song to the desktop. </li> |
| 188 | + <li>For this we need to add the property draggable to the anchor element and add a class to identify them </li> |
| 189 | + </ul> |
| 190 | + <pre class="prettyprint">$('a').addClass('dragout'); |
| 191 | +$('a').attr('draggable', 'true'); </pre> |
| 192 | + <ul><li>Now we have to create a funtion in javascript to handler the events that the draggable property allows to do in the anchor element. </li></ul> |
| 193 | + </section> |
| 194 | + |
| 195 | + <section> |
| 196 | + <h2>Step 6:Adding drag and drop</h2> |
| 197 | + <pre class="prettyprint"> |
| 198 | +(function() { |
| 199 | + var files = document.querySelectorAll('a.dragout'); |
| 200 | + for (var i = 0, file; file = files[i]; ++i) { |
| 201 | + file.addEventListener('dragstart', function(e) { |
| 202 | + var strippedUrl = document.location.toString().split("Views"); |
| 203 | + var href = this.getAttribute('href'); |
| 204 | + var dataDownloadUrl = 'audio/mpeg:' + href.substring(9, href.length).replace(' ', '%20') + ':' + strippedUrl[0].toString() + href.substring(3, href.length).replace('\\','/').replace(' ', '%20'); |
| 205 | + e.dataTransfer.setData('DownloadURL', dataDownloadUrl); |
| 206 | + }, false);}})(); |
| 207 | +</pre> |
| 208 | + </section> |
| 209 | + </div> |
| 210 | + <script type="text/javascript" src="../Scripts/jquery-1.9.0.js"></script> |
| 211 | + <script type="text/javascript" src="../Scripts/prettify.js"></script> |
| 212 | + <script type="text/javascript" src="../Scripts/htmlSlides.js"></script> |
| 213 | + <script type="text/javascript" src="../Scripts/jquery.jswipe-0.1.2.js"></script> |
| 214 | + <script type="text/javascript"> |
| 215 | + $(function () { |
| 216 | + htmlSlides.init(); |
| 217 | + }); |
| 218 | + </script> |
| 219 | + </body> |
| 220 | +</html> |
0 commit comments