Skip to content

Instantly share code, notes, and snippets.

@neo22s
Last active August 20, 2023 14:55
Show Gist options
  • Select an option

  • Save neo22s/a01cc0aff86aebc81c165f9c96c4fdeb to your computer and use it in GitHub Desktop.

Select an option

Save neo22s/a01cc0aff86aebc81c165f9c96c4fdeb to your computer and use it in GitHub Desktop.

Revisions

  1. neo22s revised this gist Dec 19, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion video.html
    Original 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) {
    $("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)
  2. neo22s revised this gist Dec 19, 2021. 1 changed file with 26 additions and 19 deletions.
    45 changes: 26 additions & 19 deletions video.html
    Original 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>
    <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.
    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) {
    // Get the time from localStorage and play.
    this.currentTime = localStorage.getItem(btoa(this.src));
    this.play();
    });
    $("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>

    </html>
  3. neo22s created this gist Dec 19, 2021.
    38 changes: 38 additions & 0 deletions video.html
    Original 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>