Skip to content

Fix Phaser audio callback cleanup - #41

Open
FranciscoMaxwell wants to merge 1 commit into
google:mainfrom
FranciscoMaxwell:fix-phaser-audio-callback-unset
Open

FranciscoMaxwell wants to merge 1 commit into
google:mainfrom
FranciscoMaxwell:fix-phaser-audio-callback-unset

Conversation

@FranciscoMaxwell

Copy link
Copy Markdown

Summary

  • fix unsetAudioChangeCallback() so it checks the _unsetAudioCallback property that setAudioChangeCallback() assigns
  • allow the Phaser helper to call the SDK unsubscribe function and clear the stored callback

Testing

  • node --input-type=module -e "import { YouTubePlayables } from './phaser/src/YouTubePlayables.js'; let unsetCalled = 0; YouTubePlayables._ytgameRef = { system: { onAudioEnabledChange: () => () => { unsetCalled += 1; } } }; YouTubePlayables.inPlayablesEnv = true; YouTubePlayables.setAudioChangeCallback(() => {}); YouTubePlayables.unsetAudioChangeCallback(); if (unsetCalled !== 1 || YouTubePlayables._unsetAudioCallback !== undefined) { throw new Error('unsetAudioChangeCallback failed'); } console.log('unsetAudioChangeCallback ok');"

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

Successfully merging this pull request may close these issues.

1 participant