{"id":8245,"date":"2020-06-06T11:37:24","date_gmt":"2020-06-06T18:37:24","guid":{"rendered":"https:\/\/www.waveplayer.info\/?p=8245"},"modified":"2020-06-23T00:16:06","modified_gmt":"2020-06-23T07:16:06","slug":"test-time-markers","status":"publish","type":"post","link":"https:\/\/www.waveplayer.info\/docs\/test-time-markers\/","title":{"rendered":"Interacting with the player: Time Markers"},"content":{"rendered":"\n<p>When using WavePlayer for your podcasts, it can be useful to reference a specific part of the audio track in the text, allowing your visitors to jump directly to that part. This can be easily achieved by adding simple anchors to any part of your page. The structure of the anchor can be as follows:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;a href=\"#\" onclick=\"WavePlayer.setCurrentTime(120)\">your anchor text goes here&lt;\/a><\/pre>\n\n\n\n<p>where the value provided to the <code>setCurrentTime<\/code> method is the time, expressed in seconds, you want your visitors to jump to. The previous anchor will allow users to jump to 2:00 into your track (2 minutes = 120 seconds). Please note that the <code>href<\/code> attribute of the anchor must be set to <code>#<\/code>: this allows the browser to execute the <code>onclick<\/code> script. If you left the <code>href<\/code> attribute empty, the page would reload and the <code>onclick<\/code> script would never execute.<\/p>\n\n\n<div class=\"waveplayer-container\"><div id=\"waveplayer-a30c92a25e3f456849d2cf5cb945d6fa-68c006a3bdc27\" class=\"waveplayer loading wvpl-skin-w3-standard wvpl-palette-800e3a14c86733ad9ccc96fd80850d88 wvpl-style-light wvpl-size-md wvpl-shape-circle wvpl-full-width-playlist \" data-limit=\"0\" data-mode=\"normal\" data-config_id=\"a30c92a25e3f456849d2cf5cb945d6fa\" data-instance_id=\"a30c92a25e3f456849d2cf5cb945d6fa-68b8d1f50ec79\">\n\t<div class=\"wvpl-cover\">\n\t\t<div class=\"wvpl-poster\"><\/div>\n\t<\/div>\n\t<div class=\"wvpl-wave\">\n\t\t<div class=\"wvpl-overlay\">\n\t\t\t<svg>\n\t\t\t\t<use xlink:href=\"#waveform-animation\" \/>\n\t\t\t<\/svg>\n\t\t\t<div class=\"percentage\"><\/div>\n\t\t\t<div class=\"wvpl-loading\">\n\t\t\t\t<div class=\"wvpl-loading-progress\"><\/div>\n\t\t\t<\/div>\n\t\t\t<div class=\"message\"><\/div>\n\t\t<\/div>\n\t\t<div class=\"wvpl-position\"><\/div>\n\t\t<div class=\"wvpl-waveform\"><\/div>\n\t\t<div class=\"wvpl-duration\"><\/div>\n\t<\/div>\n\t<div class=\"wvpl-interface\">\n\t\t<div class=\"wvpl-controls\">\n\t\t\t<div class=\"wvpl-icon wvpl-prev wvpl-disabled\"><\/div>\n\t\t\t<div class=\"wvpl-icon wvpl-play\"><\/div>\n\t\t\t<div class=\"wvpl-icon wvpl-next wvpl-disabled\"><\/div>\n\t\t<\/div>\n\t\t<div class=\"wvpl-volume-slider\">\n\t\t\t<div class=\"rail\">\n\t\t\t\t<div class=\"value\"><\/div>\n\t\t\t<\/div>\n\t\t\t<div class=\"handle\"><\/div>\n\t\t\t<div class=\"touchable\"><\/div>\n\t\t<\/div>\n\t\t<div class=\"wvpl-infobar\">\n\t\t\t<div class=\"wvpl-playing-info\"><div class=\"wvpl-infoblock\"><\/div><\/div>\n\t\t<\/div>\n\t<\/div>\n\t<div class=\"wvpl-playlist\">\n\t\t<div class=\"wvpl-playlist-wrapper\"><\/div>\n\t<\/div>\n<\/div>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th width=\"20%\">Marker<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><strong><a href=\"\" onclick=\"event.preventDefault();WavePlayer.setCurrentTime(60)\">1:00<\/a><\/strong><\/td><td>You can use markers to jump to any part of the track that is currently playing back<\/td><\/tr><tr><td><strong><a href=\"#\" onclick=\"event.preventDefault();WavePlayer.setCurrentTime(95)\"><i class=\"fas fa-share\"><\/i><\/a><\/strong><\/td><td>This is a marker behind an icon.<\/td><\/tr><tr><td><strong><a href=\"#\" onclick=\"WavePlayer.setCurrentTime(167)\">2:47<\/a><\/strong><\/td><td>A marker is nothing but an anchor with the <code>href<\/code> attribute set to <code>#<\/code> and the <code>onclick<\/code> attribute set to <code>WavePlayer.setCurrentTime( 167 )<\/code> where <code>167<\/code> is the number of seconds from the beginning of the track.<\/td><\/tr><tr><td><strong><a href=\"#\" onclick=\"WavePlayer.setCurrentTime(373)\">jump here<\/a><\/strong><\/td><td>The text of the anchor can be anything: a time reference, a title, a single word in the text, a whole part of the paragraph, an icon or an image. It just depends on what you put inside the anchor tags.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n        <div class='boxed-message tip'>\n            When using the <code>setCurrentTime<\/code> method, you can specify decimals up to any desired precision. For example, by specifying 65.768, the player will jump to 1 minute, 5 seconds and 768 milliseconds into your audio file.\n        <\/div>\n    \n\n\n\n<h3 class=\"has-text-align-center wp-block-heading\">Preventing the browser from jumping to the top of the page<\/h3>\n\n\n\n<p>When you add the <code>#<\/code> symbol to the <code>href<\/code> attribute of an anchor element, the browser expects the subsequent text to be the ID of an element on the page, so that it can jump to it. When you set the <code>href<\/code> to just the <code>#<\/code> character \u2013 as recommended here to add time markers to your pages \u2013 the browser jumps to the top of the page, in absence of any other indication of a section where it should jump to. This could be an undesirable effect when you are using the anchors as Time Markers. In order to prevent this behavior, you can add a call to <code>event.preventDefault()<\/code> to the onclick attribute, as follows:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;a href=\"#\" onclick=\"event.PreventDefault(); WavePlayer.setCurrentTime(132);\">&lt;\/a><\/pre>\n\n\n\n<p>The difference between the default behavior and the one when <code>event.preventDefault()<\/code> is used can be observed by clicking the first two markers and the last two markers in the previous table.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When using WavePlayer for your podcasts, it can be useful to reference a specific part of the audio track in the text, allowing your visitors to jump directly to that part. This can be easily achieved by adding simple anchors to any part of your page. The structure of the anchor can be as follows: [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[47],"tags":[],"class_list":["post-8245","post","type-post","status-publish","format-standard","hentry","category-docs"],"_links":{"self":[{"href":"https:\/\/www.waveplayer.info\/wp-json\/wp\/v2\/posts\/8245","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.waveplayer.info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.waveplayer.info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.waveplayer.info\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.waveplayer.info\/wp-json\/wp\/v2\/comments?post=8245"}],"version-history":[{"count":0,"href":"https:\/\/www.waveplayer.info\/wp-json\/wp\/v2\/posts\/8245\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.waveplayer.info\/wp-json\/wp\/v2\/media?parent=8245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.waveplayer.info\/wp-json\/wp\/v2\/categories?post=8245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.waveplayer.info\/wp-json\/wp\/v2\/tags?post=8245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}