Gina T – Tokyo By Night [ Timing #1 Test ]

above is the whole audio, 5 min 43 sec

Gina T – Tokyo By Night (Remix)

Audio with Timing #1 Test – this example starts at the 15th sec, and ends at the 69th sec


“audio-embedding with timing is fun, sometimes it’s really needed, you just want 3-4 minutes, only the interesting part…”

…have you ever wanted to embed an audio but the file is 2 h long (it is hosted somewhere else, lets say on Soundcloud or elsewhere, they allow to embed it but the file is 2 hours long) and you just wanted 3-4 minutes of it, you need just a part of an interview, or just 1 song (somewhere in the middle), the rest of the file is useless (to you)?

…myself never done it, simply cause didn’t know how to do it – latey I’ve been experimenting to put together that kind of feature – you need this JS function, just modify [ s=15,e=69 ] in seconds, s=when it starts, e=ending of you audio… or view the source code of this post, and you can copy the needed part

(function()
  {const b=document.getElementById('btn-a'),
  a=document.getElementById('clip-a'),
  s=15,e=69;let p=0;b.addEventListener('click',()=>{p?(a.pause(),
  p=0,b.textContent='▶'):(a.currentTime=s,a.play(),
  p=1,b.textContent='⏸')});
  a.addEventListener('timeupdate',
  ()=>{a.currentTime>=e&&(a.pause()
  ,a.currentTime=s,p=0,b.textContent='▶')})})()