Skip to content

Conversation

@revmischa
Copy link
Member

Adds a callback that's invoked before loading each preset from the playlist.

The callback receives the preset index, filename, and whether it's a hard cut.
Returning false from the callback prevents the preset from loading, allowing
applications to implement custom filtering or logging.

Fixes #946

Adds projectm_playlist_set_preset_load_event_callback() to allow applications
to handle preset loading themselves. This enables loading presets from:
- Archives (ZIP files)
- Network sources (HTTP)
- Custom storage solutions
- Asynchronous loading patterns

When the callback is set and returns true, the playlist library skips its
default filesystem-based loading. If the callback returns false or isn't set,
the default behavior is used.

Fixes #946
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a callback mechanism to the playlist library that allows applications to handle preset loading themselves instead of relying on the default filesystem loading. This enables loading presets from archives, network sources, or custom storage solutions as requested in issue #946.

Changes:

  • Added projectm_playlist_preset_load_event callback type that receives preset index, filename, hard_cut flag, and user data
  • Added projectm_playlist_set_preset_load_event_callback() API function to register the callback
  • Modified PlayPresetIndex() to invoke the callback before attempting filesystem loading
  • Callback return value controls whether default filesystem loading proceeds

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
src/playlist/api/projectM-4/playlist_callbacks.h Defines the new preset load callback type and registration function with comprehensive documentation
src/playlist/PlaylistCWrapper.hpp Adds callback storage members and setter method declaration
src/playlist/PlaylistCWrapper.cpp Implements callback setter and invocation logic in the preset loading flow

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

[FEATURE] Add callback to playlist library to handle preset loading in the application

1 participant