![]() |
|
HTML5 audio player - play where it left off? - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Webmasters (https://hackforums.net/forumdisplay.php?fid=141) +---- Forum: Website Construction (https://hackforums.net/forumdisplay.php?fid=50) +---- Thread: HTML5 audio player - play where it left off? (/showthread.php?tid=4886424) |
HTML5 audio player - play where it left off? - Ðr1ps - Jun 29, 2015 Is it possible to hack the html5 audio player somehow to continue playing from the part it left off? So when the user returns to the website, it won't start the song all over again from the beginning. * - Ayzhin - Jun 29, 2015 This is a very basic way, could be made a lot better I'm sure, but optimisation is your job. :) You will need localstorage, or cookies if you wanted, there's plenty of plugins for that. This works by setting the current time to local storage every 3 seconds. Then on page load it checks to see if the record exists, and if it is, then it loads the time and plays the audio element. http://pastebin.com/k9kZbran - Courtesy of Tasemu * - Tasemu - Jun 29, 2015 For some reason I couldnt post the code. Had Ayz do it for me. Anyway let me know if you have issues. * - Ðr1ps - Jun 30, 2015 It doesn't seem to be working for me, however this saving to localstorage method looks pretty interesting * - Tasemu - Jun 30, 2015 It's not copy/paste code. You need to find yourself a localstorage plugin for JS and use that to store and retrieve the values. |