{"id":2276,"date":"2015-02-02T13:15:59","date_gmt":"2015-02-02T11:15:59","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=2276"},"modified":"2018-06-19T11:16:19","modified_gmt":"2018-06-19T08:16:19","slug":"html5-audio-player-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/","title":{"rendered":"HTML5 Audio Player Example"},"content":{"rendered":"<p>In this example we will present you how to use the HTML5 Audio Player.<\/p>\n<p>First, we&#8217;ll present the <code>&lt;audio \/&gt;<\/code> tag and its attributes, for a quick audio integration in your HTML documents.<\/p>\n<p>And, then we will continue with more advanced usage using JavaScript to interact with the <code>HTMLMediaElement<\/code>.<\/p>\n<p>[ulp id=&#8217;tgm4cmEWcKUikZNn&#8217;]<\/p>\n<h2>1. The minimal example<\/h2>\n<p>In order to allow your users to play music directly from the browser you simply have to add the following syntax (Assuming your audio file is located in the <strong>files<\/strong> folder).<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;audio src=&quot;.\/files\/audio.ogg&quot;&gt;\r\n    &lt;p&gt;Your browser does not support the audio element.&lt;\/p&gt;\r\n&lt;\/audio&gt;\r\n<\/pre>\n<p>This will only enable audio in your document, but this will not show any player &#8230;<\/p>\n<blockquote><p><strong>Note : <\/strong>The paragraph inside the audio tag, will be displayed on old browsers that not support the audio tag. You can see the compatibility matrix on the <a href=\"http:\/\/caniuse.com\/#search=audio\" target=\"_blank\" rel=\"noopener\">CanIUse Web Site<\/a><\/p><\/blockquote>\n<h2>2. Show the controls<\/h2>\n<p>The previous example did not diplay the player on the web page. To view the player, simply add the <code>controls<\/code> attribute in the audio tag:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;audio src=&quot;.\/files\/audio.ogg&quot; controls&gt;\r\n    &lt;p&gt;Your browser does not support the audio element.&lt;\/p&gt;\r\n&lt;\/audio&gt;\r\n<\/pre>\n<p>This will display the browser&#8217;s default player with the default controls.<\/p>\n<figure id=\"attachment_2300\" aria-describedby=\"caption-attachment-2300\" style=\"width: 796px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/01\/firefox_default_audio_player.png\"><img decoding=\"async\" class=\"wp-image-2300 size-full\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/01\/firefox_default_audio_player.png\" alt=\"HTML5 Audio Player Default on Firefox\" width=\"796\" height=\"535\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/01\/firefox_default_audio_player.png 796w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/01\/firefox_default_audio_player-300x202.png 300w\" sizes=\"(max-width: 796px) 100vw, 796px\" \/><\/a><figcaption id=\"caption-attachment-2300\" class=\"wp-caption-text\">Default Audio Player on Firefox<\/figcaption><\/figure>\n<figure id=\"attachment_2305\" aria-describedby=\"caption-attachment-2305\" style=\"width: 768px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/01\/chrome_default_audio_player1.png\"><img decoding=\"async\" class=\"wp-image-2305 size-full\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/01\/chrome_default_audio_player1.png\" alt=\"HTML5 Audio Player Default on Chrome\" width=\"768\" height=\"448\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/01\/chrome_default_audio_player1.png 768w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/01\/chrome_default_audio_player1-300x175.png 300w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/a><figcaption id=\"caption-attachment-2305\" class=\"wp-caption-text\">Default Audio Player on Chrome<\/figcaption><\/figure>\n<p>Here is another way to define the media source:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;audio controls&gt;\r\n    &lt;p&gt;Your browser does not support the audio element.&lt;\/p&gt;\r\n    &lt;source src=&quot;.\/files\/audio.ogg&quot; \/&gt;\r\n&lt;\/audio&gt;\r\n<\/pre>\n<blockquote><p><strong>Note : <\/strong>All the audio format are not supported by all the browser, you can find a compatibility matrix on the <a href=\"http:\/\/en.wikipedia.org\/wiki\/HTML5_Audio#Supported_audio_coding_formats\" target=\"_blank\" rel=\"noopener\">Dedicated Wikipedia Web Page<\/a><\/p><\/blockquote>\n<h2>3. Tag Attributes<\/h2>\n<p>The <code>&lt;audio \/&gt;<\/code> Tag accept attributes that will help you to manage the behaviour of the media on your page.<\/p>\n<h3>3.1 Controls<\/h3>\n<p>This attribute will display the default browser player on the page, with the default controls, those controls are : <strong>Play<\/strong> and <strong>Pause<\/strong> buttons, <strong>Volume<\/strong> control, and the track duration.<\/p>\n<p>This attribute is used to display the player (as we&#8217;ve seen in the previous section).<\/p>\n<p>You can use it by simply adding the <code>controls<\/code> or <code>controls=\"controls\"<\/code>. It does not matter.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;audio controls=&quot;controls&quot;&gt;\r\n    &lt;p&gt;Your browser does not support the audio element.&lt;\/p&gt;\r\n    &lt;source src=&quot;.\/files\/audio.ogg&quot; \/&gt;\r\n&lt;\/audio&gt;\r\n<\/pre>\n<h3>3.2 Autoplay<\/h3>\n<p>This attribute will start playback once it&#8217;s ready.<\/p>\n<p>So, if you want to start playback on your page without displaying the player, you can do something like that:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;audio autoplay=&quot;autoplay&quot; &gt;\r\n    &lt;p&gt;Your browser does not support the audio element.&lt;\/p&gt;\r\n    &lt;source src=&quot;.\/files\/audio.ogg&quot; \/&gt;\r\n&lt;\/audio&gt;\r\n<\/pre>\n<h3>3.3 Loop<\/h3>\n<p>With this attribute, the audio will play again once it&#8217;s finished.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;audio loop=&quot;loop&quot; autoplay &gt;\r\n    &lt;p&gt;Your browser does not support the audio element.&lt;\/p&gt;\r\n    &lt;source src=&quot;.\/files\/audio.ogg&quot; \/&gt;\r\n&lt;\/audio&gt;\r\n<\/pre>\n<p>This will start playback automatically, and loop at the end of the media, it will start again.<\/p>\n<h3>3.4 Preload<\/h3>\n<p>This attributes will give a hint to the browser on how to treat the media file.<\/p>\n<p>This attribute accept the following values:<\/p>\n<ul>\n<li><em>auto<\/em> : The browser can download the whole file if it&#8217;s needed by the user&#8217;s needs.<\/li>\n<li><em>metadata<\/em> : The user may not need the whole media, so the browser can only check for the metadatas (length) of the file.<\/li>\n<li><em>none<\/em> : The browser won&#8217;t download the file if the user does not need it. This can be use to minimize server trafic.<\/li>\n<\/ul>\n<p><strong><em>Note : <\/em><\/strong> The default value is <em>auto<\/em><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;audio preload=&quot;none&quot; &gt;\r\n    &lt;p&gt;Your browser does not support the audio element.&lt;\/p&gt;\r\n    &lt;source src=&quot;.\/files\/audio.ogg&quot; \/&gt;\r\n&lt;\/audio&gt;\r\n<\/pre>\n<p>In this example the browser will request the server only when the user click on the <strong>play<\/strong> button.<\/p>\n<h2>4. Control the audio with Javascript<\/h2>\n<p>We used the <code>&lt;audio \/&gt;<\/code> Tag to display the player on the page, and to play the audio file.<\/p>\n<p>Now we&#8217;ll see how to manipulate audio with JavaScript.<\/p>\n<h3>4.1 Basic Play \/ Pause example<\/h3>\n<p>For the beginning, we will simply add an audio file in a page and manage the Play \/ Pause buttons in JavaScript.<\/p>\n<p>Here is the HTML code:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;audio id=&quot;audio1&quot;&gt;\r\n    &lt;source src=&quot;..\/files\/2081-Coin_Drop-Willem_Hunt-569197907\/mp3\/Coin_Drop-Willem_Hunt-569197907.mp3&quot; \/&gt;\r\n&lt;\/audio&gt;\r\n&lt;button id=&quot;play&quot;&gt;Play&lt;\/button&gt; &lt;button id=&quot;stop&quot;&gt;Stop&lt;\/button&gt;\r\n<\/pre>\n<p>The goal is to start play the sound when the user click on the play button, and pause the button when the user click on the Stop button.<\/p>\n<p>Here is the JavaScript Code:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar audioElement = document.getElementById('audio1');\r\n\r\ndocument.getElementById('play').addEventListener('click', function(){\r\naudioElement.play();\r\n}, false);\r\n\r\ndocument.getElementById('stop').addEventListener('click', function(){\r\naudioElement.pause();\r\n}, false);\r\n<\/pre>\n<p>Quite simple, no ?<\/p>\n<p>We get the <code>audioElement<\/code> by its ID in the document, and then, we add listener for clicks on the buttons. The <code>audioElement<\/code> variable is global in the scope so it can be accessed in the event callbacks functions.<\/p>\n<h3>4.2 The HTMLMediaElement<\/h3>\n<h4>Properties<\/h4>\n<p>The type of the <code>audioElement<\/code> variable is <code>HTMLMediaElement<\/code> which has many properties, for example:<\/p>\n<ul>\n<li><code>autoplay :<\/code> Reflects the value of the attributes (seen in previous section).<\/li>\n<li><code>currentTime :<\/code> Contains the current playback time, in seconds. Setting this property will set the playback time at the value defined.<\/li>\n<li><code>duration :<\/code> <strong>(Read-Only)<\/strong> The length, in seconds.<\/li>\n<li><code>paused :<\/code> <strong>(Read-Only)<\/strong> Indicates if the playback is paused or not.<\/li>\n<li><code>volume : <\/code> will get or set the volume of the media element : 0.0 is silent, and 1.0 is the loudest<\/li>\n<\/ul>\n<p>You&#8217;ll find the full properties list here : <a href=\"http:\/\/dev.w3.org\/html5\/spec-preview\/media-elements.html\">HTMLMediaElement<\/a>.<\/p>\n<h4>Methods<\/h4>\n<p>The element has also some methods, we&#8217;ve seen <code>play()<\/code> and <code>pause()<\/code> in the basic example, here are the others:<\/p>\n<ul>\n<li><code>canPlayType(mimetype)<\/code> : Determine if the browser can play the <strong>mimetype<\/strong> passed in argument. This function can return :<br \/>\n<code>nothing<\/code> (empty string) if the browser is not able to play the type,<br \/>\n<code>propably<\/code> if the browser seems to be able to play the type,<br \/>\n<code>maybe<\/code> if it&#8217;s impossible to tell if the type is playable or not.<\/li>\n<li><code>fastSeek(time)<\/code> : this will seek directly to the given time.<\/li>\n<li><code>load()<\/code> : This method will begin loading the media from the server<\/li>\n<\/ul>\n<p>When actions are made with the <code>&lt;audio \/&gt;<\/code> tag, some events are fired, let see the events before using all together with a full example.<\/p>\n<h2>5. Use Media Events<\/h2>\n<p>Here are some of the events we can use with audio element.<\/p>\n<ul>\n<li><code>progress :<\/code> The user agent is fetching media data.<\/li>\n<li><code>error :<\/code> An error occurs while fetching the media data.<\/li>\n<li><code>play :<\/code> Playback has begun. Fired after the <code>play()<\/code> method has returned, or when the autoplay attribute has caused playback to begin.<\/li>\n<li><code>pause :<\/code> Playback has been paused. Fired after the pause() method has returned.<\/li>\n<li><code>loadeddata :<\/code> The user agent can render the media data at the current playback position for the first time.<\/li>\n<li><code>waiting :<\/code> Playback has stopped because the next frame is not available, but the user agent expects that frame to become available in due course.<\/li>\n<li><code>playing :<\/code> Playback has started.<\/li>\n<li><code>canplay :<\/code> The user agent can resume playback of the media data, but estimates that if playback were to be started now, the media resource could not be rendered at the current playback rate up to its end without having to stop for further buffering of content.<\/li>\n<li><code>seeking :<\/code> The seeking IDL attribute changed to true and the seek operation is taking long enough that the user agent has time to fire the event.<\/li>\n<li><code>seeked :<\/code> The seeking IDL attribute changed to false.<\/li>\n<li><code>timeupdate :<\/code> The current playback position changed as part of normal playback or in an especially interesting way, for example discontinuously.<br \/>\n<strong><em>Note : <\/em><\/strong>This event will be fired every second !<\/li>\n<li><code>ended :<\/code> Playback has stopped because the end of the media resource was reached.<\/li>\n<li><code>volumechange :<\/code> Either the volume attribute or the muted attribute has changed. Fired after the relevant attribute&#8217;s setter has returned.<\/li>\n<\/ul>\n<p>The full event list can be find here : <a href=\"http:\/\/www.w3.org\/wiki\/HTML\/Elements\/audio#Media_Events\">http:\/\/www.w3.org\/wiki\/HTML\/Elements\/audio#Media_Events<\/a><\/p>\n<h3>5.1 Example<\/h3>\n<p>Let see an example on how to use those events.<\/p>\n<p>In this example we will display information in the browser console &#8230;<\/p>\n<p><em>The HTML code &#8230;<\/em><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;audio id=&quot;audio2&quot; controls&gt;\r\n    &lt;source src=&quot;..\/files\/2081-Coin_Drop-Willem_Hunt-569197907\/mp3\/Coin_Drop-Willem_Hunt-569197907.mp3&quot; \/&gt;\r\n&lt;\/audio&gt;\r\n<\/pre>\n<p><em>&#8230;and the JavaScript.<\/em><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar audioElement = document.getElementById('audio2');\r\n\r\naudioElement.addEventListener('playing', function(e){\r\n  console.log('Audio playback has started ...');\r\n  console.log('Playback started at : '+ e.target.currentTime +&quot; seconds&quot;);\r\n}, false);\r\n\r\naudioElement.addEventListener('pause', function(e){\r\n  console.log('Audio playback has been paused ...');\r\n  console.log('Playback paused at : '+ e.target.currentTime +&quot; seconds&quot;);\r\n}, false);\r\n\r\naudioElement.addEventListener('ended', function(e){\r\n  console.log('Playback has ended');\r\n}, false);\r\n\r\naudioElement.addEventListener('volumechange', function(e){\r\n  console.log(&quot;Volume has changed ...&quot;);\r\n  console.log(&quot;Volume is now &quot;+ e.target.volume);\r\n}, false);\r\n<\/pre>\n<p>First, we get the audio element by its ID and store it in a variable: <code>audioElement<\/code>, then we add listeners on the audio element for the following events :<\/p>\n<ul>\n<li><code>playing<\/code>, callback will log the string : <em>Audio playback has started &#8230;<\/em>, and an info about the currentTime of the element, when the user click on the play button.<br \/>\n<em>Try to start, pause, then start again to see the currentTime info updated.<\/em><\/li>\n<li><code>playing<\/code>, this is fired when the media has been paused &#8230; When the user pause the playback, callback will be called.<\/li>\n<li><code>ended<\/code>, this is fired when the media has ended.<\/li>\n<li><code>volumechange<\/code>, this is fired the volume (of the element, not your computer) has changed, callback will log volume value.<\/li>\n<\/ul>\n<p>For all the events we used the event target to get information about the audio element, we did not used the <code>audioElement<\/code> variable, but for this example we could do it &#8230; I prefer to use the event target because it rely on the event, not the global scope.<\/p>\n<h2>6. Playlist Example<\/h2>\n<p>Let see an example on how to use the <code>&lt;audio \/&gt;<\/code> element in a real world &#8230;<\/p>\n<h3>6.1 The Specifications<\/h3>\n<p>Imagine you are designing a web page for a Lounge Bar, you can add some smooth audio in background to improve user experience.<\/p>\n<p>So we will create a little component that will play multiple files, it means that at the end of a file, the player will start the next audio file. We will also allow the user to stop the music, and to change the volume.<\/p>\n<h3>6.2 The code &#8230;<\/h3>\n<p>Here is the HTML code i decided to use for the component:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;div id=&quot;playlist&quot;&gt;\r\n    &lt;!-- This will only display the player, and enable the audio on the document--&gt;\r\n    &lt;audio controls autoplay&gt;&lt;\/audio&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p>The <code>&lt;div&gt;<\/code> encapsulation, will allow us to position the element more easily.<\/p>\n<p>For example to position the player in the bottom left corner&#8230;:<\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\n#playlist {\r\n    display: inline;\r\n    position: fixed;\r\n    bottom:5px;\r\n    left:5px;\r\n}\r\n<\/pre>\n<p>Then the JavaScript code:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/ Playlist array\r\nvar files = &#x5B;\r\n&quot;.\/files\/2081-Coin_Drop-Willem_Hunt-569197907\/mp3\/Coin_Drop-Willem_Hunt-569197907.mp3&quot;,\r\n&quot;.\/files\/2082-Hammering_Soung_6-Lisa_Redfern-411383436\/mp3\/Hammering_Soung_6-Lisa_Redfern-411383436.mp3&quot;,\r\n&quot;.\/files\/2083-Night_Sounds_-_Crickets-Lisa_Redfern-591005346\/mp3\/Night_Sounds_-_Crickets-Lisa_Redfern-591005346.mp3&quot;\r\n];\r\n\r\n\/\/ Current index of the files array\r\nvar current = 0;\r\n\r\n\/\/ Get the audio element\r\nvar playlistPlayer = document.querySelector(&quot;#playlist audio&quot;);\r\n\r\n\/\/ function that will be call at the end of the previous\r\nfunction next() {\r\n    \/\/ Check for last media in the playlist\r\n    if (current === files.length - 1) {\r\n        current = 0;\r\n    } else {\r\n        current++;\r\n    }\r\n\r\n    \/\/ Change the audio element source\r\n    playlistPlayer.src = files&#x5B;current];\r\n}\r\n\r\n\/\/ Check if the player is in the DOM\r\nif (playlistPlayer === null) {\r\n    throw &quot;Playlist Player does not exists ...&quot;;\r\n} else {\r\n    \/\/ Start the player\r\n    playlistPlayer.src = files&#x5B;current];\r\n\r\n    \/\/ Listen for the playback ended event, to play the next media\r\n    playlistPlayer.addEventListener('ended', next, false)\r\n}\r\n<\/pre>\n<p>This was very simple to do, and it will improve user experience.<\/p>\n<p>Of course we could imagine many improvements such as getting the list of audio files from an Ajax Request, or even designing our own player, but the requirements are satisfied.<\/p>\n<h2>7. Conclusion<\/h2>\n<p>The HTML5 <code>&lt;audio \/&gt;<\/code> offers the ability to easily embed sound into your documents.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here : <a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/01\/html5_audio_player_example.zip\"><strong>HTML5 Audio Player Example<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example we will present you how to use the HTML5 Audio Player. First, we&#8217;ll present the &lt;audio \/&gt; tag and its attributes, for a quick audio integration in your HTML documents. And, then we will continue with more advanced usage using JavaScript to interact with the HTMLMediaElement. [ulp id=&#8217;tgm4cmEWcKUikZNn&#8217;] 1. The minimal example &hellip;<\/p>\n","protected":false},"author":46,"featured_media":914,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[86,87],"class_list":["post-2276","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-html5","tag-audio","tag-player"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>HTML5 Audio Player Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Interested to learn about HTML5 Audio Player? Check out our Example on how to use tag, its attributes &amp; JavaScript to interact with the HTMLMediaElement.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"HTML5 Audio Player Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about HTML5 Audio Player? Check out our Example on how to use tag, its attributes &amp; JavaScript to interact with the HTMLMediaElement.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2015-02-02T11:15:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-06-19T08:16:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Remi Goyard\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@mimiz33\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Remi Goyard\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/\"},\"author\":{\"name\":\"Remi Goyard\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/ae15332f888fcdc376a8d4e03180e242\"},\"headline\":\"HTML5 Audio Player Example\",\"datePublished\":\"2015-02-02T11:15:59+00:00\",\"dateModified\":\"2018-06-19T08:16:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/\"},\"wordCount\":2055,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"keywords\":[\"audio\",\"player\"],\"articleSection\":[\"HTML5\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/\",\"name\":\"HTML5 Audio Player Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"datePublished\":\"2015-02-02T11:15:59+00:00\",\"dateModified\":\"2018-06-19T08:16:19+00:00\",\"description\":\"Interested to learn about HTML5 Audio Player? Check out our Example on how to use tag, its attributes & JavaScript to interact with the HTMLMediaElement.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"HTML5\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/html5\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"HTML5 Audio Player Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/ae15332f888fcdc376a8d4e03180e242\",\"name\":\"Remi Goyard\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/caa839a88ba9d485eec370ff8e020c314f10fb2e4ddedb3424a4bf92198259b2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/caa839a88ba9d485eec370ff8e020c314f10fb2e4ddedb3424a4bf92198259b2?s=96&d=mm&r=g\",\"caption\":\"Remi Goyard\"},\"description\":\"I'm a senior web architect. Passionated by new technologies, programming, devops tools, and agile methodologies. I really enjoy to coach, or teach, people who wants to learn programming, from beginners to skilled programmers. Involved in local developer communities, Java User Group, PHP User Group, or Javascript User Group, i like to share with others about experiences, news or business. Coding is FUN !\",\"sameAs\":[\"http:\/\/www.mimiz.fr\/\",\"http:\/\/fr.linkedin.com\/in\/remigoyard\/en\",\"https:\/\/x.com\/@mimiz33\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/remi-goyard\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"HTML5 Audio Player Example - Web Code Geeks - 2026","description":"Interested to learn about HTML5 Audio Player? Check out our Example on how to use tag, its attributes & JavaScript to interact with the HTMLMediaElement.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/","og_locale":"en_US","og_type":"article","og_title":"HTML5 Audio Player Example - Web Code Geeks - 2026","og_description":"Interested to learn about HTML5 Audio Player? Check out our Example on how to use tag, its attributes & JavaScript to interact with the HTMLMediaElement.","og_url":"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2015-02-02T11:15:59+00:00","article_modified_time":"2018-06-19T08:16:19+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","type":"image\/jpeg"}],"author":"Remi Goyard","twitter_card":"summary_large_image","twitter_creator":"@mimiz33","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Remi Goyard","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/"},"author":{"name":"Remi Goyard","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/ae15332f888fcdc376a8d4e03180e242"},"headline":"HTML5 Audio Player Example","datePublished":"2015-02-02T11:15:59+00:00","dateModified":"2018-06-19T08:16:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/"},"wordCount":2055,"commentCount":5,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","keywords":["audio","player"],"articleSection":["HTML5"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/","url":"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/","name":"HTML5 Audio Player Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","datePublished":"2015-02-02T11:15:59+00:00","dateModified":"2018-06-19T08:16:19+00:00","description":"Interested to learn about HTML5 Audio Player? Check out our Example on how to use tag, its attributes & JavaScript to interact with the HTMLMediaElement.","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-audio-player-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"HTML5","item":"https:\/\/www.webcodegeeks.com\/category\/html5\/"},{"@type":"ListItem","position":3,"name":"HTML5 Audio Player Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/ae15332f888fcdc376a8d4e03180e242","name":"Remi Goyard","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/caa839a88ba9d485eec370ff8e020c314f10fb2e4ddedb3424a4bf92198259b2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/caa839a88ba9d485eec370ff8e020c314f10fb2e4ddedb3424a4bf92198259b2?s=96&d=mm&r=g","caption":"Remi Goyard"},"description":"I'm a senior web architect. Passionated by new technologies, programming, devops tools, and agile methodologies. I really enjoy to coach, or teach, people who wants to learn programming, from beginners to skilled programmers. Involved in local developer communities, Java User Group, PHP User Group, or Javascript User Group, i like to share with others about experiences, news or business. Coding is FUN !","sameAs":["http:\/\/www.mimiz.fr\/","http:\/\/fr.linkedin.com\/in\/remigoyard\/en","https:\/\/x.com\/@mimiz33"],"url":"https:\/\/www.webcodegeeks.com\/author\/remi-goyard\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/2276","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/46"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=2276"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/2276\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/914"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=2276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=2276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=2276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}