Skip to content

Add OnCompleted event to PlaySongInfo class#1111

Open
star620 wants to merge 2 commits intoUnrealMultiple:masterfrom
star620:patch-3
Open

Add OnCompleted event to PlaySongInfo class#1111
star620 wants to merge 2 commits intoUnrealMultiple:masterfrom
star620:patch-3

Conversation

@star620
Copy link
Member

@star620 star620 commented Mar 15, 2026

添加播放完成事件 OnCompleted

添加插件

  • 插件已加入解决方案 (Plugin.sln)
  • 插件项目已导入template.targets ()
  • 插件信息已添加至对应manifest.json
  • 插件的文件夹名字和插件的插件项目名字一样 (XXX/XXX.csproj)
  • 添加插件单独的README.md文件 (XXX/README.md)
  • 插件可以正常工作

更新插件/修复BUG

  • 插件已修改版本号
  • 更新插件README.md中的更新日志
  • 插件可以正常工作

其他

  • ❤️熙恩我喜欢你

Summary by Sourcery

PlaySongInfo 流程中添加一个完成事件,并将歌曲结束时的处理交由订阅者负责,而不是直接结束歌曲。

新功能:

  • PlaySongInfo 上引入 OnCompleted 事件,用于在播放结束时通知监听者。

优化:

  • 通过用基于事件的完成回调替换直接调用 EndSong,将 PlaySongInfoMusicPlayer 解耦。
Original summary in English

Summary by Sourcery

Add a completion event to the PlaySongInfo flow and delegate end-of-song handling to subscribers instead of directly ending the song.

New Features:

  • Introduce an OnCompleted event on PlaySongInfo that notifies listeners when playback has finished.

Enhancements:

  • Decouple PlaySongInfo from MusicPlayer by replacing the direct EndSong call with an event-based completion callback.

@star620 star620 requested a review from a team as a code owner March 15, 2026 09:57
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - 我在这里给出了一些整体性的反馈:

  • 将完成行为从直接调用 EndSong() 改为触发 OnCompleted,意味着如果没有任何处理程序订阅该事件,就不会发生任何事;请确认所有现有调用方现在都订阅了这个事件,或者考虑一个合理的默认行为,以保持之前的语义。
  • 目前的写法中,在 noteIndex == Notes.Count 之后,每一次后续的 Update 调用都会触发 OnCompleted;如果该事件预期是每首歌只触发一次,请添加保护(例如在调用前检查 PlayCompleted),或者在第一次触发后取消订阅处理程序。
给 AI Agent 的提示词
请根据本次代码审查中的评论进行修改:

## 总体评论
- 将完成行为从直接调用 `EndSong()` 改为触发 `OnCompleted`,意味着如果没有任何处理程序订阅该事件,就不会发生任何事;请确认所有现有调用方现在都订阅了这个事件,或者考虑一个合理的默认行为,以保持之前的语义。
- 目前的写法中,在 `noteIndex == Notes.Count` 之后,每一次后续的 `Update` 调用都会触发 `OnCompleted`;如果该事件预期是每首歌只触发一次,请添加保护(例如在调用前检查 `PlayCompleted`),或者在第一次触发后取消订阅处理程序。

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请对每条评论点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey - I've left some high level feedback:

  • Changing the completion behavior from directly calling EndSong() to firing OnCompleted means nothing will happen if no handler is attached; confirm all existing callers now subscribe to this event or consider a sensible default behavior to preserve the previous semantics.
  • As written, OnCompleted will be invoked on every subsequent Update call after noteIndex == Notes.Count; if this event is intended to fire only once per song, add a guard (e.g., check PlayCompleted before invoking) or unsubscribe handlers after the first invocation.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Changing the completion behavior from directly calling `EndSong()` to firing `OnCompleted` means nothing will happen if no handler is attached; confirm all existing callers now subscribe to this event or consider a sensible default behavior to preserve the previous semantics.
- As written, `OnCompleted` will be invoked on every subsequent `Update` call after `noteIndex == Notes.Count`; if this event is intended to fire only once per song, add a guard (e.g., check `PlayCompleted` before invoking) or unsubscribe handlers after the first invocation.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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