mirror of
https://github.com/Monibuca/plugin-ps.git
synced 2025-12-24 12:37:59 +08:00
25 lines
522 B
Go
25 lines
522 B
Go
package ps
|
|
|
|
import (
|
|
"github.com/gobwas/ws/wsutil"
|
|
. "m7s.live/engine/v4"
|
|
"m7s.live/engine/v4/common"
|
|
"m7s.live/engine/v4/util"
|
|
)
|
|
|
|
type PSSubscriber struct {
|
|
Subscriber
|
|
}
|
|
|
|
func (ps *PSSubscriber) OnEvent(event any) {
|
|
switch v := event.(type) {
|
|
case *PSTrack:
|
|
wsutil.WriteServerBinary(ps, util.ConcatBuffers(v.GetPSM()))
|
|
go v.Play(ps.IO, func(data *common.DataFrame[*util.ListItem[util.Buffer]]) error {
|
|
return wsutil.WriteServerBinary(ps, data.Value.Value)
|
|
})
|
|
default:
|
|
ps.Subscriber.OnEvent(event)
|
|
}
|
|
}
|