more work for preparing for casting

This commit is contained in:
Drew Weymouth
2025-03-29 15:15:13 -07:00
parent 4f731833c0
commit 8bd1c8183d
6 changed files with 261 additions and 151 deletions
+23 -23
View File
@@ -84,66 +84,66 @@ func (r ReplayGainMode) String() string {
}
type BasePlayerCallbackImpl struct {
onPaused []func()
onStopped []func()
onPlaying []func()
onSeek []func()
onTrackChange []func()
onPaused func()
onStopped func()
onPlaying func()
onSeek func()
onTrackChange func()
}
// Registers a callback which is invoked when the player transitions to the Paused state.
// Sets a callback which is invoked when the player transitions to the Paused state.
func (p *BasePlayerCallbackImpl) OnPaused(cb func()) {
p.onPaused = append(p.onPaused, cb)
p.onPaused = cb
}
// Registers a callback which is invoked when the player transitions to the Stopped state.
// Sets a callback which is invoked when the player transitions to the Stopped state.
func (p *BasePlayerCallbackImpl) OnStopped(cb func()) {
p.onStopped = append(p.onStopped, cb)
p.onStopped = cb
}
// Registers a callback which is invoked when the player transitions to the Playing state.
// Sets a callback which is invoked when the player transitions to the Playing state.
func (p *BasePlayerCallbackImpl) OnPlaying(cb func()) {
p.onPlaying = append(p.onPlaying, cb)
p.onPlaying = cb
}
// Registers a callback which is invoked whenever a seek event occurs.
func (p *BasePlayerCallbackImpl) OnSeek(cb func()) {
p.onSeek = append(p.onSeek, cb)
p.onSeek = cb
}
// Registers a callback which is invoked when the currently playing track changes,
// or when playback begins at any time from the Stopped state.
// Callback is invoked with the index of the currently playing track (zero-based).
func (p *BasePlayerCallbackImpl) OnTrackChange(cb func()) {
p.onTrackChange = append(p.onTrackChange, cb)
p.onTrackChange = cb
}
func (p *BasePlayerCallbackImpl) InvokeOnPaused() {
for _, cb := range p.onPaused {
cb()
if p.onPaused != nil {
p.onPaused()
}
}
func (p *BasePlayerCallbackImpl) InvokeOnPlaying() {
for _, cb := range p.onPlaying {
cb()
if p.onPlaying != nil {
p.onPlaying()
}
}
func (p *BasePlayerCallbackImpl) InvokeOnStopped() {
for _, cb := range p.onStopped {
cb()
if p.onStopped != nil {
p.onStopped()
}
}
func (p *BasePlayerCallbackImpl) InvokeOnSeek() {
for _, cb := range p.onSeek {
cb()
if p.onSeek != nil {
p.onSeek()
}
}
func (p *BasePlayerCallbackImpl) InvokeOnTrackChange() {
for _, cb := range p.onTrackChange {
cb()
if p.onTrackChange != nil {
p.onTrackChange()
}
}