package globals

type PlayerCmdStruct struct {
	PlayerId       PlayerType `json:"playerId"`
	Src            string     `json:"src,omitempty"`
	Uuid           string     `json:"srcUuid,omitempty"`
	SkTime         int        `json:"skTime,omitempty"`
	PlyMode        int        `json:"plyMode,omitempty"`
	PlyListType    int        `json:"plyListType,omitempty"`
	AdSrcType      AdSrcType  `json:"adSrcType,omitempty"`
	Tts            string     `json:"ttsText,omitempty"`
	VolRestoreTime int        `json:"volRestoreTime,omitempty"`
	VolBegin       uint8      `json:"volBegin,omitempty"`
	Gain           float32    `json:"gain"`
	Fifo           string     `json:"fifo,omitempty"`
	Channel        uint8      `json:"channel,omitempty"`
	Bytes          uint8      `json:"bytes,omitempty"`
	SampleRate     int        `json:"sampleRate,omitempty"`
	Duration       uint32     `json:"duration,omitempty"`
	BGUrl          string     `json:"backGroundUrl"`
}

type AdSrcType int

const (
	AdSrcType_FILE                  AdSrcType = 0x00
	AdSrcType_FILE_MIX              AdSrcType = 0x01
	AdSrcType_FILE_NOT_REPLAY_MUSIC AdSrcType = 0x02
	AdSrcType_TTS                   AdSrcType = 0x20
	AdSrcType_TTS_NOT_REPLAY_MUSIC  AdSrcType = 0X21
	AdSrcType_TTS_MIX               AdSrcType = 0x22
	AdSrcType_STOP_REPLAY_MUSIC     AdSrcType = 0X30
	AdSrcType_STOP_NOT_REPLAY_MUSIC AdSrcType = 0X31
)

type PlayerBroadStatus struct {
	Uuid     string         `json:"musicUuid"`
	Status   PlayerStatuses `json:"plySt"`
	CurPos   int            `json:"curPos"`
	Duration int            `json:"duration"`
}

type PlayerStatuses int

//music play status
const (
	MUSIC_ST_IDLE PlayerStatuses = iota
	MUSIC_ST_PREPARING
	MUSIC_ST_PREPARED
	MUSIC_ST_PLAYING
	MUSIC_ST_PAUSED
	MUSIC_ST_SEEKING
	MUSIC_ST_COMPLETED

	MUSIC_ST_FOR_NEXT
	MUSIC_ST_REV_LIST_OK
	MUSIC_ST_MAX
)
const (
	MUSIC_ST_PREPARING_TIMEOUT PlayerStatuses = 0x10 + iota
)

//se
const (
	SE_ST_IDLE PlayerStatuses = 0x20 + iota
	SE_ST_PREPARING
	SE_ST_PREPARED
	SE_ST_PLAYING
	SE_ST_COMPLETED
)

//tts
const (
	AUDIO_ST_IDLE PlayerStatuses = 0x30 + iota
	AUDIO_ST_START
	AUDIO_ST_FINISH
	AUDIO_ST_INTERRUPT
	AUDIO_ST_ERR
	AUDIO_ST_MAX
)

//ERROR
const (
	PLAYER_ERR_TINA_NOTIFY PlayerStatuses = 0x40 + iota
	PLAYER_ERR_TINA_INIT
	PLAYER_ERR_TINA_START
	PLAYER_ERR_TINA_RESET
	PLAYER_ERR_TINA_SETSOURCE
	PLAYER_ERR_TINA_PREPARE
	PLAYER_ERR_TINA_PAUSE
	PLAYER_ERR_TINA_STOP
	PLAYER_ERR_TINA_SEEKTO
	PLAYER_ERR_TINA_SETLOOP
	PLAYER_ERR_TINA_SETVOL
)
const (
	PLAYER_ERR_LIST_NULL     PlayerStatuses = 0x80 + iota
	PLAYER_ERR_DU_PLAYING                   // duplicate playing
	PLAYER_ERR_MODE_SEL                     // mode sel val err
	PLAYER_ERR_SOURCE_NULL                  // source is null
	PLAYER_ERR_REV_LIST_FAIL                // reverse music list fail
	PLAYER_ERR_INVALID_CMD                  // cmd invalid
	PLAYER_ERR_URL_INVALID                  // url invalid
)

const (
	PLAYER_ERR_SYS PlayerStatuses = 0xB0 + iota
)
const (
	PLAYER_ERR_TTS_INIT PlayerStatuses = 0xC0 + iota // xf tts init err
	PLAYER_ERR_TTS_TRAN                              // xf tts transform err
)

const (
	PLAYER_ERR_OTHERs PlayerStatuses = 0Xff
)
