mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2025-12-09 19:58:13 +08:00
rewrite
This commit is contained in:
@@ -1,54 +1,56 @@
|
||||
package events
|
||||
|
||||
import (
|
||||
"AynaLivePlayer/common/event"
|
||||
"AynaLivePlayer/core/model"
|
||||
)
|
||||
//const (
|
||||
// EventPlay event.EventId = "player.play"
|
||||
// EventPlayed event.EventId = "player.played"
|
||||
// EventPlaylistPreInsert event.EventId = "playlist.insert.pre"
|
||||
// EventPlaylistInsert event.EventId = "playlist.insert.after"
|
||||
// EventPlaylistUpdate event.EventId = "playlist.update"
|
||||
// EventLyricUpdate event.EventId = "lyric.update"
|
||||
// EventLyricReload event.EventId = "lyric.reload"
|
||||
//)
|
||||
|
||||
const (
|
||||
EventPlay event.EventId = "player.play"
|
||||
EventPlayed event.EventId = "player.played"
|
||||
EventPlaylistPreInsert event.EventId = "playlist.insert.pre"
|
||||
EventPlaylistInsert event.EventId = "playlist.insert.after"
|
||||
EventPlaylistUpdate event.EventId = "playlist.update"
|
||||
EventLyricUpdate event.EventId = "lyric.update"
|
||||
EventLyricReload event.EventId = "lyric.reload"
|
||||
)
|
||||
const ErrorUpdate = "update.error"
|
||||
|
||||
func EventPlayerPropertyUpdate(property model.PlayerProperty) event.EventId {
|
||||
return event.EventId("player.property.update." + string(property))
|
||||
type ErrorUpdateEvent struct {
|
||||
Error error
|
||||
}
|
||||
|
||||
type PlaylistInsertEvent struct {
|
||||
Playlist *model.Playlist
|
||||
Index int
|
||||
Media *model.Media
|
||||
}
|
||||
|
||||
type PlaylistUpdateEvent struct {
|
||||
Playlist *model.Playlist // Playlist is a copy of the playlist
|
||||
}
|
||||
|
||||
type PlayEvent struct {
|
||||
Media *model.Media
|
||||
}
|
||||
|
||||
type LyricUpdateEvent struct {
|
||||
Lyrics *model.Lyric
|
||||
Time float64
|
||||
Lyric *model.LyricContext
|
||||
}
|
||||
|
||||
type LyricReloadEvent struct {
|
||||
Lyrics *model.Lyric
|
||||
}
|
||||
|
||||
type PlayerPropertyUpdateEvent struct {
|
||||
Property model.PlayerProperty
|
||||
Value model.PlayerPropertyValue
|
||||
}
|
||||
|
||||
type LiveRoomStatusUpdateEvent struct {
|
||||
RoomTitle string
|
||||
Status bool
|
||||
}
|
||||
//
|
||||
//func EventPlayerPropertyUpdate(property model.PlayerProperty) event.EventId {
|
||||
// return event.EventId("player.property.update." + string(property))
|
||||
//}
|
||||
//
|
||||
//type PlaylistInsertEvent struct {
|
||||
// Playlist *model.Playlist
|
||||
// Index int
|
||||
// Media *model.Media
|
||||
//}
|
||||
//
|
||||
//type PlaylistUpdateEvent struct {
|
||||
// Playlist *model.Playlist // Playlist is a copy of the playlist
|
||||
//}
|
||||
//
|
||||
//type PlayEvent struct {
|
||||
// Media *model.Media
|
||||
//}
|
||||
//
|
||||
//type LyricUpdateEvent struct {
|
||||
// Lyrics *model.Lyric
|
||||
// Time float64
|
||||
// Lyric *model.LyricContext
|
||||
//}
|
||||
//
|
||||
//type LyricReloadEvent struct {
|
||||
// Lyrics *model.Lyric
|
||||
//}
|
||||
//
|
||||
//type PlayerPropertyUpdateEvent struct {
|
||||
// Property model.PlayerProperty
|
||||
// Value model.PlayerPropertyValue
|
||||
//}
|
||||
//
|
||||
//type LiveRoomStatusUpdateEvent struct {
|
||||
// RoomTitle string
|
||||
// Status bool
|
||||
//}
|
||||
|
||||
@@ -1,16 +1,73 @@
|
||||
package events
|
||||
|
||||
import (
|
||||
"AynaLivePlayer/common/event"
|
||||
"AynaLivePlayer/core/adapter"
|
||||
"AynaLivePlayer/core/model"
|
||||
liveroomsdk "github.com/AynaLivePlayer/liveroom-sdk"
|
||||
)
|
||||
|
||||
const (
|
||||
LiveRoomStatusChange event.EventId = "liveclient.status.change"
|
||||
LiveRoomMessageReceive event.EventId = "liveclient.message.receive"
|
||||
)
|
||||
//const (
|
||||
// LiveRoomStatusChange event.EventId = "liveclient.status.change"
|
||||
// LiveRoomMessageReceive event.EventId = "liveclient.message.receive"
|
||||
//)
|
||||
//
|
||||
//type StatusChangeEvent struct {
|
||||
// Connected bool
|
||||
// Client adapter.LiveClient
|
||||
//}
|
||||
|
||||
type StatusChangeEvent struct {
|
||||
Connected bool
|
||||
Client adapter.LiveClient
|
||||
const LiveRoomAddCmd = "cmd.liveroom.add"
|
||||
|
||||
type LiveRoomAddCmdEvent struct {
|
||||
Title string
|
||||
Provider string
|
||||
RoomKey string
|
||||
}
|
||||
|
||||
const LiveRoomProviderUpdate = "update.liveroom.provider"
|
||||
|
||||
type LiveRoomProviderUpdateEvent struct {
|
||||
Providers []model.LiveRoomProviderInfo
|
||||
}
|
||||
|
||||
const LiveRoomRemoveCmd = "cmd.liveroom.remove"
|
||||
|
||||
type LiveRoomRemoveCmdEvent struct {
|
||||
Identifier string
|
||||
}
|
||||
|
||||
const LiveRoomRoomsUpdate = "update.liveroom.rooms"
|
||||
|
||||
type LiveRoomRoomsUpdateEvent struct {
|
||||
Rooms []model.LiveRoom
|
||||
}
|
||||
|
||||
const LiveRoomStatusUpdate = "update.liveroom.status"
|
||||
|
||||
type LiveRoomStatusUpdateEvent struct {
|
||||
Room model.LiveRoom
|
||||
}
|
||||
|
||||
const LiveRoomConfigChangeCmd = "cmd.liveroom.config.change"
|
||||
|
||||
type LiveRoomConfigChangeCmdEvent struct {
|
||||
Identifier string
|
||||
Config model.LiveRoomConfig
|
||||
}
|
||||
|
||||
const LiveRoomOperationCmd = "cmd.liveroom.operation"
|
||||
|
||||
type LiveRoomOperationCmdEvent struct {
|
||||
Identifier string
|
||||
SetConnect bool // connect or disconnect
|
||||
}
|
||||
|
||||
const LiveRoomOperationFinish = "update.liveroom.operation"
|
||||
|
||||
type LiveRoomOperationFinishEvent struct {
|
||||
}
|
||||
|
||||
const LiveRoomMessageReceive = "update.liveroom.message"
|
||||
|
||||
type LiveRoomMessageReceiveEvent struct {
|
||||
Message *liveroomsdk.Message
|
||||
}
|
||||
|
||||
37
core/events/player_control.go
Normal file
37
core/events/player_control.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package events
|
||||
|
||||
import (
|
||||
"AynaLivePlayer/core/model"
|
||||
)
|
||||
|
||||
const PlayerVolumeChangeCmd = "cmd.player.op.change_volume"
|
||||
|
||||
type PlayerVolumeChangeCmdEvent struct {
|
||||
Volume float64 // Volume from 0-100
|
||||
}
|
||||
|
||||
const PlayerPlayCmd = "cmd.player.op.play"
|
||||
|
||||
type PlayerPlayCmdEvent struct {
|
||||
Media model.Media
|
||||
}
|
||||
|
||||
const PlayerSeekCmd = "cmd.player.op.seek"
|
||||
|
||||
type PlayerSeekCmdEvent struct {
|
||||
Position float64
|
||||
// Absolute is the seek mode.
|
||||
// if absolute = true : position is the time in second
|
||||
// if absolute = false: position is in percentage eg 0.1 0.2
|
||||
Absolute bool
|
||||
}
|
||||
|
||||
const PlayerToggleCmd = "cmd.player.op.toggle"
|
||||
|
||||
type PlayerToggleCmdEvent struct {
|
||||
}
|
||||
|
||||
const PlayerPlayNextCmd = "cmd.player.op.next"
|
||||
|
||||
type PlayerPlayNextCmdEvent struct {
|
||||
}
|
||||
23
core/events/player_lyric.go
Normal file
23
core/events/player_lyric.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package events
|
||||
|
||||
import "github.com/AynaLivePlayer/miaosic"
|
||||
|
||||
const PlayerLyricRequestCmd = "cmd.player.lyric.request"
|
||||
|
||||
type PlayerLyricRequestCmdEvent struct {
|
||||
}
|
||||
|
||||
const PlayerLyricReload = "update.player.lyric.reload"
|
||||
|
||||
type PlayerLyricReloadEvent struct {
|
||||
Lyrics miaosic.Lyrics
|
||||
}
|
||||
|
||||
const PlayerLyricPosUpdate = "update.player.lyric.pos"
|
||||
|
||||
type PlayerLyricPosUpdateEvent struct {
|
||||
Time float64
|
||||
CurrentIndex int // -1 means no lyric
|
||||
CurrentLine miaosic.LyricLine
|
||||
Total int // total lyric count
|
||||
}
|
||||
46
core/events/player_property.go
Normal file
46
core/events/player_property.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package events
|
||||
|
||||
import "AynaLivePlayer/core/model"
|
||||
|
||||
const PlayerPlayingUpdate = "update.player.playing"
|
||||
|
||||
type PlayerPlayingUpdateEvent struct {
|
||||
Media model.Media
|
||||
Removed bool // if no media is playing, removed is true
|
||||
}
|
||||
|
||||
const PlayerPropertyPauseUpdate = "update.player.property.pause"
|
||||
|
||||
type PlayerPropertyPauseUpdateEvent struct {
|
||||
Paused bool
|
||||
}
|
||||
|
||||
const PlayerPropertyPercentPosUpdate = "update.player.property.percent_pos"
|
||||
|
||||
type PlayerPropertyPercentPosUpdateEvent struct {
|
||||
PercentPos float64
|
||||
}
|
||||
|
||||
const PlayerPropertyIdleActiveUpdate = "update.player.property.idle_active"
|
||||
|
||||
type PlayerPropertyIdleActiveUpdateEvent struct {
|
||||
IsIdle bool
|
||||
}
|
||||
|
||||
const PlayerPropertyTimePosUpdate = "update.player.property.time_pos"
|
||||
|
||||
type PlayerPropertyTimePosUpdateEvent struct {
|
||||
TimePos float64 // Time in seconds
|
||||
}
|
||||
|
||||
const PlayerPropertyDurationUpdate = "update.player.property.duration"
|
||||
|
||||
type PlayerPropertyDurationUpdateEvent struct {
|
||||
Duration float64 // Duration in seconds
|
||||
}
|
||||
|
||||
const PlayerPropertyVolumeUpdate = "update.player.property.volume"
|
||||
|
||||
type PlayerPropertyVolumeUpdateEvent struct {
|
||||
Volume float64 // Volume from 0-100
|
||||
}
|
||||
7
core/events/player_videoplayer.go
Normal file
7
core/events/player_videoplayer.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package events
|
||||
|
||||
const PlayerVideoPlayerSetWindowHandleCmd = "cmd.player.videoplayer.set_window_handle"
|
||||
|
||||
type PlayerVideoPlayerSetWindowHandleCmdEvent struct {
|
||||
Handle uintptr
|
||||
}
|
||||
81
core/events/playlist.go
Normal file
81
core/events/playlist.go
Normal file
@@ -0,0 +1,81 @@
|
||||
package events
|
||||
|
||||
import (
|
||||
"AynaLivePlayer/core/model"
|
||||
"AynaLivePlayer/pkg/event"
|
||||
)
|
||||
|
||||
func PlaylistDetailUpdate(id model.PlaylistID) event.EventId {
|
||||
return event.EventId("update.playlist.detail." + id)
|
||||
}
|
||||
|
||||
type PlaylistDetailUpdateEvent struct {
|
||||
Medias []model.Media
|
||||
}
|
||||
|
||||
func PlaylistMoveCmd(id model.PlaylistID) event.EventId {
|
||||
return event.EventId("cmd.playlist.move." + id)
|
||||
}
|
||||
|
||||
type PlaylistMoveCmdEvent struct {
|
||||
From int
|
||||
To int
|
||||
}
|
||||
|
||||
func PlaylistDeleteCmd(id model.PlaylistID) event.EventId {
|
||||
return event.EventId("cmd.playlist.delete." + id)
|
||||
}
|
||||
|
||||
type PlaylistDeleteCmdEvent struct {
|
||||
Index int
|
||||
}
|
||||
|
||||
func PlaylistInsertCmd(id model.PlaylistID) event.EventId {
|
||||
return event.EventId("cmd.playlist.insert." + id)
|
||||
}
|
||||
|
||||
type PlaylistInsertCmdEvent struct {
|
||||
Position int // position to insert, -1 means last one
|
||||
Media model.Media
|
||||
}
|
||||
|
||||
func PlaylistInsertUpdate(id model.PlaylistID) event.EventId {
|
||||
return event.EventId("update.playlist.insert." + id)
|
||||
}
|
||||
|
||||
type PlaylistInsertUpdateEvent struct {
|
||||
Position int // position to insert, -1 means last one
|
||||
Media model.Media
|
||||
}
|
||||
|
||||
func PlaylistNextCmd(id model.PlaylistID) event.EventId {
|
||||
return event.EventId("cmd.playlist.next." + id)
|
||||
}
|
||||
|
||||
type PlaylistNextCmdEvent struct {
|
||||
Remove bool // remove the media after next
|
||||
}
|
||||
|
||||
func PlaylistNextUpdate(id model.PlaylistID) event.EventId {
|
||||
return event.EventId("update.playlist.next." + id)
|
||||
}
|
||||
|
||||
type PlaylistNextUpdateEvent struct {
|
||||
Media model.Media
|
||||
}
|
||||
|
||||
func PlaylistModeChangeCmd(id model.PlaylistID) event.EventId {
|
||||
return event.EventId("cmd.playlist.mode." + id)
|
||||
}
|
||||
|
||||
type PlaylistModeChangeCmdEvent struct {
|
||||
Mode model.PlaylistMode
|
||||
}
|
||||
|
||||
func PlaylistModeChangeUpdate(id model.PlaylistID) event.EventId {
|
||||
return event.EventId("update.playlist.mode." + id)
|
||||
}
|
||||
|
||||
type PlaylistModeChangeUpdateEvent struct {
|
||||
Mode model.PlaylistMode
|
||||
}
|
||||
24
core/events/search.go
Normal file
24
core/events/search.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package events
|
||||
|
||||
import (
|
||||
"AynaLivePlayer/core/model"
|
||||
)
|
||||
|
||||
const SearchCmd = "cmd.search"
|
||||
|
||||
type SearchCmdEvent struct {
|
||||
Keyword string
|
||||
Provider string
|
||||
}
|
||||
|
||||
const SearchResultUpdate = "update.search_result"
|
||||
|
||||
type SearchResultUpdateEvent struct {
|
||||
Medias []model.Media
|
||||
}
|
||||
|
||||
const SearchProviderUpdate = "update.search.provider.update"
|
||||
|
||||
type SearchProviderUpdateEvent struct {
|
||||
Providers []string
|
||||
}
|
||||
Reference in New Issue
Block a user