Last active
August 20, 2023 14:55
-
-
Save neo22s/a01cc0aff86aebc81c165f9c96c4fdeb to your computer and use it in GitHub Desktop.
Revisions
-
neo22s revised this gist
Dec 19, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ localStorage.setItem(btoa(this.src), this.currentTime); }); $("video").on("play", function(event) { $storedtime = localStorage.getItem(btoa(this.src)); // Get the time from localStorage and play if not at the end. if ($storedtime < this.duration) -
neo22s revised this gist
Dec 19, 2021 . 1 changed file with 26 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,37 +2,44 @@ <html> <head> <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script> </head> <body> <video controls="" src="https://s3.amazonaws.com/akamai.netstorage/HD_downloads/Orion_SM.mp4?" data-origwidth="0" data-origheight="0" ></video> <video controls="" src="https://s3.amazonaws.com/akamai.netstorage/HD_downloads/rbsp_launch_480p.mp4?" data-origwidth="0" data-origheight="0" ></video> <script> jQuery(document).ready(function( $ ) { $("video").on("pause", function(event) { // Save into local storage,if you change the browser will not work localStorage.setItem(btoa(this.src), this.currentTime); }); $("video").on("play", function(event) { $storedtime = localStorage.getItem(btoa(this.src)); // Get the time from localStorage and play if not at the end. if ($storedtime < this.duration) this.currentTime = $storedtime; this.play(); }); //if you close the window and video playing store the current time $(window).on("unload", function(e) { $("video").each(function(index, value) { if ( ! this.paused ) { localStorage.setItem(btoa(this.src), this.currentTime); } }); }); }); </script> </body> </html> -
neo22s created this gist
Dec 19, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ <!DOCTYPE html> <html> <head> <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script> </head> <body> <video controls="" src="https://s3.amazonaws.com/akamai.netstorage/HD_downloads/Orion_SM.mp4" data-origwidth="0" data-origheight="0" ></video> <video controls="" src="https://s3.amazonaws.com/akamai.netstorage/HD_downloads/rbsp_launch_480p.mp4" data-origwidth="0" data-origheight="0" ></video> <script> $("video").on("pause", function(event) { //alert(btoa(this.src)); //alert(this.src); // Save into local storage, this might even be better than saving to a server. localStorage.setItem(btoa(this.src), this.currentTime); }); $("video").on("play", function(event) { // Get the time from localStorage and play. this.currentTime = localStorage.getItem(btoa(this.src)); this.play(); }); </script> </body> </html>