{"id":767,"date":"2011-06-03T18:48:48","date_gmt":"2011-06-03T18:48:48","guid":{"rendered":"http:\/\/mauspace.com\/space\/?p=767"},"modified":"2013-07-17T21:49:19","modified_gmt":"2013-07-17T21:49:19","slug":"html-5-audio","status":"publish","type":"post","link":"https:\/\/mauspace.com\/space\/?p=767","title":{"rendered":"Html5 Audio"},"content":{"rendered":"<div class=\"twttr_buttons\"><div class=\"twttr_twitter\">\n\t\t\t\t\t<a href=\"http:\/\/twitter.com\/share?text=Html5+Audio\" class=\"twitter-share-button\" data-via=\"\" data-hashtags=\"\"  data-size=\"default\" data-url=\"https:\/\/mauspace.com\/space\/?p=767\"  data-related=\"\" target=\"_blank\">Tweet<\/a>\n\t\t\t\t<\/div><\/div><p><a href=\"http:\/\/mauspace.com\/space\/wp-content\/uploads\/2011\/06\/browsersuport1.jpg\"><br \/>\n<\/a>1-First you need a source in mp3 and ogg.here you came find a online converter\u00a0<a title=\"http:\/\/media.io\/\" href=\"http:\/\/media.io\/\">http:\/\/media.io\/<\/a><\/p>\n<p>2-Jquary is needed<\/p>\n<p><a title=\"http:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.4\/jquery.min.js\" href=\"http:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.4\/jquery.min.js\">http:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.4\/jquery.min.js<\/a><\/p>\n<p>3- create a progress bar with css<br \/>\n.position {<br \/>\nposition:static;<br \/>\nleft: 0px;<br \/>\nz-index: 0;<br \/>\nwidth: 0%;<br \/>\nbackground: #990000;<br \/>\nheight: 30px;<br \/>\nmargin-top: 0px;<br \/>\n}<br \/>\n.controls {<br \/>\nwidth: 500px;<br \/>\n}<br \/>\n4- create a div in the html.<\/p>\n<p>&lt;div class=&#8221;controls&gt;&lt;div class=&#8221;position&#8221;\u00a0style=&#8221;width: 0%; &#8220;&gt;&lt;\/div&gt;&lt;\/div&gt;<\/p>\n<p>5-Create the audio tag new for html5 in this case try to use the autoplay and id audio-player and three buttons play,pause and stop whit Id.You need a litle trick for all source you need mp3 ,ogg ,wav and for IE8 a swf its a solution.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/mauspace.com\/space\/wp-content\/uploads\/2011\/06\/browsersuport1.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"browsersuport\" alt=\"\" src=\"http:\/\/mauspace.com\/space\/wp-content\/uploads\/2011\/06\/browsersuport1.jpg\" width=\"500\" height=\"156\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;div id=&#8221;nowPlaying&#8221;&gt;&lt;audio id=&#8221;audio-player&#8221; name=&#8221;audio-player&#8221; autoplay&gt;<\/p>\n<p>&lt;source src=&#8221;jazz.mp3&#8243; \/&gt;<\/p>\n<p>&lt;source src=&#8221;jazz.ogg&#8221; \/&gt;<\/p>\n<p>&lt;source src=&#8221;jazz.wav&#8221; \/&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>&lt;p&gt;Your browser doesn&#8217;t recognize audio&lt;\/p&gt;&lt;\/audio&gt;<br \/>\n&lt;a id=&#8221;play-bt&#8221; href=&#8221;#&#8221;&gt;&lt;img src=&#8221;images\/play.png&#8221; alt=&#8221;||&#8221; \/&gt;&lt;\/a&gt; &lt;a id=&#8221;pause-bt&#8221; href=&#8221;#&#8221;&gt;&lt;img src=&#8221;images\/pause.png&#8221; alt=&#8221;||&#8221; \/&gt;&lt;\/a&gt; &lt;a id=&#8221;stop-bt&#8221; href=&#8221;#&#8221;&gt;&lt;img src=&#8221;images\/stop.png&#8221; alt=&#8221;||&#8221; \/&gt;&lt;\/a&gt;<br \/>\n&lt;\/div&gt;<\/p>\n<p>6-start a java Script with the function for the buttons , start used $Api to call the play and stop.And<br \/>\n$(&#8216;.controls .position&#8217;).width(&#8216;0%&#8217;) this star in 0 when you click stop.<\/p>\n<p>$(&#8220;#play-bt&#8221;).click(function(){<br \/>\n$(&#8220;#audio-player&#8221;)[0].play();<\/p>\n<p>})<\/p>\n<p>$(&#8220;#pause-bt&#8221;).click(function(){<br \/>\n$(&#8220;#audio-player&#8221;)[0].pause();<br \/>\n})<\/p>\n<p>$(&#8220;#stop-bt&#8221;).click(function(){<br \/>\n$(&#8220;#audio-player&#8221;)[0].pause();<br \/>\n$(&#8220;#audio-player&#8221;)[0].currentTime = 0;<br \/>\n$(&#8216;.controls .position&#8217;).width(&#8216;0%&#8217;);<\/p>\n<p>})<br \/>\n7- update the event and calculate the progress with length of the sound<\/p>\n<p>$(&#8220;#audio-player&#8221;)[0].addEventListener(&#8216;timeupdate&#8217;, function(){<br \/>\nvar length = this.duration;<br \/>\nvar secs = this.currentTime;<br \/>\nvar progress = (secs \/ length) * 100;<br \/>\n$(&#8216;.controls .position&#8217;).width( (progress +&#8217;%&#8217;) );<\/p>\n<p>},false);<\/p>\n<p><a href=\"http:\/\/mauspace.com\/space\/wp-content\/uploads\/2011\/06\/audio.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-769\" title=\"audio\" alt=\"\" src=\"http:\/\/mauspace.com\/space\/wp-content\/uploads\/2011\/06\/audio.jpg\" width=\"194\" height=\"86\" \/><\/a><br \/>\nThis Is It<\/p>\n<div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>1-First you need a source in mp3 and ogg.here you came find a online converter\u00a0http:\/\/media.io\/ 2-Jquary is needed http:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.4\/jquery.min.js 3- create a progress bar with css .position { position:static; left: 0px; z-index: 0; width: 0%; background: #990000; height: 30px; margin-top: 0px; } .controls { width: 500px; } 4- create a div in the html. &lt;div <a class=\"more-link excerpt-link\" href=\"https:\/\/mauspace.com\/space\/?p=767\">Continue Reading<span class=\"glyphicon glyphicon-chevron-right\"><\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48],"tags":[],"_links":{"self":[{"href":"https:\/\/mauspace.com\/space\/index.php?rest_route=\/wp\/v2\/posts\/767"}],"collection":[{"href":"https:\/\/mauspace.com\/space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mauspace.com\/space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mauspace.com\/space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mauspace.com\/space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=767"}],"version-history":[{"count":9,"href":"https:\/\/mauspace.com\/space\/index.php?rest_route=\/wp\/v2\/posts\/767\/revisions"}],"predecessor-version":[{"id":1119,"href":"https:\/\/mauspace.com\/space\/index.php?rest_route=\/wp\/v2\/posts\/767\/revisions\/1119"}],"wp:attachment":[{"href":"https:\/\/mauspace.com\/space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=767"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mauspace.com\/space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=767"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mauspace.com\/space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=767"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}