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

Enable multiple calls to _setup() method #90

Merged
merged 3 commits into from
Jan 21, 2021

Conversation

joaopaulovieira
Copy link
Member

@joaopaulovieira joaopaulovieira commented Jan 6, 2021

Summary

Currently, if the _setup() is called after the playback is ready/started to play, one error (code 3015) occurs when the setInterval loop on _startTimeUpdateTimer method tries to update the current time of the old shaka-player instance in the time interval between the _setup method is called and one new shaka-player instance is created.

This PR guarantees the delete of the old shaka-player instance (if exists) before the creation of the new one.

Changes

  • Extracted code to initial config into one new method (_setInitialConfig);
  • Extracted code to load source into one new method (_loadSource);
  • Aggregate steps to avoid code duplication (runAllSteps);
  • Chained runAllSteps call with the this._player.destroy promise if this_player exists;

How to test

  • Play any media;
  • Config one new media;
    • E.g.: player.core.activePlayback._options.src = 'your-new-media.mpd'.
  • Call _setup method;
    • The configured media should be loaded.

A picture is worth a thousand words

Before

Screen.Recording.2021-01-06.at.10.02.12.mov

After

Screen.Recording.2021-01-06.at.10.01.11.mov

One error (code 3015) occurs when the setInterval loop on _startTimeUpdateTimer method tries to update the current time of the old shaka-player instance in the time interval between the _setup method is called and one new shaka-player instance is created.

This code guarantees the delete of the old shaka-player instance before the creation of one new one into the _setup method.
@joaopaulovieira joaopaulovieira merged commit df9b346 into master Jan 21, 2021
@joaopaulovieira joaopaulovieira deleted the enable-setup-call-multiple-times branch January 21, 2021 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants