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

Unable to apply custom filters after calling player.reset() #3975

Closed
vodlogic opened this issue Jun 30, 2022 · 3 comments · Fixed by #3979
Closed

Unable to apply custom filters after calling player.reset() #3975

vodlogic opened this issue Jun 30, 2022 · 3 comments · Fixed by #3979
Assignees
Labels
Milestone

Comments

@vodlogic
Copy link
Contributor

When player.reset() is called and a custom initial track selection is applied , it does not seem possible to re-initialise the player and attach the source.

Uncaught TypeError: Cannot read properties of null (reading 'setCustomInitialTrackSelectionFunction')
    at Object.setCustomInitialTrackSelectionFunction (MediaPlayer.js:1584:31)
    at HTMLButtonElement.<anonymous> (reset-test.html:27:12)

This also affects the capabilities filter and license request filters functions being applied after player.reset() is called.

This seems to be because customParametersModel is set to null in the reset() function, but it is never then re-initialised since this is only called in the MediaPlayer setup() function

customParametersModel = CustomParametersModel(context).getInstance();

Below is a Quick demo showing setCustomInitialTrackSelectionFunction working when reset() is not applied beforehand but throws the error when reset is called beforehand.

<video height="200"></video>
<button id="withoutReset">Without Reset</button>
<button id="withReset">With Reset</button>
<script src="https://cdn.dashjs.org/v4.4.0/dash.all.debug.js"></script>
<script>
  const video = document.getElementsByTagName('video')[0];
  const url = 'https://dash.akamaized.net/dash264/TestCases/1a/sony/SNE_DASH_SD_CASE1A_REVISED.mpd';

  const player = window.dashjs.MediaPlayer().create()

  player.initialize(video, url);
  player.setCustomInitialTrackSelectionFunction(getTrackWithLowestBitrate);
  player.setMute(true);
  player.play();

  document.getElementById('withoutReset').addEventListener('click', () => {
    player.initialize();
    player.setCustomInitialTrackSelectionFunction(getTrackWithLowestBitrate);
    player.attachView(video);
    player.attachSource(url);
    player.play();
  });


  document.getElementById('withReset').addEventListener('click', () => {
    player.reset();
    player.initialize();
    player.setCustomInitialTrackSelectionFunction(getTrackWithLowestBitrate);
    player.attachView(video);
    player.attachSource(url);
    player.play();
  });

  var getTrackWithLowestBitrate = function (trackArr) {
    let min = Infinity;
    let result = [];
    let tmp;

    trackArr.forEach(function (track) {
      tmp = Math.min.apply(Math, track.bitrateList.map(function (obj) {
        return obj.bandwidth;
      }));

      if (tmp < min) {
        min = tmp;
        result = [track];
      }
    });

    return result;
  }


</script>
@dsilhavy
Copy link
Collaborator

dsilhavy commented Jul 4, 2022

Thanks for pointing this out. Can you confirm that #3979 fixes your issue?

@vodlogic
Copy link
Contributor Author

vodlogic commented Jul 4, 2022

I've re-run the sample test I put together above and the issue no longer occurs and a new stream is loaded

@dsilhavy
Copy link
Collaborator

dsilhavy commented Jul 4, 2022

@vodlogic thank you

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

Successfully merging a pull request may close this issue.

2 participants