22 lines
364 B
Go
22 lines
364 B
Go
package middleware
|
|
|
|
import (
|
|
"game-driver/internal/common"
|
|
"game-driver/internal/schema"
|
|
"game-driver/leaf"
|
|
"game-driver/pkg/audio"
|
|
)
|
|
|
|
func PlayBgm() leaf.HandlerFunc {
|
|
return func(c *leaf.Context) {
|
|
pm := leaf.Value[*schema.PlayModal](c, PayloadJSONKey)
|
|
|
|
bgm := common.LinkAudio(pm.BGM)
|
|
if bgm != nil {
|
|
go audio.PlayMP3(c, bgm)
|
|
}
|
|
|
|
c.Next()
|
|
}
|
|
}
|