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

Setting currentTime before loading video breaks shaka-player on firefox (NS_ERROR_DOM_MEDIA_METADATA_ERR) #4363

Closed
happylinks opened this issue Jul 19, 2022 · 4 comments
Labels
browser: Firefox Issues affecting Firefox or Gecko derivatives status: archived Archived and locked; will not be updated type: external An issue with an external dependency; not our issue; sometimes kept open for tracking

Comments

@happylinks
Copy link

happylinks commented Jul 19, 2022

Have you read the FAQ and checked for duplicate open issues?
Yes

What version of Shaka Player are you using?
3.3.0 works, >=3.3.1 fails

Can you reproduce the issue with our latest release version?
Yes

Can you reproduce the issue with the latest code from main?
Yes

Are you using the demo app or your own custom app?
3.3.1: https://5d6qk1.csb.app/
3.3.0: https://qs4ony.csb.app/

If custom app, can you reproduce the issue using our demo app?
Probably not, since it's not setting currentTime.

What browser and OS are you using?
Firefox 102.0.1

For embedded devices (smart TVs, etc.), what model and firmware version are you using?
n/a

What are the manifest and license server URIs?

Tested it with https://dev-raw.tella.tv/cl5qwe6ln0006txeqgs1g3ilp/output.mpd

What configuration are you using? What is the output of player.getConfiguration()?

See codesandbox

What did you do?

Setting video.currentTime before attaching and loading shaka player breaks on version >=3.3.1 and worked before that. NS_ERROR_DOM_MEDIA_METADATA_ERR is thrown in firefox.

What did you expect to happen?
It should allow me to set the initial currentTime for the video element and load the manifest appropriately. I don't want to have a flash of 0 and then seek, I want it to load at a specific time.

What actually happened?

Somehow firefox can't load the media when currentTime has been set before loading the video.

I checked the changelog and think that maybe it's this PR that might have broken this behavior:
#3795

@happylinks happylinks added the type: bug Something isn't working correctly label Jul 19, 2022
@github-actions github-actions bot added this to the v4.2 milestone Jul 19, 2022
@joeyparrish
Copy link
Member

Setting video.currentTime before attaching and loading shaka player breaks on version >=3.3.1 and worked before that. NS_ERROR_DOM_MEDIA_METADATA_ERR is thrown in firefox.

Can you be more specific? Are you setting currentTime on a specific event or at a specific time in the lifecycle of the player?
Can you provide sample code for this?

Also, have you tried the startTime parameter of player.load()? It is meant to handle this for you.

@joeyparrish joeyparrish added the status: waiting on response Waiting on a response from the reporter(s) of the issue label Jul 19, 2022
@happylinks
Copy link
Author

Ah sorry for not providing the code, you can see the sandbox source when clicking "Open Sandbox" in the bottom right.
But I'll also provide the code here:

initPlayer() {
    let video = this.refs.video;

    this.player = new shaka.Player();

    video.currentTime = 1;

    this.player.detach().then(() => {
      this.player.attach(video).then(() => {
        this.player
          .load("https://dev-raw.tella.tv/cl5qwe6ln0006txeqgs1g3ilp/output.mpd")
          .then(function () {
            // This runs if the asynchronous load is successful.
            console.log("The video has now been loaded! ");
          })
          .catch(this.onError);
      });
    });

    // Listen for error events.
    this.player.addEventListener("error", this.onErrorEvent);
  }

Notice the video.currentTime = 1;

Also, have you tried the startTime parameter of player.load()? It is meant to handle this for you.

Yes! In our actual app we also use this, and load the video at the specific start time, but we also allow people to seek before the video is loaded.
Summarizing our app (tella.tv); we have a video editor that has a timeline and a playbar, the timeline is not 1:1 to 1 video, it's multiple video elements all playing at a certain time.
image
These video elements are loaded just before they need to play, at their start time. However, the user can seek through the whole video whenever they want, they just have to wait for the actual video element to load before they see the result.

So in this minimal reproduction case, I just put video.currentTime = 1; as the trigger for the error, but in our actual app, it will be the user seeking, us setting the currentTime to something different than what normally would be the start time of that video because of that, and firefox failing because of that.

The alternative would be that we make a seek() function that first checks if the player is already loaded or not, if so uses currentTime, if not uses player.load() with startTime.

That will probably work, I was just thinking this behavior is probably a bug since it only happens on Firefox and not in other browsers.

@github-actions github-actions bot removed the status: waiting on response Waiting on a response from the reporter(s) of the issue label Jul 20, 2022
@joeyparrish joeyparrish added type: external An issue with an external dependency; not our issue; sometimes kept open for tracking browser: Firefox Issues affecting Firefox or Gecko derivatives and removed type: bug Something isn't working correctly labels Jul 22, 2022
@joeyparrish
Copy link
Member

That will probably work, I was just thinking this behavior is probably a bug since it only happens on Firefox and not in other browsers.

I agree that it's probably a bug, but it sounds like a bug in Firefox to me, and one that startTime in load() is meant to work around. You should probably plan to use that parameter, as that is already our workaround.

In your case, the user action occurs outside the player, and the error is generated by the platform. So I don't think we can do anything else about it other than recommend you implement the user action through our existing workaround.

Does this help?

@joeyparrish joeyparrish removed this from the v4.2 milestone Jul 22, 2022
@happylinks
Copy link
Author

Alright I wrote a wrapper that checks if the video is already loaded or not, if it is, it just seeks the video element, if not, it sets the initialStartTime to be used when it starts loading using player.load().

Works fine for now, thanks!

@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Sep 23, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
browser: Firefox Issues affecting Firefox or Gecko derivatives status: archived Archived and locked; will not be updated type: external An issue with an external dependency; not our issue; sometimes kept open for tracking
Projects
None yet
Development

No branches or pull requests

2 participants