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

[2.0] reset() has weird behaviour #974

Closed
LloydW93 opened this issue Jan 4, 2016 · 4 comments
Closed

[2.0] reset() has weird behaviour #974

LloydW93 opened this issue Jan 4, 2016 · 4 comments
Assignees
Milestone

Comments

@LloydW93
Copy link
Member

LloydW93 commented Jan 4, 2016

Consider the following:

var player = MediaPlayer().create();
player.initialize();
player.reset();

reset() calls attachSource(null), which calls resetAndPlay(), which will then error because there is no source.

I'm working around this currently by wrapping attachSource's resetAndPlay around an if (urlOrManifest) but not sure if that's the best way. I'm also unsure on why attaching a source is supposed to always start playback.

@dsparacio
Copy link
Contributor

Thanks for opening the issue . There will most likely be a lot of these little things so Ill start trying to set up unit test for small scenarios like this.

@dsparacio
Copy link
Contributor

Adding notes from duplicate CR and looking at fixing this now.

@dsparacio
Copy link
Contributor

Invoking the reset() function in MediaPlayer.js results in the play() function throwing the "Missing view or source." exception.

With recent changes and issues in dash.js, autoPlay must be enabled (see issue # 1027 #1027). This results in the following sequence of events if reset() is invoked.

reset() sets source and element to null via the following.

function reset() {
    //todo add all vars in reset that need to be in here
    attachSource(null);
    attachView(null);
    protectionController = null;
    protectionData = null;
}

attachSource() invokes resetAndPlay() which then invokes play() if autoPlay is enabled.

play() throws an exception if element or source is not set.

The only way to use reset() at this point is to bracket all invocations as follows

player.setAutoPlay(false);
player.reset();
player.setAutoPlay(true);

@dsparacio
Copy link
Contributor

Should be resolved with PR #1051

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

No branches or pull requests

2 participants