Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp URL shortcut does not work #680

Open
lil0r opened this issue Dec 20, 2022 · 6 comments
Open

Timestamp URL shortcut does not work #680

lil0r opened this issue Dec 20, 2022 · 6 comments
Assignees

Comments

@lil0r
Copy link

lil0r commented Dec 20, 2022

Describe the issue
Expected to be able to link to specific timestamp in video by adding URL parameter

To Reproduce
Steps to reproduce the issue:

  1. Go to any video and play
  2. Perform action, add "&t=60" to the URL
  3. Error, video stops, on hitting play video starts from the beginning

Expected behavior
video to jump to 60 seconds mark

Environment (please complete the following information):

  • OS: 20.04.05 LTS
  • Installation method: single server install
  • Browser Multiple: Edge Version 108.0.1462.54 (Official build) (64-bit)

Additional context
Add any other context about the problem here.

@mgogoulos
Copy link
Contributor

Thanks for opening, I also noticed this myself recently that this stopped working!

@Mikzas
Copy link

Mikzas commented Dec 21, 2022

I'm in the same situation.

@jp-rad
Copy link

jp-rad commented Jan 12, 2023

Change the loadedmetadata event to the playing event, and then get around it for now.
But no autoplay.

https://github.com/mediacms-io/mediacms/blob/main/frontend/src/static/js/components/video-player/VideoPlayer.jsx#L195

@jp-rad
Copy link

jp-rad commented Jan 13, 2023

Time setting is held off until a canplay event occurs, function currentTime.

v1.8 - 7.20.2 video.js (L.L.25427-25456)

    /**
     * Get or set the current time (in seconds)
     *
     * @param {number|string} [seconds]
     *        The time to seek to in seconds
     *
     * @return {number}
     *         - the current time in seconds when getting
     */
    ;

    _proto.currentTime = function currentTime(seconds) {
      if (typeof seconds !== 'undefined') {
        if (seconds < 0) {
          seconds = 0;
        }

        this.techCall_('setCurrentTime', seconds);
        return;
      } // cache last currentTime and return. default to 0 seconds
      //
      // Caching the currentTime is meant to prevent a massive amount of reads on the tech's
      // currentTime when scrubbing, but may not provide much performance benefit afterall.
      // Should be tested. Also something has to read the actual current time or the cache will
      // never get updated.


      this.cache_.currentTime = this.techGet_('currentTime') || 0;
      return this.cache_.currentTime;
    }

v1.9 - 7.20.2 video.js (L.L.27087-27124)

    /**
     * Get or set the current time (in seconds)
     *
     * @param {number|string} [seconds]
     *        The time to seek to in seconds
     *
     * @return {number}
     *         - the current time in seconds when getting
     */
    ;

    _proto.currentTime = function currentTime(seconds) {
      if (typeof seconds !== 'undefined') {
        if (seconds < 0) {
          seconds = 0;
        }

        if (!this.isReady_ || this.changingSrc_ || !this.tech_ || !this.tech_.isReady_) {
          this.cache_.initTime = seconds;
          this.off('canplay', this.boundApplyInitTime_);
          this.one('canplay', this.boundApplyInitTime_);
          return;
        }

        this.techCall_('setCurrentTime', seconds);
        this.cache_.initTime = 0;
        return;
      } // cache last currentTime and return. default to 0 seconds
      //
      // Caching the currentTime is meant to prevent a massive amount of reads on the tech's
      // currentTime when scrubbing, but may not provide much performance benefit afterall.
      // Should be tested. Also something has to read the actual current time or the cache will
      // never get updated.


      this.cache_.currentTime = this.techGet_('currentTime') || 0;
      return this.cache_.currentTime;
    }

video.js L.L.24845-24847

    _this.boundApplyInitTime_ = function (e) {
      return _this.applyInitTime_(e);
    };

video.js L.L.27132-27134

    _proto.applyInitTime_ = function applyInitTime_() {
      this.currentTime(this.cache_.initTime);
    }

@jp-rad
Copy link

jp-rad commented Jan 13, 2023

Change the loadedmetadata event to the canplaythrough event that occurs after the canplay event

https://github.com/mediacms-io/mediacms/blob/main/frontend/src/static/js/components/video-player/VideoPlayer.jsx#L195


    player.player.one('canplaythrough', () => {       
      const urlParams = new URLSearchParams(window.location.search);
      const paramT = Number(urlParams.get('t'));
      const timestamp = !isNaN(paramT) ? paramT : 0;
      player.player.currentTime(timestamp);
    });

jp-rad pushed a commit to jp-rad/mediacms-protected that referenced this issue Jan 13, 2023
…rs after the canplay event

v1.9 - 7.20.2 video.js (L.L.27087-27124)

Timestamp URL shortcut does not work
mediacms-io#680

TIMESTAMP_IN_TIMEBAR does not work
mediacms-io#694
@KyleMaas
Copy link
Contributor

KyleMaas commented Dec 3, 2023

See #928

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants