merge r16 code 20180926

This commit is contained in:
lupeng 2018-09-26 10:18:07 +08:00
parent e2f6426c75
commit 9c43c03b1d
54 changed files with 1421 additions and 388 deletions

View File

@ -3,27 +3,29 @@ package globals
type APPInitStatus int type APPInitStatus int
const ( const (
APPInitStatus_UNKNOW APPInitStatus = -1 APPInitStatus_UNKNOW APPInitStatus = -1
APPInitStatus_SUCCESS APPInitStatus = 0 APPInitStatus_SUCCESS APPInitStatus = 0
APPInitStatus_SYSTEM_ERROR APPInitStatus = 0xf001 APPInitStatus_SYSTEM_ERROR APPInitStatus = 0xf001
APPInitStatus_FMT_NOTMATCH APPInitStatus = 0xf002 APPInitStatus_FMT_NOTMATCH APPInitStatus = 0xf002
APPInitStatus_JSON_ERROR APPInitStatus = 0xf003 APPInitStatus_JSON_ERROR APPInitStatus = 0xf003
APPInitStatus_ARG_ERROR APPInitStatus = 0xf004 APPInitStatus_ARG_ERROR APPInitStatus = 0xf004
APPInitStatus_SSID_NOTFOUND APPInitStatus = 0xf005 APPInitStatus_SSID_NOTFOUND APPInitStatus = 0xf005
APPInitStatus_PASSWD_ERROR APPInitStatus = 0xf006 APPInitStatus_PASSWD_ERROR APPInitStatus = 0xf006
APPInitStatus_WIFI_BUSY APPInitStatus = 0xf007 APPInitStatus_WIFI_BUSY APPInitStatus = 0xf007
APPInitStatus_CONNECT_TIMEOUT APPInitStatus = 0xf008 APPInitStatus_CONNECT_TIMEOUT APPInitStatus = 0xf008
APPInitStatus_WIFI_NOT_RESPONSE APPInitStatus = 0xf009 APPInitStatus_WIFI_NOT_RESPONSE APPInitStatus = 0xf009
APPInitStatus_ENCRYPT_NOT_SUPPORT APPInitStatus = 0xf00a APPInitStatus_ENCRYPT_NOT_SUPPORT APPInitStatus = 0xf00a
APPInitStatus_OTHER_CONNECT_ERROR APPInitStatus = 0xf00b APPInitStatus_OTHER_CONNECT_ERROR APPInitStatus = 0xf00b
APPInitStatus_PARING_NOT_RESPONSE APPInitStatus = 0xf00c APPInitStatus_PARING_NOT_RESPONSE APPInitStatus = 0xf00c
APPInitStatus_REQUEST_SERVER_ERROR APPInitStatus = 0xf00d APPInitStatus_REQUEST_SERVER_ERROR APPInitStatus = 0xf00d
APPInitStatus_NOT_IN_WIFIPARING APPInitStatus = 0xf00e APPInitStatus_NOT_IN_WIFIPARING APPInitStatus = 0xf00e
APPInitStatus_BINDNUM_BEYOND_MAX APPInitStatus = 0xf00f APPInitStatus_BINDNUM_BEYOND_MAX APPInitStatus = 0xf00f
APPInitStatus_YUNXIN_FAIL APPInitStatus = 0xf010 APPInitStatus_YUNXIN_FAIL APPInitStatus = 0xf010
APPInitStatus_ACCOUNT_NOT_EXIST APPInitStatus = 0xf011 APPInitStatus_ACCOUNT_NOT_EXIST APPInitStatus = 0xf011
APPInitStatus_SERVER_ARG_ERROR APPInitStatus = 0xf012 APPInitStatus_SERVER_ARG_ERROR APPInitStatus = 0xf012
APPInitStatus_SERVER_SYSTEM_ERROR APPInitStatus = 0xf013 APPInitStatus_SERVER_SYSTEM_ERROR APPInitStatus = 0xf013
APPInitStatus_SERVER_ACCOUNT_BOUNDED APPInitStatus = 0xf014
APPInitStatus_SERVER_DEVICE_BOUNDED APPInitStatus = 0xf015
APPInitStatus_BLE_DISCONNECT APPInitStatus = 0xffff APPInitStatus_BLE_DISCONNECT APPInitStatus = 0xffff
) )

View File

@ -50,6 +50,18 @@ var (
CurMcuVersion string CurMcuVersion string
SilentBoot = false SilentBoot = false
WifiSwitch = WifiSwitch_On
FirstCalTime = time.Now()
)
type WifiSwitch_Status int8
const (
WifiSwitch_On WifiSwitch_Status = iota
WifiSwitch_Oning
WifiSwitch_Off
WifiSwitch_Offing
) )
type WhoCLoseMic uint8 type WhoCLoseMic uint8

View File

@ -19,7 +19,7 @@ var (
Tts_ERR_NODE_NULL = errors.New("节点信息为空") Tts_ERR_NODE_NULL = errors.New("节点信息为空")
Server_ERR_RET = errors.New("网络有点抖动,暂时没法为你继续播放啦") //请求音乐失败,服务器下发数据异常 Server_ERR_RET = errors.New("暂时没办法为你继续播放了,待会儿再试试吧") //请求音乐失败,服务器下发数据异常
No_Permission_Err = errors.New("付费歌曲或者下架歌曲") No_Permission_Err = errors.New("付费歌曲或者下架歌曲")
Repeat_ERR_NULL = errors.New("没有可执行任务") Repeat_ERR_NULL = errors.New("没有可执行任务")

View File

@ -490,6 +490,7 @@ func (this *NormalList) Init() {
this.List.Init() this.List.Init()
this.HasMore = false this.HasMore = false
this.CurPos = nil this.CurPos = nil
this.MaxPage = 0
} }
func (this *NormalList) GetFirst() (*list.Element, error) { func (this *NormalList) GetFirst() (*list.Element, error) {

View File

@ -99,6 +99,7 @@ type PlayListSrcInfo struct {
BizType BizTypeDef BizType BizTypeDef
Order MusicLenType Order MusicLenType
ListHasEnd bool //顺序播放的时候,是否播放完成
} }
// 本地存储播放列表的数据结构 // 本地存储播放列表的数据结构
@ -237,6 +238,30 @@ type ServerSongPlay struct {
SongPlay SongPlayInfo `json:"songPlayInfo"` SongPlay SongPlayInfo `json:"songPlayInfo"`
} }
//歌单详情,服务器返回结构
type MusicPlayListDetail struct {
Id int `json:"id"`
Name string `json:"name"`
TrackCount int `json:"trackCount"`
}
// 服务器返回参数: 返回歌曲id的详细信息
type MusicPlayListInfo struct {
ListInfo MusicPlayListDetail `json:"playlist"`
}
//电台详情,服务器返回结构
type RadioPlayListDetail struct {
Id int `json:"id"`
Album string `json:"album"`
ProgramCount int `json:"programCount"`
}
// 服务器返回参数: 返回歌曲id的详细信息
type RadioPlayListInfo struct {
ListInfo RadioPlayListDetail `json:"data"`
}
// 消息通知状态合集,后续提醒的状态也可以添加在其中 // 消息通知状态合集,后续提醒的状态也可以添加在其中
type IsNotify struct { type IsNotify struct {
IsAlarm bool IsAlarm bool
@ -451,6 +476,8 @@ const (
ACTION_ADD_LIST_MUSIC_SHARE // 13 ACTION_ADD_LIST_MUSIC_SHARE // 13
ACTION_PRE_PAGE_REPLACE_LIST //14 前一页 page
ACTION_STOP_PLAYER // 停止播放器 ACTION_STOP_PLAYER // 停止播放器
ACTION_NULL ACTION_NULL

View File

@ -1,6 +1,9 @@
package globals package globals
import "strings" import (
"strings"
"time"
)
type PlayerType uint32 type PlayerType uint32
@ -52,6 +55,8 @@ const (
WAKEUP_AUDIO_ID string = "wakeup_audio_uuid" WAKEUP_AUDIO_ID string = "wakeup_audio_uuid"
SUB_AUDIO_ID string = "audio_uuid" SUB_AUDIO_ID string = "audio_uuid"
BT_WIFI_RESUME_TIME_LIMIT time.Duration = 30 * time.Second
) )
const ( const (
@ -89,4 +94,6 @@ var (
KeyVolTest bool = false KeyVolTest bool = false
GetFrom163Test bool = true GetFrom163Test bool = true
BtAvkDataRecving bool = false
) )

View File

@ -15,6 +15,8 @@ const (
ERR_ACCOUNT_NOT_EXIST ErrCode = 1003 ERR_ACCOUNT_NOT_EXIST ErrCode = 1003
ERR_SERVER_ARGS_ERROR ErrCode = 3000 ERR_SERVER_ARGS_ERROR ErrCode = 3000
ERR_BIND_ACCOUNT_BEYOND_MAX ErrCode = 2000 ERR_BIND_ACCOUNT_BEYOND_MAX ErrCode = 2000
ERR_DEVICE_BOUNDED ErrCode = 4100
ERR_ACCOUNT_BOUNDED ErrCode = 4101
) )
type Cmd int type Cmd int
@ -62,6 +64,7 @@ const (
const ( const (
MSC_CMD_QUERY_VOL Cmd = 3025 MSC_CMD_QUERY_VOL Cmd = 3025
MSC_CMD_MODE_CHANGE Cmd = 3026 MSC_CMD_MODE_CHANGE Cmd = 3026
MSC_CMD_ORDER_PLAY Cmd = 3027 //顺序播放
) )
const ( const (
MSC_CMD_LIGHT_ON Cmd = 3010 + iota MSC_CMD_LIGHT_ON Cmd = 3010 + iota
@ -94,6 +97,7 @@ const (
const ( const (
MSC_CMD_IOTWIFIPARING Cmd = 3700 MSC_CMD_IOTWIFIPARING Cmd = 3700
MSC_CMD_BTONWIFIOFF Cmd = 3701
) )
const ( const (

View File

@ -40,12 +40,13 @@ const (
TTS_REPEAT_NIL = "可惜,这个我帮不到你" TTS_REPEAT_NIL = "可惜,这个我帮不到你"
TTS_MUSIC_ERR_1 = "当前没有音乐内容,想听音乐你可以说,嘀嗒嘀嗒,来点音乐" TTS_MUSIC_ERR_1 = "当前没有音乐内容,想听音乐你可以说,嘀嗒嘀嗒,来点音乐"
TTS_MUSIC_ERR_2 = "抱歉,当前音乐来自手机等设备,我也无法切换播放模式" TTS_MUSIC_ERR_2 = "抱歉,当前内容来自手机等设备,我也无法切换播放模式"
TTS_MUSIC_ERR_3 = "抱歉,当前音乐来自手机等设备,我也无法为你收藏" TTS_MUSIC_ERR_3 = "抱歉,当前内容来自手机等设备,我也无法为你收藏"
TTS_MUSIC_ERR_4 = "没有播放中的音乐,无法收藏" TTS_MUSIC_ERR_4 = "没有播放中的音乐,无法收藏"
TTS_MUSIC_ERR_5 = "没有音乐可以播放,你可以说:嘀嗒嘀嗒,来点音乐" TTS_MUSIC_ERR_5 = "没有音乐可以播放,你可以说:嘀嗒嘀嗒,来点音乐"
TTS_DLNA_ERR_1 = "播放源失效,请点击下一首继续" //TTS_DLNA_ERR_1 = "播放源失效,请点击下一首继续"
TTS_DLNA_ERR_1 = "很抱歉,暂时无法播放这首歌,想听歌的话可以对我说,播放每日推荐"
TTS_MUSIC_LIST_ONE = "现在只有一首歌了,想听更多歌曲的话可以对我说,嘀嗒嘀嗒,来首歌" TTS_MUSIC_LIST_ONE = "现在只有一首歌了,想听更多歌曲的话可以对我说,嘀嗒嘀嗒,来首歌"
TTS_RADIO_LIST_ONE = "现在只有一个节目了,为你继续播放" TTS_RADIO_LIST_ONE = "现在只有一个节目了,为你继续播放"
@ -55,9 +56,17 @@ const (
TTS_TEXT_BT_CONNECT_CONFLICT = "当前音箱蓝牙已被占用,请先断开" TTS_TEXT_BT_CONNECT_CONFLICT = "当前音箱蓝牙已被占用,请先断开"
TTS_TEXT_RADIO_END = "这个节目已经播放完了,你可以尝试点播新的内容" TTS_TEXT_RADIO_END = "好的,不过你之前点的节目已经播完了,一起回味下最后收听的内容"
TTS_TEXT_MUSIC_END = "列表中歌曲已全部播完"
TTS_TEXT_LAST_RADIO = "抱歉,没有下一个节目了" TTS_TEXT_LAST_RADIO = "抱歉,没有下一个节目了"
TTS_TEXT_FIRST_RADIO = "抱歉,没有上一个节目了" TTS_TEXT_FIRST_RADIO = "抱歉,没有上一个节目了"
TTS_TEXT_LAST_MUSIC = "抱歉,没有下一首音乐了"
TTS_TEXT_FIRST_MUSIC = "抱歉,没有上一首音乐了"
// 产品暂时播放完成不播报tts暂时内部用非tts
// 用于顺序播放完成的标志
// 后续产品有顺序播放完成tts需求可以使用此tts
TTS_TEXT_ORDER_PLAY_END_FLAG = "_ORDER_PLAY_END_FLAG"
) )
var ( var (

View File

@ -6,7 +6,7 @@ import (
) )
const ( const (
BRAODCAST_ST_PERIOD = 10 * time.Second BRAODCAST_ST_PERIOD = 30 * time.Second
) )
type MusicFieldSt uint16 type MusicFieldSt uint16
@ -50,6 +50,10 @@ func ResetBroadCastTimer() {
BroadcastStTimer.Reset(0) BroadcastStTimer.Reset(0)
} }
func SetBroadCastTimer(afterTime time.Duration) {
BroadcastStTimer.Reset(afterTime)
}
func TrigBroadcastStatus(st VboxBroadcastSt) { func TrigBroadcastStatus(st VboxBroadcastSt) {
st.TimeStamp = time.Now().Unix() st.TimeStamp = time.Now().Unix()
select { select {

View File

@ -1,5 +1,11 @@
package globals package globals
import (
"time"
"strconv"
"strings"
)
const ( const (
YunxinServerAccount = "000000" YunxinServerAccount = "000000"
) )
@ -16,6 +22,50 @@ type VboxInfo struct {
Status int `json:"status"` Status int `json:"status"`
} }
type CloudHistoryStautus int
const (
CloudHistoryStautus_Save CloudHistoryStautus = 1
CloudHistoryStautus_UnSave CloudHistoryStautus = 0
)
type OffLineStatus int
const (
OffLineStatus_Online OffLineStatus = 0
OffLineStatus_Offline OffLineStatus = 1
)
type MillTimeStamp time.Time
func (t MillTimeStamp) MarshalJSON() ([]byte, error) {
return []byte(strconv.FormatInt(time.Time(t).UnixNano()/1e6, 10)), nil
}
func (t *MillTimeStamp) UnmarshalJSON(s []byte) (err error) {
r := strings.Replace(string(s), `"`, ``, -1)
q, err := strconv.ParseInt(r, 10, 64)
if err != nil {
return err
}
*(*time.Time)(t) = time.Unix(q/1000, q%1000*1e6)
return
}
type YunxinAPPMsg struct {
ResCode int `json:"resCode"`
Feature int `json:"feature"`
Content struct {
ToType int `json:"to_type"`
TimeStampM MillTimeStamp `json:"time"`
MsgType int `json:"msg_type"`
MsgBody string `json:"msg_body"`
CloudHistory CloudHistoryStautus `json:"cloud_history"`
OfflineStatus OffLineStatus `json:"offline_msg"`
} `json:"content"`
}
type YunxinBasePack struct { type YunxinBasePack struct {
Cmd Cmd `json:"cmd"` Cmd Cmd `json:"cmd"`
Timestamp int64 `json:"ts"` Timestamp int64 `json:"ts"`
@ -69,6 +119,7 @@ const (
YxSCmd_UploadLog YunxinServerCmdId = 8300 //exec vol=0 YxSCmd_UploadLog YunxinServerCmdId = 8300 //exec vol=0
YxSCmd_RefreshCfglist YunxinServerCmdId = 8302 YxSCmd_RefreshCfglist YunxinServerCmdId = 8302
YxSCmd_IotWifiParingResult YunxinServerCmdId = 8303 YxSCmd_IotWifiParingResult YunxinServerCmdId = 8303
YxSCmd_InBtOnWifiOff YunxinServerCmdId = 8304
YxSCmd_MscTest YunxinServerCmdId = 77777 //exec vol=0 YxSCmd_MscTest YunxinServerCmdId = 77777 //exec vol=0
) )

View File

@ -51,7 +51,7 @@ func EpRecord(eventId string, args map[string]interface{}) {
log.Println(log.ErrorLog, err) log.Println(log.ErrorLog, err)
} }
}() }()
return
var tmp EventPoint var tmp EventPoint
tmp.Base = http.Reqbase tmp.Base = http.Reqbase
args["event"] = eventId args["event"] = eventId

View File

@ -8,9 +8,10 @@ import (
type InformType int type InformType int
const ( const (
Type_Inform_Ota InformType = 103 Type_Inform_Ota InformType = 103
Type_Inform_TtsDelay InformType = 108 Type_Inform_TtsDelay InformType = 108
Type_Inform_TtsPush InformType = 109 //上传成对出现的tts信息流 Type_Inform_TtsPush InformType = 109 //上传成对出现的tts信息流
Type_Inform_BtOnWifiOff InformType = 110
) )
const ( const (
Type_Inform_Top3_Play InformType = 104 + iota Type_Inform_Top3_Play InformType = 104 + iota
@ -44,7 +45,7 @@ func GetWeatherInfo() (*WeatherResp, int, *string, error) {
return &res, code, nil, nil return &res, code, nil, nil
} }
func InformMsgToServer(informType InformType, data interface{}) { func InformMsgToServer(informType InformType, data interface{}) error {
defer func() { defer func() {
if err := recover(); err != nil { if err := recover(); err != nil {
log.Println(log.ErrorLog, err) log.Println(log.ErrorLog, err)
@ -55,8 +56,10 @@ func InformMsgToServer(informType InformType, data interface{}) {
if code, _, err := HttpPostAuto(httpInformReq, &res); code == 1000 && err == nil { if code, _, err := HttpPostAuto(httpInformReq, &res); code == 1000 && err == nil {
log.Println(log.DebugLog, "has inform server of data:", data, " rsp:", res) log.Println(log.DebugLog, "has inform server of data:", data, " rsp:", res)
return err
} else { } else {
log.Println(log.WarningLog, "inform server failed, data:", data, "code: ", code, " err:", err) log.Println(log.WarningLog, "inform server failed, data:", data, "code: ", code, " err:", err)
return err
} }
} }

View File

@ -86,6 +86,12 @@ const (
//电台detail接口 //电台detail接口
URL_Get_Radio_List_Rcmd = "vbox/radio/common/getlist" URL_Get_Radio_List_Rcmd = "vbox/radio/common/getlist"
//music play list info接口
URL_Get_Music_Play_List_Rcmd = "vbox/music/playlist/detail"
//电台play list info接口
URL_Get_Radio_Play_List_Rcmd = "vbox/app/radio/info"
) )
type HttpReqbase struct { type HttpReqbase struct {
@ -408,6 +414,16 @@ type reqGetRadioPlayListRcmd struct {
ExtraData string `json:"extraData"` ExtraData string `json:"extraData"`
} }
type reqGetRadioPlayListInfoRcmd struct {
RadioId string `json:"radioId"`
ModeId int64 `json:"modeId"`
}
type reqGetMusicPlayListInfoRcmd struct {
PlaylistId string `json:"playlist_id"`
ModeId int64 `json:"modeId"`
}
type reqAlbumByID struct { type reqAlbumByID struct {
AlbumId string `json:"id,omitempty"` AlbumId string `json:"id,omitempty"`
Size globals.MusicLenType `json:"size"` Size globals.MusicLenType `json:"size"`
@ -580,6 +596,12 @@ type MusicListServerType struct {
NextMusic bool NextMusic bool
} }
//获取歌单信息
type PlayListServerType struct {
Id *string
ModeId int64
}
type DataType uint8 type DataType uint8
const ( const (

View File

@ -51,6 +51,9 @@ func init() {
RegisteApi(reqGetNaturalPlayListRcmd{}, ApiContainer{Url: URL_Natual_GetPlaylist_Rcmd, ReqparamIsString: true, IsEncrypted: true}) RegisteApi(reqGetNaturalPlayListRcmd{}, ApiContainer{Url: URL_Natual_GetPlaylist_Rcmd, ReqparamIsString: true, IsEncrypted: true})
RegisteApi(reqRadioDetailInfo{}, ApiContainer{Url: URL_Radio_Detail_Rcmd, ReqparamIsString: true, IsEncrypted: true}) RegisteApi(reqRadioDetailInfo{}, ApiContainer{Url: URL_Radio_Detail_Rcmd, ReqparamIsString: true, IsEncrypted: true})
RegisteApi(reqGetRadioPlayListRcmd{}, ApiContainer{Url: URL_Get_Radio_List_Rcmd, ReqparamIsString: true, IsEncrypted: true}) RegisteApi(reqGetRadioPlayListRcmd{}, ApiContainer{Url: URL_Get_Radio_List_Rcmd, ReqparamIsString: true, IsEncrypted: true})
RegisteApi(reqGetMusicPlayListInfoRcmd{}, ApiContainer{Url: URL_Get_Music_Play_List_Rcmd, ReqparamIsString: true, IsEncrypted: true})
RegisteApi(reqGetRadioPlayListInfoRcmd{}, ApiContainer{Url: URL_Get_Radio_Play_List_Rcmd, ReqparamIsString: true, IsEncrypted: true})
} }
func GetSongPlayInfoDo(id *string) (*ServerSongPlay, int, *string, error) { func GetSongPlayInfoDo(id *string) (*ServerSongPlay, int, *string, error) {
@ -99,6 +102,50 @@ func GetSongDetailInfoDo(id *string) (*ServerSongDetail, int, *string, error) {
return &res, code, nil, nil return &res, code, nil, nil
} }
func GetMusicPlayListInfoDo(listinfo PlayListServerType) (*MusicPlayListInfo, int, *string, error) {
if nil == listinfo.Id {
return nil, 0, nil, Server_ERR_RET
}
var reqbody interface{}
reqbody = reqGetMusicPlayListInfoRcmd{PlaylistId: *listinfo.Id, ModeId: listinfo.ModeId}
var res MusicPlayListInfo
code, detail, err := postInterface(reqbody, &res)
if int(ERR_SUCCESS) != code && "" != detail {
return nil, code, &detail, Server_ERR_RET
}
if nil != err {
log.Println(log.ErrorLog, err.Error())
return nil, code, nil, err
}
return &res, code, nil, nil
}
func GetRadioPlayListInfoDo(listinfo PlayListServerType) (*RadioPlayListInfo, int, *string, error) {
if nil == listinfo.Id {
return nil, 0, nil, Server_ERR_RET
}
var reqbody interface{}
reqbody = reqGetRadioPlayListInfoRcmd{RadioId: *listinfo.Id, ModeId: listinfo.ModeId}
var res RadioPlayListInfo
code, detail, err := postInterface(reqbody, &res)
if int(ERR_SUCCESS) != code && "" != detail {
return nil, code, &detail, Server_ERR_RET
}
if nil != err {
log.Println(log.ErrorLog, err.Error())
return nil, code, nil, err
}
return &res, code, nil, nil
}
func GetMusicListDoNew(musicList MusicListServerType) (*ServerMusicList, int, *string, error) { func GetMusicListDoNew(musicList MusicListServerType) (*ServerMusicList, int, *string, error) {
var res ServerMusicList var res ServerMusicList
var code int var code int

View File

@ -282,6 +282,13 @@ func coreSchedule(cmd SCmdStruct) {
if curRunningPlayer != player { if curRunningPlayer != player {
changePlayer(curRunningPlayer, player) changePlayer(curRunningPlayer, player)
} }
if curRunningPlayer != nil && curRunningPlayer.Player.GetScheduleDomain != nil {
setscheduleDomain(curRunningPlayer.Player.GetScheduleDomain)
} else {
setscheduleDomain(scheduleDomain_default_player)
}
//uncontrol player //uncontrol player
if curRunningPlayer.Player.IfForcePause() == false { if curRunningPlayer.Player.IfForcePause() == false {
//curRunningPlayer.ClearPlayStatus() //curRunningPlayer.ClearPlayStatus()
@ -302,8 +309,8 @@ func coreSchedule(cmd SCmdStruct) {
player.Player.Pause() player.Player.Pause()
player.playerDetail.Status = globals.MUSIC_ST_PAUSED player.playerDetail.Status = globals.MUSIC_ST_PAUSED
} }
player.PlayAfterResume = false //player.PlayAfterResume = false
player.HasRequestPlayWhenInterrupt = false //player.HasRequestPlayWhenInterrupt = false
if cmd.ExecCb != nil { if cmd.ExecCb != nil {
cmd.ExecCb(SCmdStructExecCb{Result: SCmdExecStatus_NotEnoughPrivilege}) cmd.ExecCb(SCmdStructExecCb{Result: SCmdExecStatus_NotEnoughPrivilege})
@ -572,6 +579,11 @@ func reCheckScheduleTask() {
curRunningTask = nil curRunningTask = nil
//come here means task is nil, can play //come here means task is nil, can play
if curRunningPlayer != nil && curRunningPlayer.Player.GetScheduleDomain != nil {
setscheduleDomain(curRunningPlayer.Player.GetScheduleDomain)
} else {
setscheduleDomain(scheduleDomain_default_player)
}
if curRunningPlayer.Player.IsOnline() { if curRunningPlayer.Player.IsOnline() {
if result := curRunningPlayer.Resume(); result == true && globals.CurBootState == globals.BootStage_FINISH { if result := curRunningPlayer.Resume(); result == true && globals.CurBootState == globals.BootStage_FINISH {
@ -584,28 +596,30 @@ func reCheckScheduleTask() {
} else { } else {
//curplayer is offline, change to the wifi player //curplayer is offline, change to the wifi player
if curRunningPlayer.GetPlayerId() != uint32(globals.PlayerType_Wifi) { if curRunningPlayer.GetPlayerId() != uint32(globals.PlayerType_Wifi) {
prevPlayer := curRunningPlayer.GetPlayerId()
if player := playermap[uint32(globals.PlayerType_Wifi)]; player != nil { if player := playermap[uint32(globals.PlayerType_Wifi)]; player != nil {
changePlayer(curRunningPlayer, player) changePlayer(curRunningPlayer, player)
curRunningPlayer = player curRunningPlayer = player
if curRunningPlayer != nil && curRunningPlayer.Player.GetScheduleDomain != nil {
setscheduleDomain(curRunningPlayer.Player.GetScheduleDomain)
}
if isGlobalPause == true { if isGlobalPause == true {
log.Println(log.DebugLog, "Global pause is ", isGlobalPause) log.Println(log.DebugLog, "Global pause is ", isGlobalPause)
isGlobalPause = false isGlobalPause = false
curRunningPlayer.PlayAfterResume = false curRunningPlayer.PlayAfterResume = false
} }
//do not resume play #PV1-2041
/*curRunningPlayer.PlayAfterResume = false
curRunningPlayer.Resume()*/ //need to resume play #PV1-4131. if prevPlayer != uint32(globals.PlayerType_Bt){ //PV1-2041 //PV1-4131
curRunningPlayer.PlayAfterResume = false
}
curRunningPlayer.Resume()
} }
} }
} }
if curRunningPlayer.Player.GetScheduleDomain != nil {
setscheduleDomain(curRunningPlayer.Player.GetScheduleDomain)
} else {
setscheduleDomain(scheduleDomain_default_player)
}
if curRunningPlayer.IsPlaying() == true { if curRunningPlayer.IsPlaying() == true {
vui.ShowIconMusic() vui.ShowIconMusic()
misc.VolTrigeMicAdc() misc.VolTrigeMicAdc()
@ -671,14 +685,27 @@ func changePlayer(from *SPlayer, to *SPlayer) {
UnlockScene() UnlockScene()
} }
curRunningPlayer = to
globals.ResetBroadCastTimer() globals.ResetBroadCastTimer()
} }
func checkTaskCanRun(task *STask) (canRun bool) { func checkTaskCanRun(task *STask) (canRun bool) {
for i := TaskLevel_Min; i < task.Task.GetTaskLevel() && i < TaskLevel_MAX; i++ { for i := TaskLevel_Min; i <= task.Task.GetTaskLevel() && i < TaskLevel_MAX; i++ {
for _, task := range alltask[i] { for _, tmptask := range alltask[i] {
if task.Task.IsActive() == true { if tmptask.Task.GetName() == task.Task.GetName() {
return false continue
}
if i == task.Task.GetTaskLevel() {
if tmptask.Task.IsActive() == true {
if tmptask.Task.CanBeInterruptBySameLevelTask == nil || tmptask.Task.CanBeInterruptBySameLevelTask != nil && tmptask.Task.CanBeInterruptBySameLevelTask() == false {
return false
}
}
} else {
if tmptask.Task.IsActive() == true {
return false
}
} }
} }
} }
@ -714,6 +741,12 @@ func playerRequestPlay(playerid uint32, arg interface{}) (canPlay bool) {
changePlayer(curRunningPlayer, player) changePlayer(curRunningPlayer, player)
} }
if curRunningPlayer != nil && curRunningPlayer.Player.GetScheduleDomain != nil {
setscheduleDomain(curRunningPlayer.Player.GetScheduleDomain)
} else {
setscheduleDomain(scheduleDomain_default_player)
}
curRunningPlayer.OemArg.OemArg = arg curRunningPlayer.OemArg.OemArg = arg
//uncontrol player //uncontrol player
if curRunningPlayer.Player.IfForcePause() == false { if curRunningPlayer.Player.IfForcePause() == false {
@ -730,8 +763,8 @@ func playerRequestPlay(playerid uint32, arg interface{}) (canPlay bool) {
player.Player.Pause() player.Player.Pause()
player.playerDetail.Status = globals.MUSIC_ST_PAUSED player.playerDetail.Status = globals.MUSIC_ST_PAUSED
} }
player.PlayAfterResume = false //player.PlayAfterResume = false
player.HasRequestPlayWhenInterrupt = false //player.HasRequestPlayWhenInterrupt = false
} }
// wait for st from player // wait for st from player

View File

@ -25,7 +25,7 @@ func SendSCmdStruct(scmd SCmdStruct) {
select { select {
case coreChan <- scmd: case coreChan <- scmd:
if scmd.SCmd != SCMD_SChedule { if scmd.SCmd != SCMD_SChedule {
log.Printf(log.DebugLog, "Send cmd: %d success!\n", scmd) log.Printf(log.DebugLog, "Send cmd: %+v success!\n", scmd)
} }
default: default:
log.Println(log.DebugLog, "Send fail, cmd:", scmd) log.Println(log.DebugLog, "Send fail, cmd:", scmd)
@ -58,6 +58,7 @@ const (
ScheduleDomain_Alarm ScheduleDomain_Alarm
ScheduleDomain_Remind ScheduleDomain_Remind
ScheduleDomain_Notice ScheduleDomain_Notice
ScheduleDomain_IotWifiParing
) )
func (this *ScheduleDomain) String() string { func (this *ScheduleDomain) String() string {

View File

@ -497,7 +497,8 @@ func isPlaying(st globals.PlayerStatuses) bool {
func SpeakerIsPlaying() bool { func SpeakerIsPlaying() bool {
if isPlaying(globals.CurPlayerSt.ContinuousTaskSt) || if isPlaying(globals.CurPlayerSt.ContinuousTaskSt) ||
SeIsPlaying() == true || SeIsPlaying() == true ||
NoticeIsPlaying() == true { NoticeIsPlaying() == true ||
globals.BtAvkDataRecving == true {
return true return true
} else { } else {
return false return false

View File

@ -33,6 +33,10 @@ const (
//iot //iot
SCMD_SuperTask_Enter_IOT_WifiParing SCMD_SuperTask_Enter_IOT_WifiParing
//btOnWifiOff
SCMD_SuperTask_Enter_btOnWifiOff
SCMD_SuperTask_Exit_btOnWifiOff
//Alarm //Alarm
SCMD_SuperTask_Alarm_Ring SCMD_SuperTask_Alarm_Ring
//Remind //Remind

View File

@ -23,6 +23,8 @@ const (
const ( const (
TaskLevel_SystemService = TaskLevel_0 TaskLevel_SystemService = TaskLevel_0
TaskLevel_IotWifiParingService = TaskLevel_1 TaskLevel_IotWifiParingService = TaskLevel_1
TaskLevel_BtOnWifiOff = TaskLevel_1
TaskLevel_WifiParing = TaskLevel_1
TaskLevel_VoiceEventService = TaskLevel_2 TaskLevel_VoiceEventService = TaskLevel_2
TaskLevel_RemindService = TaskLevel_3 TaskLevel_RemindService = TaskLevel_3
TaskLevel_AlarmService = TaskLevel_4 TaskLevel_AlarmService = TaskLevel_4
@ -38,7 +40,7 @@ const (
type TaskStatus uint8 type TaskStatus uint8
const ( const (
TaskStatus_Init TaskStatus = iota TaskStatus_Init TaskStatus = iota
TaskStatus_Running TaskStatus_Running
TaskStatus_Interrupted TaskStatus_Interrupted
) )
@ -55,7 +57,8 @@ type RegistedTask struct {
GetName func() string GetName func() string
GetTaskLevel func() TaskLevel GetTaskLevel func() TaskLevel
CanBeInterruptByKey func() bool CanBeInterruptByKey func() bool
CanBeInterruptBySameLevelTask func() bool
GetSupportedSCmd func() []SCMD GetSupportedSCmd func() []SCMD
GetScheduleDomain ScheduleDomainGetFunc GetScheduleDomain ScheduleDomainGetFunc

View File

@ -57,7 +57,7 @@ type StartPlayNotice func(id uint32, srcType globals.AdSrcType, src string, uuid
type StopPlayNotice func(id uint32) type StopPlayNotice func(id uint32)
type PlayNoticeCallBack func(id uint32, reason NoticeStopReason) type PlayNoticeCallBack func(id uint32, reason NoticeStopReason)
const audioPlayIdStart = 1 //id = curplayid ++, 即从2开始避免与music相同 const audioPlayIdStart = uint32(globals.PlayerType_Other) //id = curplayid ++, 即从PlayerType_Other + 1 开始
var ( var (
curplayid uint32 = audioPlayIdStart curplayid uint32 = audioPlayIdStart
noticeChan chan uint8 noticeChan chan uint8

View File

@ -102,7 +102,9 @@ func ShowIcon(icon IconLedDesc) {
}() }()
if val := globals.IconLedSwitch.GetCfgListVui(); val == 0 && icon.CanNotOff == false { if val := globals.IconLedSwitch.GetCfgListVui(); val == 0 && icon.CanNotOff == false {
log.Println(log.DebugLog, "Icon show is off, do not show:", icon.Name) if icon.Equal(justlastIcon) == false {
log.Println(log.DebugLog, "Icon show is off, do not show:", icon.Name)
}
return return
} }

View File

@ -21,6 +21,7 @@ import (
func Init() { func Init() {
log.Println(log.DebugLog, "Begin init skin!") log.Println(log.DebugLog, "Begin init skin!")
C.SkinInit() C.SkinInit()
log.Println(log.DebugLog, "Init skin end!")
} }
func GetSkinRes(key string) (path string) { func GetSkinRes(key string) (path string) {

View File

@ -103,6 +103,19 @@ const (
SoundNotice_Mic_Close SoundNotice = "v601" //麦克风已禁用 SoundNotice_Mic_Close SoundNotice = "v601" //麦克风已禁用
SoundNotice_Mic_Open SoundNotice = "v602" //麦克风已启用 SoundNotice_Mic_Open SoundNotice = "v602" //麦克风已启用
SoundNotice_Enter_BtOnWifiOff SoundNotice = "v701" //正在进入蓝牙单通道模式
SoundNotice_Exit_BtOnWifiOff SoundNotice = "v703" //正在退出蓝牙单通道模式
SoundNotice_Warn_BtOnWifiOff SoundNotice = "v702" //请先长按顶部按键退出蓝牙单通道模式后再使用
SoundNotice_IOT_Finding SoundNotice = "v905" //正在为你扫描周围的智能设备,请耐心等待
SoundNotice_IOT_Finded SoundNotice = "v906" //已为你找到设备,现在开始联网,请稍等
SoundNotice_IOT_NotFound SoundNotice = "v909" //抱歉,没有找到附近的智能设备,请检查该设备是否在配网状态
SoundNotice_IOT_ConnectedSuccess SoundNotice = "v907" //与设备连接成功快打开三音APP进入智能家居页面学习怎么操作吧
SoundNotice_IOT_ConnectedFail SoundNotice = "v908" //抱歉,连接设备失败,请检查该设备的网络状况后再试一下吧
SoundNotice_PullFromServer_Timeout SoundNotice = "v801" //暂时没办法为你继续播放了,待会儿再试试吧
) )
func (this SoundNotice) GetPath() string { func (this SoundNotice) GetPath() string {

View File

@ -19,6 +19,8 @@ func Init() {
controller.RemindTaskinit() controller.RemindTaskinit()
controller.VoiceTaskInit() controller.VoiceTaskInit()
controller.IOTTaskinit() controller.IOTTaskinit()
//controller.BtOnWifiOffTaskinit()
controller.WifiParingTaskinit()
player.PlayerInit() player.PlayerInit()
log.Println(log.DebugLog, "Begin to init controller!") log.Println(log.DebugLog, "Begin to init controller!")
controller.Init() controller.Init()

View File

@ -17,17 +17,14 @@ import (
) )
var ( var (
timeBtPause time.Time = time.Now() timeBtPause time.Time
timeBtPlay time.Time = time.Now() timeBtPlay time.Time
enableBtMixProtect bool = false enableBtMixProtect bool = false
waitLock sync.Mutex waitLock sync.Mutex
waitPlayAfterPauseTimer *time.Timer = nil waitPlayAfterPauseTimer *time.Timer = nil
btCon bool = false btCon bool = false
) pauseBtNeedResumeWifiPlay bool = false
const (
BT_WIFI_RESUME_TIME_LIMIT time.Duration = 30 * time.Second
) )
func BtMsgProcess(cmdid uint32, msg string) { func BtMsgProcess(cmdid uint32, msg string) {
@ -46,13 +43,18 @@ func BtMsgProcess(cmdid uint32, msg string) {
} }
if !player.PlayerHander[globals.PlayerType_Bt].IsPlaying() { if !player.PlayerHander[globals.PlayerType_Bt].IsPlaying() {
timeBtPlay = time.Now() pauseBtNeedResumeWifiPlay = false
if player.PlayerHander[globals.PlayerType_Wifi].IsPlaying() {
pauseBtNeedResumeWifiPlay = true
timeBtPlay = time.Now()
}
player.ChangeBtOnLineSt(true) player.ChangeBtOnLineSt(true)
} else { } else {
log.Printf(log.DebugLog, "IsPlaying: %v\n", player.PlayerHander[globals.PlayerType_Bt].IsPlaying()) log.Printf(log.DebugLog, "IsPlaying: %v\n", player.PlayerHander[globals.PlayerType_Bt].IsPlaying())
} }
case uint32(C.CMD_BT_AVK_RC_PAUSE): //case uint32(C.CMD_BT_AVK_RC_PAUSE):
//case uint32(C.CMD_BT_AVK_RC_PAUSE), uint32(C.CMD_BT_AVK_SOUND_STOP_EVT): case uint32(C.CMD_BT_AVK_RC_PAUSE), uint32(C.CMD_BT_AVK_SOUND_STOP_EVT):
switch cmdid { switch cmdid {
case uint32(C.CMD_BT_AVK_RC_PAUSE): case uint32(C.CMD_BT_AVK_RC_PAUSE):
log.Println(log.WarningLog, "bt---------------------------- CMD_BT_AVK_RC_PAUSE") log.Println(log.WarningLog, "bt---------------------------- CMD_BT_AVK_RC_PAUSE")
@ -68,8 +70,11 @@ func BtMsgProcess(cmdid uint32, msg string) {
if cmdid == C.CMD_BT_AVK_SOUND_STOP_EVT { if cmdid == C.CMD_BT_AVK_SOUND_STOP_EVT {
player.MonitorBtPlayerBroadcast(globals.MUSIC_ST_PAUSED) player.MonitorBtPlayerBroadcast(globals.MUSIC_ST_PAUSED)
}else }
if time.Now().Sub(timeBtPlay) < BT_WIFI_RESUME_TIME_LIMIT {
//#PV1-4403
if time.Now().Sub(timeBtPlay) <= globals.BT_WIFI_RESUME_TIME_LIMIT && pauseBtNeedResumeWifiPlay {
log.Println(log.WarningLog, "bt offline , resume to wifi.")
player.ChangeBtOnLineSt(false) player.ChangeBtOnLineSt(false)
} }
} else { } else {
@ -116,7 +121,11 @@ func BtMsgProcess(cmdid uint32, msg string) {
log.Println(log.WarningLog, "time disconnect is:", time.Now().Sub(timeBtPause), ", ignore se") log.Println(log.WarningLog, "time disconnect is:", time.Now().Sub(timeBtPause), ", ignore se")
} }
//player.ChangeBtOnLineSt(false) //mark by lupeng 20180903 for #PV1-4131 if time.Now().Sub(timeBtPlay) > globals.BT_WIFI_RESUME_TIME_LIMIT && player.BtPlayIsOnline() && !player.AirPlayIsOnline2() && !player.DlnaIsOnline(){ //20180912 lupeng add #PV1-4403
log.Println(log.WarningLog, "bt offline , send GloablePause.")
schedule.SendSCmd(schedule.SCMD_MusicPlayer_Pause, schedule.PlayerArg{GloablePause: true, NotShowIcon: true})
}
player.ChangeBtOnLineSt(false)
eventPoint.DeviceDisconEvent(eventPoint.ModelValBt) eventPoint.DeviceDisconEvent(eventPoint.ModelValBt)
case uint32(C.CMD_BT_AVK_CRTED): case uint32(C.CMD_BT_AVK_CRTED):

View File

@ -4,6 +4,10 @@ import (
"netease_control_center/utils/customization" "netease_control_center/utils/customization"
"netease_control_center/utils/ntp" "netease_control_center/utils/ntp"
"sync" "sync"
"netease_control_center/globals"
"time"
"netease_control_center/interfaces/log"
"math/rand"
) )
var ( var (
@ -20,5 +24,8 @@ func calTimeSuccess() {
UpdateMicStatus(true) UpdateMicStatus(true)
UpdateCronTime() UpdateCronTime()
go customization.DoCheck(5) go customization.DoCheck(5)
globals.FirstCalTime = time.Now()
rand.Seed(time.Now().UnixNano())
log.Println(log.DebugLog, "Firstly cal time:", globals.FirstCalTime)
}) })
} }

View File

@ -31,7 +31,7 @@ func CrontabInit() {
log.Println(log.ErrorLog, "Set Nduilite_fespa_set error 7", err) log.Println(log.ErrorLog, "Set Nduilite_fespa_set error 7", err)
} }
if err := cron_system.AddFunc("25 3 3 * * *", func() { if err := cron_system.AddFunc("0 0 5 * * *", func() {
Nduilite_fespa_set_arg(true) Nduilite_fespa_set_arg(true)
}); err != nil { }); err != nil {
log.Println(log.ErrorLog, "Set Nduilite_fespa_set_arg with sdk init", err) log.Println(log.ErrorLog, "Set Nduilite_fespa_set_arg with sdk init", err)

View File

@ -55,7 +55,7 @@ func DlnaCmdProcess(cmdid uint32, msg string) {
} }
log.Println(log.WarningLog, "GetCurPlayerId():", GetCurPlayerId(), log.Println(log.WarningLog, "GetCurPlayerId():", GetCurPlayerId(),
"PlayerType_Dlna.IsActive():", player.PlayerHander[PlayerType_Dlna].IsActive(), "playPauseState: ", player.GetDlnaPlayPauseState()) "PlayerType_Dlna.IsActive():", player.PlayerHander[PlayerType_Dlna].IsActive(), "playPauseState: ", player.GetDlnaPlayPauseState())
player.DlnaPlaySeek = true
if GetCurPlayerId() == PlayerType_Dlna && player.PlayerHander[PlayerType_Dlna].IsActive() { if GetCurPlayerId() == PlayerType_Dlna && player.PlayerHander[PlayerType_Dlna].IsActive() {
if !player.GetDlnaPlayPauseState() { if !player.GetDlnaPlayPauseState() {
//SendSCmd(SCMD_MusicPlayer_Play, nil) //SendSCmd(SCMD_MusicPlayer_Play, nil)
@ -100,13 +100,13 @@ func DlnaCmdProcess(cmdid uint32, msg string) {
return return
} }
log.Println(log.WarningLog, "recive stop cmd from phone") log.Println(log.WarningLog, "recive stop cmd from phone")
SendSCmd(SCMD_MusicPlayer_Stop)
dlnaTrigStop() dlnaTrigStop()
player.DlnaPlaySeek = false player.DlnaPlaySeek = false
player.ClearProjectorVolProcess() player.ClearProjectorVolProcess()
player.SetDlnaPlayPauseState(false) player.SetDlnaPlayPauseState(false)
// prd reverse : 20180322 // prd reverse : 20180322
//player.SoundEffectPlayCmd(CMD_SE_PLAY, SoundNotice_Slianjiechenggong001.GetPath()) //player.SoundEffectPlayCmd(CMD_SE_PLAY, SoundNotice_Slianjiechenggong001.GetPath())
SendSCmd(SCMD_MusicPlayer_Stop)
eventPoint.DeviceDisconEvent(eventPoint.ModelValDlna) eventPoint.DeviceDisconEvent(eventPoint.ModelValDlna)
case CMD_KPLAYER_CTR_SEEK: case CMD_KPLAYER_CTR_SEEK:
if GetCurPlayerId() != PlayerType_Dlna { if GetCurPlayerId() != PlayerType_Dlna {
@ -128,6 +128,7 @@ func DlnaCmdProcess(cmdid uint32, msg string) {
hasSetUrl = true hasSetUrl = true
hasPostUrl = true hasPostUrl = true
} }
player.DlnaPlaySeek = false
case CMD_KPLAYER_CTR_CTREATED: case CMD_KPLAYER_CTR_CTREATED:
player.GetSystemVolPer() player.GetSystemVolPer()
log.Println(log.DebugLog, "dlna has on") log.Println(log.DebugLog, "dlna has on")

View File

@ -19,6 +19,8 @@ import (
"netease_control_center/utils/godbus/dbus" "netease_control_center/utils/godbus/dbus"
"strconv" "strconv"
"time" "time"
"netease_control_center/modules/hardware/led_mcu"
"netease_control_center/modules/hardware/mcu_leds/atservice"
) )
var ( var (
@ -310,7 +312,25 @@ func goapi(modId uint32, msgmsk uint32, sec uint32, usec uint32, buscmd uint32,
case uint32(C.CMD_YUNXIN_RECVMSG): case uint32(C.CMD_YUNXIN_RECVMSG):
log.Println(log.DebugLog, "Recv yunxin msg:", string(data)) log.Println(log.DebugLog, "Recv yunxin msg:", string(data))
AppSuccessCommand(&data, msglen) var tmp YunxinAPPMsg
tmp.Content.OfflineStatus = OffLineStatus_Offline
if err := json.Unmarshal(data, &tmp); err == nil {
log.Printf(log.DebugLog, "Msg time:%+v\n", time.Time(tmp.Content.TimeStampM))
if tmp.Content.OfflineStatus == OffLineStatus_Online && time.Now().Sub(time.Time(tmp.Content.TimeStampM)) >= 10 * time.Second {
log.Printf(log.ErrorLog, "Time out, do not deal the msg, msg time:%+v!\n", time.Time(tmp.Content.TimeStampM))
return nil
}
if tmp.Content.OfflineStatus == OffLineStatus_Online && time.Time(tmp.Content.TimeStampM).Before(FirstCalTime) {
log.Printf(log.ErrorLog, "Msg's time(%+v) is before first cal time(%+v), do nothing!\n", time.Time(tmp.Content.TimeStampM), FirstCalTime)
return nil
}
appDataFormat := []byte(tmp.Content.MsgBody)
AppSuccessCommand(&appDataFormat, uint32(len(appDataFormat)))
} else {
log.Println(log.ErrorLog, "Decode yunxin msg err!", err)
}
case uint32(C.CMD_YUNXIN_SYSMSG): case uint32(C.CMD_YUNXIN_SYSMSG):
DbusYunxinSysMsgControl(data) DbusYunxinSysMsgControl(data)
@ -416,7 +436,7 @@ func _sigProcess(sig *dbus.Signal) {
if err := json.Unmarshal([]byte(buf), &tmp); err == nil { if err := json.Unmarshal([]byte(buf), &tmp); err == nil {
if CurBootState == BootStage_WIFIPARING || IsInBackupSystem() { if CurBootState == BootStage_WIFIPARING || IsInBackupSystem() {
log.Println(log.DebugLog, "In wifi paring, tell wifi module") log.Println(log.DebugLog, "In wifi paring, tell wifi module")
if bytedata, err := base64.StdEncoding.DecodeString(tmp.Pwd); err == nil && string(bytedata) == "pvt@20180529" { if bytedata, err := base64.StdEncoding.DecodeString(tmp.Pwd); err == nil && string(bytedata) == "mp@20180911" {
log.Println(log.DebugLog, "Turn on adb!") log.Println(log.DebugLog, "Turn on adb!")
ADBControl(true) ADBControl(true)
SendBleStatus(APPInitStatus_PARING_NOT_RESPONSE) SendBleStatus(APPInitStatus_PARING_NOT_RESPONSE)
@ -469,6 +489,11 @@ func _sigProcess(sig *dbus.Signal) {
default: default:
if buf, bufok := sig.Body[3].(string); bufok { if buf, bufok := sig.Body[3].(string); bufok {
if buscmd == uint32(C.CMD_BT_AVK_RC_PLAY) {
BtAvkDataRecving = true
}else if buscmd == uint32(C.CMD_BT_AVK_SOUND_STOP_EVT) || buscmd == uint32(C.CMD_BT_AVK_DISC_EVT) {
BtAvkDataRecving = false
}
BtMsgProcess(buscmd, buf) BtMsgProcess(buscmd, buf)
} else { } else {
log.Printf(log.DebugLog, "invalid msg.cmd:0x%x", buscmd) log.Printf(log.DebugLog, "invalid msg.cmd:0x%x", buscmd)
@ -480,6 +505,17 @@ func _sigProcess(sig *dbus.Signal) {
} }
buscmd := sig.Body[2].(uint32) buscmd := sig.Body[2].(uint32)
switch buscmd { switch buscmd {
case uint32(C.CMD_WIFI_ON_RESP):
SoundEffectPlayCmd(CMD_SE_PLAY, vui.SoundNotice_Slianjiechenggong001.GetPath())
led_mcu.DirectLedClear(atservice.GUIDE_EFFECT_ID_NET_MODE)
WifiSwitch = WifiSwitch_On
RequestWifiAutoConnect(true)
case uint32(C.CMD_WIFI_OFF_RESP):
SoundEffectPlayCmd(CMD_SE_PLAY, vui.SoundNotice_Slianjiechenggong001.GetPath())
led_mcu.DirectLedClear(atservice.GUIDE_EFFECT_ID_NET_MODE)
WifiSwitch = WifiSwitch_Off
case uint32(C.CMD_WIFI_AUTO_CONN_OUT): case uint32(C.CMD_WIFI_AUTO_CONN_OUT):
IsWifiAutoConnecting = false IsWifiAutoConnecting = false
SRevent.BroadCastSRevent(SRevent.SRevent_type_AutoConnectEnd) SRevent.BroadCastSRevent(SRevent.SRevent_type_AutoConnectEnd)

View File

@ -544,62 +544,6 @@ func systemService_exec(canExec bool, scmd SCMD, arg ...interface{}) {
if tmp := GetOtaSource(); tmp.IsSilent() == true { if tmp := GetOtaSource(); tmp.IsSilent() == true {
atservice.LampIsShowWhenReset(atservice.MCU_LAMP_INIT_NOT_SHOW, nil) atservice.LampIsShowWhenReset(atservice.MCU_LAMP_INIT_NOT_SHOW, nil)
} }
case SCMD_SuperTask_System_WifiParing:
if CurOTAStatus == OTAStatus_begin || CurBootState < BootStage_BASEINIT {
log.Println(log.DebugLog, "Can not paring wifi, because ota or init system!")
return
}
if IsInBackupSystem() {
if CurBootState == BootStage_BACKUPSYSTEM_WIFIPARING {
log.Println(log.DebugLog, "Jump into backup system, curboot: ", CurBootState)
StartBoard(BootStage_BACKUPSYSTEM, true)
} else {
log.Println(log.DebugLog, "Jump into backup system wifiparing, curboot: ", CurBootState)
StartBoard(BootStage_BACKUPSYSTEM_WIFIPARING, true)
}
} else {
if CurBootState == BootStage_WIFIPARING {
if IsNewBoard() {
log.Println(log.DebugLog, "This is a new board, and current in wifi paring, do nothing!")
schedule.PlayNoticeAsync(AdSrcType_FILE, SoundNotice_Alianwang002.GetPath(), CONST_AUDIO_ID, false, nil, nil)
//StartBoard(BootStage_WIFIPARING, true)
} else {
log.Println(log.DebugLog, "Current in wifi paring mode, jump check wifi and exit!")
PlayNoticeAsync(AdSrcType_FILE, SoundNotice_Alianwang011.GetPath(), CONST_AUDIO_ID, false, nil, nil)
StartBoard(BootStage_BEFOREDONE, true)
}
} else {
log.Println(log.DebugLog, "Will jump into wifi paring by key triging in normal system!")
CurWifiParingMode = WifiParingMode_BT
StartBoard(BootStage_WIFIPARING, false)
eventPoint.EpRecord("B211", map[string]interface{}{"type": CurWifiParingMode.String(), "net": false})
}
}
case SCMD_SuperTask_System_WifiModeChange_AP_BT:
switch CurBootState {
case BootStage_WIFIPARING:
log.Println(log.DebugLog, "jump into wifi ap paring in normal system!")
if CurWifiParingMode == WifiParingMode_AP {
CurWifiParingMode = WifiParingMode_BT
} else {
CurWifiParingMode = WifiParingMode_AP
}
StartBoard(BootStage_WIFIPARING, true)
eventPoint.EpRecord("B211", map[string]interface{}{"type": CurWifiParingMode.String(), "net": false})
case BootStage_BACKUPSYSTEM_WIFIPARING:
log.Println(log.DebugLog, "jump into wifi ap paring in backup system!")
if CurWifiParingMode == WifiParingMode_AP {
CurWifiParingMode = WifiParingMode_BT
} else {
CurWifiParingMode = WifiParingMode_AP
}
StartBoard(BootStage_BACKUPSYSTEM_WIFIPARING, true)
default:
log.Println(log.DebugLog, "not in wifi paring, do nothing!")
}
} }
} }
@ -616,7 +560,7 @@ func systemServiceTaskRegiste() {
} }
tmp.IsActive = func() bool { tmp.IsActive = func() bool {
return (len(bootBoardChan) > 0 || (CurBootState != BootStage_FINISH && CurBootState != BootStage_BEFOREDONE) || CurOTAStatus == OTAStatus_begin) return (CurBootState != BootStage_FINISH && CurBootState != BootStage_BEFOREDONE && CurBootState != BootStage_WIFIPARING) || CurOTAStatus == OTAStatus_begin
} }
tmp.GetTaskLevel = func() TaskLevel { tmp.GetTaskLevel = func() TaskLevel {
@ -629,9 +573,7 @@ func systemServiceTaskRegiste() {
tmp.GetSupportedSCmd = func() []SCMD { tmp.GetSupportedSCmd = func() []SCMD {
return []SCMD{SCMD_SuperTask_System_BeginInit, return []SCMD{SCMD_SuperTask_System_BeginInit,
SCMD_SuperTask_System_BeginOta, SCMD_SuperTask_System_BeginOta}
SCMD_SuperTask_System_WifiParing,
SCMD_SuperTask_System_WifiModeChange_AP_BT}
} }
tmp.Do = systemService_exec tmp.Do = systemService_exec
@ -675,6 +617,7 @@ func systemServiceTaskRegiste() {
tmp += fmt.Sprintln(" Device mode:", getCurDeviceMode(true)) tmp += fmt.Sprintln(" Device mode:", getCurDeviceMode(true))
vol, volerr := adau1761.GetVol() vol, volerr := adau1761.GetVol()
tmp += fmt.Sprintln(" Volume:", vol, volerr) tmp += fmt.Sprintln(" Volume:", vol, volerr)
tmp += fmt.Sprintln(" FirstCalTime:", FirstCalTime)
tmp += fmt.Sprintln(" CurTime:", time.Now().Local()) tmp += fmt.Sprintln(" CurTime:", time.Now().Local())
tmp += fmt.Sprintln(" PingTime:", DevNetworkStatus.Time) tmp += fmt.Sprintln(" PingTime:", DevNetworkStatus.Time)
tmp += fmt.Sprintln(" Global cfg list:", GetGlobalCfgList()) tmp += fmt.Sprintln(" Global cfg list:", GetGlobalCfgList())

View File

@ -1,5 +1,8 @@
package controller package controller
/*
#include <uvdbus/smart_sound.h>
*/
import "C"
import ( import (
"context" "context"
"fmt" "fmt"
@ -106,6 +109,10 @@ func KeyResponse(keycode int, pressedTimes uint8, longpress bool, insistTime tim
return return
} }
if globals.WifiSwitch != globals.WifiSwitch_On {
schedule.SendSCmd(schedule.SCMD_SuperTask_Exit_btOnWifiOff)
return
}
//wifi paring //wifi paring
schedule.SendSCmd(schedule.SCMD_SuperTask_System_WifiParing) schedule.SendSCmd(schedule.SCMD_SuperTask_System_WifiParing)
eventPoint.EpRecord("H411", map[string]interface{}{"pressedTimes": pressedTimes, "status": "wifi paring", "pressedtime": insistTime.Nanoseconds() / 1e6, "net": (globals.CurBootState == globals.BootStage_WIFIPARING), "longpress": longpress}) eventPoint.EpRecord("H411", map[string]interface{}{"pressedTimes": pressedTimes, "status": "wifi paring", "pressedtime": insistTime.Nanoseconds() / 1e6, "net": (globals.CurBootState == globals.BootStage_WIFIPARING), "longpress": longpress})
@ -169,6 +176,33 @@ func KeyResponse(keycode int, pressedTimes uint8, longpress bool, insistTime tim
CopyLogfiles() CopyLogfiles()
//schedule.PlayNoticeAsync(globals.AdSrcType_TTS, "日志已保存", globals.CONST_AUDIO_ID, false, nil, nil) //schedule.PlayNoticeAsync(globals.AdSrcType_TTS, "日志已保存", globals.CONST_AUDIO_ID, false, nil, nil)
case 4: case 4:
//if schedule.GetCurScheduleDomain().IsMusicDomain() == false {
// log.Println(log.DebugLog, "Not in music mode, do nothing!")
// return
//}
////wifi switch
//switch globals.WifiSwitch {
//case globals.WifiSwitch_On:
// log.Println(log.DebugLog, "Turn off wifi")
// globals.WifiSwitch = globals.WifiSwitch_Offing
// SendWifiCmd(uint32(C.CMD_WIFI_OFF))
// SetInternetConnect(false, "user force")
// player.SoundEffectPlayCmd(globals.CMD_SE_PLAY, vui.SoundNotice_Exit_BtOnWifiOff.GetPath())
//
//case globals.WifiSwitch_Off:
// log.Println(log.DebugLog, "Turn on wifi")
// globals.WifiSwitch = globals.WifiSwitch_Oning
// SendWifiCmd(uint32(C.CMD_WIFI_ON))
// player.SoundEffectPlayCmd(globals.CMD_SE_PLAY, vui.SoundNotice_Enter_BtOnWifiOff.GetPath())
//
//case globals.WifiSwitch_Oning:
// log.Println(log.DebugLog, "Wifi is oning!")
// player.SoundEffectPlayCmd(globals.CMD_SE_PLAY, vui.SoundNotice_Enter_BtOnWifiOff.GetPath())
//
//case globals.WifiSwitch_Offing:
// log.Println(log.DebugLog, "Wifi is offing!")
// player.SoundEffectPlayCmd(globals.CMD_SE_PLAY, vui.SoundNotice_Exit_BtOnWifiOff.GetPath())
//}
//player.TestInterfaceForKey(player.HOT_TOP_TYPE) //player.TestInterfaceForKey(player.HOT_TOP_TYPE)
case 5: case 5:
//player.TestInterfaceForKey(player.CREATE_LISTS_TYPE) //player.TestInterfaceForKey(player.CREATE_LISTS_TYPE)
@ -265,7 +299,7 @@ func TriggerKey(keycode int, isPress bool) {
} }
func KeyApp() error { func KeyApp() error {
dev, err := evdev.Open(globals.GetCurPlatformConfig().InputKeyPath) dev, err := evdev.Open(devpath)
if err != nil { if err != nil {
return err return err
} }

View File

@ -48,7 +48,7 @@ func MscToastFinish(arg TtsPlayerArg) {
//检查是否网络缓存播放失败 //检查是否网络缓存播放失败
if arg.StopReason == NoticeStopReason_Error { if arg.StopReason == NoticeStopReason_Error {
go MscToastFile(vui.SoundNotice_Song_Get_Timeout.GetPath(), CONST_AUDIO_ID, false, false, nil) go MscToastFile(vui.SoundNotice_Song_Get_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
} }
} }
@ -69,7 +69,7 @@ func volChangeCb(params *NoticePlayerParams) {
//检查是否网络缓存播放失败 //检查是否网络缓存播放失败
if arg.StopReason == NoticeStopReason_Error { if arg.StopReason == NoticeStopReason_Error {
go MscToastFile(vui.SoundNotice_Song_Get_Timeout.GetPath(), CONST_AUDIO_ID, false, false, nil) go MscToastFile(vui.SoundNotice_Song_Get_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
} }
} }
} }
@ -127,7 +127,7 @@ func MscToast(adsrc AdSrcType, tts string, RespId string, needRepeat bool, keep
tmpconfig.IconIn = vui.IconLed_DoNothing tmpconfig.IconIn = vui.IconLed_DoNothing
tmpconfig.IconOut = vui.IconLed_DoNothing tmpconfig.IconOut = vui.IconLed_DoNothing
tmpconfig.BeforeExecFunc = MscToastLed_Before tmpconfig.BeforeSpecialFunc = MscToastLed_Before
tmpconfig.SpecialFunc = MscToastFinish tmpconfig.SpecialFunc = MscToastFinish
if configChange != nil { if configChange != nil {
@ -199,6 +199,9 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) {
case MSC_CMD_IOTWIFIPARING: case MSC_CMD_IOTWIFIPARING:
SendSCmd(SCMD_SuperTask_Enter_IOT_WifiParing) SendSCmd(SCMD_SuperTask_Enter_IOT_WifiParing)
case MSC_CMD_BTONWIFIOFF:
SendSCmd(SCMD_SuperTask_Enter_btOnWifiOff)
case MSC_CMD_CHAT: case MSC_CMD_CHAT:
if isMute() { if isMute() {
return return
@ -427,11 +430,10 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) {
case GetScenePlayerId(), PlayerType_Wifi, PlayerType_Bt, PlayerType_Airplay: case GetScenePlayerId(), PlayerType_Wifi, PlayerType_Bt, PlayerType_Airplay:
if retData.Desc == MSC_CMD_ONE_SHOT_WAKEUP { if retData.Desc == MSC_CMD_ONE_SHOT_WAKEUP {
log.Println(log.DebugLog, "one shot cmd for next song by wakeup") log.Println(log.DebugLog, "one shot cmd for next song by wakeup")
http.InformLocalMsgToServer(http.Type_Inform_TtsPush, int(MSC_CMD_NEXT), "下一首", "下一首") //上传信息流
} }
case PlayerType_Dlna: case PlayerType_Dlna:
MscToastTts(TTS_NOT_UNSUPPORT, retData.RspId, true, false, nil) /*MscToastTts(TTS_NOT_UNSUPPORT, retData.RspId, true, false, nil) //lupeng 20190908 #PV1-4216
if retData.Desc == MSC_CMD_ONE_SHOT_WAKEUP { if retData.Desc == MSC_CMD_ONE_SHOT_WAKEUP {
log.Println(log.WarningLog, "can not use one shot cmd ", TTS_NOT_UNSUPPORT) log.Println(log.WarningLog, "can not use one shot cmd ", TTS_NOT_UNSUPPORT)
@ -439,7 +441,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) {
} else { } else {
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: retData.RspId, Cmd: retData.Cmd, Data: TTS_NOT_UNSUPPORT, Tts: TTS_NOT_UNSUPPORT, http.PushInfoToServerForApp(http.InfoForApp{ResponseId: retData.RspId, Cmd: retData.Cmd, Data: TTS_NOT_UNSUPPORT, Tts: TTS_NOT_UNSUPPORT,
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING}) PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING})
} }*/
return return
default: default:
@ -451,14 +453,13 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) {
case GetScenePlayerId(), PlayerType_Wifi, PlayerType_Bt, PlayerType_Airplay: case GetScenePlayerId(), PlayerType_Wifi, PlayerType_Bt, PlayerType_Airplay:
if retData.Desc == MSC_CMD_ONE_SHOT || retData.Desc == MSC_CMD_ONE_SHOT_WAKEUP { if retData.Desc == MSC_CMD_ONE_SHOT || retData.Desc == MSC_CMD_ONE_SHOT_WAKEUP {
log.Println(log.DebugLog, "one shot cmd for next song") log.Println(log.DebugLog, "one shot cmd for next song")
go http.InformLocalMsgToServer(http.Type_Inform_TtsPush, int(MSC_CMD_NEXT), "下一首", "下一首") //上传信息流
/*播放反馈声音prd暂时不需要 /*播放反馈声音prd暂时不需要
PlayNoticeAsync(AdSrcType_FILE, vui.SoundNotice_Shuanxing001.GetPath(), WAKEUP_AUDIO_ID, false, nil, func(id uint32, reason NoticeStopReason) { PlayNoticeAsync(AdSrcType_FILE, vui.SoundNotice_Shuanxing001.GetPath(), WAKEUP_AUDIO_ID, false, nil, func(id uint32, reason NoticeStopReason) {
log.Println(log.WarningLog, "one shot cmd audio sound end") log.Println(log.WarningLog, "one shot cmd audio sound end")
})*/ })*/
} }
case PlayerType_Dlna: case PlayerType_Dlna:
MscToastTts(TTS_NOT_UNSUPPORT, retData.RspId, true, false, nil) /*MscToastTts(TTS_NOT_UNSUPPORT, retData.RspId, true, false, nil) //lupeng 20190908 #PV1-4216
if retData.Desc == MSC_CMD_ONE_SHOT || retData.Desc == MSC_CMD_ONE_SHOT_WAKEUP { if retData.Desc == MSC_CMD_ONE_SHOT || retData.Desc == MSC_CMD_ONE_SHOT_WAKEUP {
log.Println(log.WarningLog, "can not use one shot cmd ", TTS_NOT_UNSUPPORT) log.Println(log.WarningLog, "can not use one shot cmd ", TTS_NOT_UNSUPPORT)
@ -466,7 +467,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) {
} else { } else {
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: retData.RspId, Cmd: retData.Cmd, Data: TTS_NOT_UNSUPPORT, Tts: TTS_NOT_UNSUPPORT, http.PushInfoToServerForApp(http.InfoForApp{ResponseId: retData.RspId, Cmd: retData.Cmd, Data: TTS_NOT_UNSUPPORT, Tts: TTS_NOT_UNSUPPORT,
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING}) PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING})
} }*/
return return
default: default:
log.Println(log.ErrorLog, "err playerId:", GetCurPlayerId()) log.Println(log.ErrorLog, "err playerId:", GetCurPlayerId())
@ -484,7 +485,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) {
switch Cmd(retData.Cmd) { switch Cmd(retData.Cmd) {
case MSC_CMD_NEXT: case MSC_CMD_NEXT:
//自然声快捷命令下一首需要音箱端主动去服务器拉取 //自然声快捷命令下一首需要音箱端主动去服务器拉取
if PlayListSrcRec.BizType == BIZ_TYPE_NATURAL_SOUND { if PlayerType_Wifi == GetCurPlayerId() && PlayListSrcRec.BizType == BIZ_TYPE_NATURAL_SOUND {
log.Println(log.DebugLog, "one shot cmd for next natural sound, so get next from server") log.Println(log.DebugLog, "one shot cmd for next natural sound, so get next from server")
// 拉取新的自然声 // 拉取新的自然声
serverListParams := http.MusicListServerType{ serverListParams := http.MusicListServerType{
@ -513,6 +514,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) {
list.RspId = list.RspId list.RspId = list.RspId
SetPlayerArgs(PlayerType_Wifi, list) SetPlayerArgs(PlayerType_Wifi, list)
player.PlayerHander[PlayerType_Wifi].RequestPlay_Async(nil) player.PlayerHander[PlayerType_Wifi].RequestPlay_Async(nil)
go http.InformLocalMsgToServer(http.Type_Inform_TtsPush, int(MSC_CMD_NEXT), TTS_MUSIC_NEXT, TTS_MUSIC_NEXT) //上传信息流
} }
} else { } else {
RspId = &retData.RspId RspId = &retData.RspId
@ -565,7 +567,33 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) {
player.PlayerHander[PlayerType_Wifi].RequestPlay_Async(nil) player.PlayerHander[PlayerType_Wifi].RequestPlay_Async(nil)
} }
case Pause_mode, Exec_MusicPlay_mode, Exec_Non_Music_Played_mode: case Pause_mode, Exec_MusicPlay_mode, Exec_Non_Music_Played_mode:
SendSCmd(SCMD_MusicPlayer_Play, nil) if CurPlayingMode == LIST_ORDER_PLAY && PlayListSrcRec.ListHasEnd == true {
var continuePlayTts string
if PlayListSrcRec.BizType == BIZ_TYPE_MUSIC {
continuePlayTts = TTS_TEXT_MUSIC_END
} else {
continuePlayTts = TTS_TEXT_RADIO_END
}
MscToastTts(continuePlayTts, retData.RspId, true, false, func(params *NoticePlayerParams) {
specialFuncBackup := params.SpecialFunc
params.SpecialFunc = func(arg TtsPlayerArg) {
specialFuncBackup(arg)
//电台模式下,继续播放最后一个节目
if PlayListSrcRec.BizType != BIZ_TYPE_MUSIC {
SendSCmd(SCMD_MusicPlayer_Play, nil)
} else {
SendSCmd(SCMD_MusicPlayer_Pause, PlayerArg{GloablePause: false, NotShowIcon: true})
}
//检查是否网络缓存播放失败
if arg.StopReason == NoticeStopReason_Error {
go MscToastFile(vui.SoundNotice_Song_Get_Timeout.GetPath(), CONST_AUDIO_ID, false, false, nil)
}
}
})
} else {
SendSCmd(SCMD_MusicPlayer_Play, nil)
}
} }
case MSC_CMD_PLAY_MUSIC: case MSC_CMD_PLAY_MUSIC:
var tmp struct { var tmp struct {
@ -702,7 +730,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) {
}) })
} }
case MSC_CMD_CYCLE_LIST, MSC_CMD_CYCLE_RANDOM, MSC_CMD_CYCLE_ONE_SONG: case MSC_CMD_CYCLE_LIST, MSC_CMD_CYCLE_RANDOM, MSC_CMD_CYCLE_ONE_SONG, MSC_CMD_ORDER_PLAY:
// prd reverse : 20180316 // prd reverse : 20180316
mode := getCurDeviceMode(true) mode := getCurDeviceMode(true)
switch mode { switch mode {
@ -728,6 +756,12 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) {
ResetUnPlayListCurNode() ResetUnPlayListCurNode()
} }
CurPlayingMode = LIST_ORDER_CYCLE CurPlayingMode = LIST_ORDER_CYCLE
case MSC_CMD_ORDER_PLAY:
// 切换到顺序播放时,如果当前是单曲循环,不需要处理
if LIST_RANDOM_CYCLE == CurPlayingMode {
ResetUnPlayListCurNode()
}
CurPlayingMode = LIST_ORDER_PLAY
case MSC_CMD_CYCLE_RANDOM: case MSC_CMD_CYCLE_RANDOM:
if LIST_ORDER_CYCLE == CurPlayingMode || SINGLE_CYCLE == CurPlayingMode { if LIST_ORDER_CYCLE == CurPlayingMode || SINGLE_CYCLE == CurPlayingMode {
ResetUnPlayListCurNode() ResetUnPlayListCurNode()
@ -741,6 +775,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) {
CurPlayingMode = SINGLE_CYCLE CurPlayingMode = SINGLE_CYCLE
} }
log.Println(log.DebugLog, "Change playmode:", CurPlayingMode) log.Println(log.DebugLog, "Change playmode:", CurPlayingMode)
playModeBroadCast(CurPlayingMode)
var tmp ServerDetailBase var tmp ServerDetailBase
err := json.Unmarshal([]byte(retData.Detail), &tmp) err := json.Unmarshal([]byte(retData.Detail), &tmp)
if nil != err { if nil != err {
@ -1272,7 +1307,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) {
ttsRepeatInfo := GetTtsRepeatInfo() ttsRepeatInfo := GetTtsRepeatInfo()
if ttsRepeatInfo.HasSetTtsInfo { if ttsRepeatInfo.HasSetTtsInfo {
if time.Now().Sub(ttsRepeatInfo.TimePlay) >= RepeatCmdDurtion.GetCfgListTime() { if time.Now().Sub(ttsRepeatInfo.TimePlay) >= RepeatCmdDurtion.GetCfgListTime() {
log.Println(log.WarningLog, "time is out") log.Printf(log.WarningLog, "tts repeat time is out, content:%+v, time:%+v\n", ttsRepeatInfo.Tts, ttsRepeatInfo.TimePlay)
ClearTtsRepeatInfo() ClearTtsRepeatInfo()
MscToastTts(TTS_REPEAT_NIL, retData.RspId, false, false, nil) MscToastTts(TTS_REPEAT_NIL, retData.RspId, false, false, nil)
@ -1329,6 +1364,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) {
status.CurPos = 0 status.CurPos = 0
log.Println(log.DebugLog, "MSC_CMD_REPEAT_MUSIC set CurPos to 0") log.Println(log.DebugLog, "MSC_CMD_REPEAT_MUSIC set CurPos to 0")
curPlayer.SetPlayerStatus(status) curPlayer.SetPlayerStatus(status)
SendSCmd(SCMD_MusicPlayer_Seek, uint32(status.CurPos))
} else { } else {
eventPoint.SetEpOsSouce("F141", eventPoint.EpOs_Server) eventPoint.SetEpOsSouce("F141", eventPoint.EpOs_Server)
if time.Now().Sub(curPlayer.GetLastPasusedTime()) >= RepeatCmdDurtion.GetCfgListTime() { if time.Now().Sub(curPlayer.GetLastPasusedTime()) >= RepeatCmdDurtion.GetCfgListTime() {
@ -1389,12 +1425,11 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) {
} }
log.Printf(log.DebugLog, "Detail:%+v tmp:%+v\n", retData.Detail, tmp) log.Printf(log.DebugLog, "Detail:%+v tmp:%+v\n", retData.Detail, tmp)
SendSCmd(SCMD_MusicPlayer_Pause, PlayerArg{NotShowIcon: true})
ResetWifiPlayer()
SendSCmdStruct(SCmdStruct{SCmd: SCMD_MusicPlayer_Pause, Arg: []interface{}{PlayerArg{NotShowIcon: true}}, ExecCb: func(cb SCmdStructExecCb) { SendSCmdStruct(SCmdStruct{SCmd: SCMD_MusicPlayer_Pause, Arg: []interface{}{PlayerArg{NotShowIcon: true}}, ExecCb: func(cb SCmdStructExecCb) {
tmp := GetCurVboxBroadcastSt(false) tmp := GetCurVboxBroadcastSt(false)
tmp.PlayerStPtr.ContinuousTaskSt = MUSIC_ST_PAUSED tmp.PlayerStPtr.ContinuousTaskSt = MUSIC_ST_IDLE
TrigBroadcastStatus(tmp) TrigBroadcastStatus(tmp)
ResetWifiPlayer()
}}) }})
if len(tmp.Tts2) > 0 { if len(tmp.Tts2) > 0 {
@ -1404,6 +1439,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) {
} }
default: default:
log.Printf(log.ErrorLog, "Unknow the cmd %d\n", retData.Cmd) log.Printf(log.ErrorLog, "Unknow the cmd %d\n", retData.Cmd)
MscToastTts(TTS_NOT_UNSUPPORT, retData.RspId, true, false, nil)
} }
return return
@ -1496,6 +1532,7 @@ func AppSuccessCommand(msg *[]byte, msglen uint32) {
case APP_CMD_MUSIC_CONTINUE: case APP_CMD_MUSIC_CONTINUE:
RestoreDefaultVolWhen0() RestoreDefaultVolWhen0()
eventPoint.SetEpOsSouce("F141", eventPoint.EpOs_App) eventPoint.SetEpOsSouce("F141", eventPoint.EpOs_App)
PlayListSrcRec.ListHasEnd = false //歌单播放结束标志位false
SendSCmd(SCMD_MusicPlayer_Play) SendSCmd(SCMD_MusicPlayer_Play)
case APP_CMD_MUSIC_PAUSE: case APP_CMD_MUSIC_PAUSE:
eventPoint.SetEpOsSouce("F141", eventPoint.EpOs_App) eventPoint.SetEpOsSouce("F141", eventPoint.EpOs_App)
@ -1519,6 +1556,7 @@ func AppSuccessCommand(msg *[]byte, msglen uint32) {
SendSCmd(SCMD_MusicPlayer_Pause, PlayerArg{NotShowIcon: true}) SendSCmd(SCMD_MusicPlayer_Pause, PlayerArg{NotShowIcon: true})
} }
PlayListSrcRec.ListHasEnd = false //歌单播放结束标志位false
base := ServerPlayerBase{Action: MUSIC_ACTION_PREV, ActionSrc: MUSIC_ACTION_SRC_APP} base := ServerPlayerBase{Action: MUSIC_ACTION_PREV, ActionSrc: MUSIC_ACTION_SRC_APP}
SendSCmd(SCMD_MusicPlayer_PlayPre, PlayerArg{GloablePause: false, NotShowIcon: false, SendSCmd(SCMD_MusicPlayer_PlayPre, PlayerArg{GloablePause: false, NotShowIcon: false,
ServerPlayerBase: base}) ServerPlayerBase: base})
@ -1760,6 +1798,7 @@ func AppSuccessCommand(msg *[]byte, msglen uint32) {
default: default:
log.Println(log.ErrorLog, "Unknow app msg:", string(*msg)) log.Println(log.ErrorLog, "Unknow app msg:", string(*msg))
MscToastTts(TTS_NOT_UNSUPPORT, CONST_AUDIO_ID, true, false, nil)
} }
} }
@ -1835,14 +1874,14 @@ func createVboxChangeMusicLists(params VboxChangeInfo) *ServerMusicLists {
list, err := GetMusicListsNew(PlayerType_Wifi, true, serverListParams) list, err := GetMusicListsNew(PlayerType_Wifi, true, serverListParams)
if nil != err { if nil != err {
log.Println(log.ErrorLog, err.Error()) log.Println(log.ErrorLog, err.Error())
MscToastTts(err.Error(), CONST_AUDIO_ID, true, false, nil) MscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
return nil return nil
} }
if nil == list || nil == list.MusicLists || 0 == len(list.MusicLists) || if nil == list || nil == list.MusicLists || 0 == len(list.MusicLists) ||
nil == list.MusicLists[0].SongList { nil == list.MusicLists[0].SongList {
log.Println(log.ErrorLog, "err list from server") log.Println(log.ErrorLog, "err list from server")
MscToastTts(Server_ERR_RET.Error(), CONST_AUDIO_ID, true, false, nil) MscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
return nil return nil
} }
@ -1906,7 +1945,7 @@ func createVboxChangeMusicLists(params VboxChangeInfo) *ServerMusicLists {
songDetail, err := player.GetSongDetail(PlayerType_Wifi, &params.SongId, true) songDetail, err := player.GetSongDetail(PlayerType_Wifi, &params.SongId, true)
if nil != err { if nil != err {
log.Println(log.ErrorLog, err.Error()) log.Println(log.ErrorLog, err.Error())
MscToastTts(err.Error(), CONST_AUDIO_ID, true, false, nil) MscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
return nil return nil
} }
tmp.MusicLists[0].Url = songDetail.Song.Url tmp.MusicLists[0].Url = songDetail.Song.Url
@ -2012,12 +2051,12 @@ func createVboxChangeMusicList(params VboxChangeInfo) *ServerMusicList {
if nil != err { if nil != err {
log.Println(log.ErrorLog, err.Error()) log.Println(log.ErrorLog, err.Error())
MscToastTts(err.Error(), CONST_AUDIO_ID, true, false, nil) MscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
return nil return nil
} }
if nil == list || nil == list.MusicList.SongList { if nil == list || nil == list.MusicList.SongList {
log.Println(log.ErrorLog, "err list from server") log.Println(log.ErrorLog, "err list from server")
MscToastTts(Server_ERR_RET.Error(), CONST_AUDIO_ID, true, false, nil) MscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
return nil return nil
} }
tmp.ExtraData = list.ExtraData tmp.ExtraData = list.ExtraData
@ -2101,7 +2140,7 @@ func createVboxChangeMusicList(params VboxChangeInfo) *ServerMusicList {
songDetail, err := player.GetSongDetail(PlayerType_Wifi, &params.SongId, true) songDetail, err := player.GetSongDetail(PlayerType_Wifi, &params.SongId, true)
if nil != err { if nil != err {
log.Println(log.ErrorLog, err.Error()) log.Println(log.ErrorLog, err.Error())
MscToastTts(err.Error(), CONST_AUDIO_ID, true, false, nil) MscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
return nil return nil
} }
tmp.MusicList.Url = songDetail.Song.Url tmp.MusicList.Url = songDetail.Song.Url
@ -2117,10 +2156,10 @@ func createVboxChangeMusicList(params VboxChangeInfo) *ServerMusicList {
NormalListMap[NORMAL_LIST_PAGE].BackIndex = 0 NormalListMap[NORMAL_LIST_PAGE].BackIndex = 0
} }
} else { } else {
PlayListSrcRec.BizType = OldBizType
NormalListMap[NORMAL_LIST_PAGE].BackIndex = 0 NormalListMap[NORMAL_LIST_PAGE].BackIndex = 0
} }
PlayListSrcRec.BizType = OldBizType
tmp.Action = MUSIC_ACTION_NEXT tmp.Action = MUSIC_ACTION_NEXT
tmp.ActionSrc = MUSIC_ACTION_SRC_APP tmp.ActionSrc = MUSIC_ACTION_SRC_APP
@ -2338,6 +2377,47 @@ func VboxChangeTestNaturalSound() {
AppSuccessCommand(&dataMsg, uint32(len(dataMsg))) AppSuccessCommand(&dataMsg, uint32(len(dataMsg)))
} }
func VboxTestdeny() {
log.Println(log.ErrorLog, "VboxChangeTest VboxTestdeny")
var tmp struct {
Cmd int `json:"cmd"`
Detail string `json:"detail"`
Code int `json:"code"`
}
var denyInfo DenyInfo = DenyInfo {
Data : []string{"8FFEC9AC75F29C61D3A2BBF51C36BD1C", "5ECC9314FBE04C64BC2C5C62173CFCF8"},//测试排除多个歌曲Id
Type : 1,
}
var denyData struct {
Data []DenyInfo `json:"data"`
Cmd int `json:"cmd"`
Tts string `json:"tts"`
}
denyData.Cmd = int(MSC_CMD_MUSIC_DENY)
denyData.Data = append(denyData.Data, denyInfo)
denyData.Tts = string("好的,为你播放下一首%s")
data, err := json.Marshal(denyData)
if nil != err {
log.Println(log.ErrorLog, err.Error())
return
}
tmp.Detail = string(data)
tmp.Cmd = int(MSC_CMD_MUSIC_DENY)
tmp.Code = 1000
dataMsg, err := json.Marshal(tmp)
if nil != err {
log.Println(log.ErrorLog, err.Error())
return
}
log.Println(log.ErrorLog, "datamsg:", string(dataMsg))
MscSuccessCommand(&dataMsg, uint32(len(dataMsg)))
}
func VboxChangeTestRadioStation() { func VboxChangeTestRadioStation() {
log.Println(log.ErrorLog, "VboxChangeTest VboxChangeTestRadioStation") log.Println(log.ErrorLog, "VboxChangeTest VboxChangeTestRadioStation")

View File

@ -579,6 +579,10 @@ _begin_connect_wifi:
SendBleStatus(APPInitStatus_SERVER_ARG_ERROR) SendBleStatus(APPInitStatus_SERVER_ARG_ERROR)
case ERR_BIND_ACCOUNT_BEYOND_MAX: case ERR_BIND_ACCOUNT_BEYOND_MAX:
SendBleStatus(APPInitStatus_BINDNUM_BEYOND_MAX) SendBleStatus(APPInitStatus_BINDNUM_BEYOND_MAX)
case ERR_DEVICE_BOUNDED:
SendBleStatus(APPInitStatus_SERVER_DEVICE_BOUNDED)
case ERR_ACCOUNT_BOUNDED:
SendBleStatus(APPInitStatus_SERVER_ACCOUNT_BOUNDED)
default: default:
SendBleStatus(APPInitStatus_REQUEST_SERVER_ERROR) SendBleStatus(APPInitStatus_REQUEST_SERVER_ERROR)
} }
@ -679,6 +683,9 @@ func DisableBT() {
} }
func RequestWifiAutoConnect(force bool) { func RequestWifiAutoConnect(force bool) {
if WifiSwitch != WifiSwitch_On {
return
}
go func() { go func() {
time.Sleep(500 * time.Millisecond) time.Sleep(500 * time.Millisecond)
if IsWifiAutoConnecting == false || force == true { if IsWifiAutoConnecting == false || force == true {
@ -691,9 +698,12 @@ func RequestWifiAutoConnect(force bool) {
} }
func RequestChangeWifi(force bool) { func RequestChangeWifi(force bool) {
if WifiSwitch != WifiSwitch_On {
return
}
go func() { go func() {
time.Sleep(500 * time.Millisecond) time.Sleep(500 * time.Millisecond)
if IsWifiChanging == false { if IsWifiChanging == false || force == true {
SendWifiCmd(uint32(C.CMD_WIFI_CHANGE_VALID_AP)) SendWifiCmd(uint32(C.CMD_WIFI_CHANGE_VALID_AP))
} else { } else {
log.Println(log.DebugLog, "Wifi is changing now, do not send cmd!") log.Println(log.DebugLog, "Wifi is changing now, do not send cmd!")
@ -886,9 +896,10 @@ func network_check_daemon() {
} }
}() }()
_AllStart: _AllStart:
//log.Println(log.DebugLog, "Begin Check Network!") //log.Println(log.DebugLog, "Begin Check Network!")
if CurBootState != BootStage_FINISH { if CurBootState != BootStage_FINISH || WifiSwitch != WifiSwitch_On {
//do nothing on boot //do nothing on boot
fmt.Println("Not in net check daemon, wifiswitch:", WifiSwitch)
return return
} }

View File

@ -31,6 +31,7 @@ import (
"os" "os"
"strconv" "strconv"
"time" "time"
"math/rand"
) )
var ( var (
@ -56,6 +57,8 @@ func otaEveryNightCheck() {
log.Println(log.DebugLog, "OTA TIME begin, begin to check ota in midnight! ota night times:", curNightOtaTimes) log.Println(log.DebugLog, "OTA TIME begin, begin to check ota in midnight! ota night times:", curNightOtaTimes)
SetNightOtaTimes(curNightOtaTimes) SetNightOtaTimes(curNightOtaTimes)
time.Sleep(time.Duration(rand.Intn(3600)) * time.Second)
for { for {
if time.Now().Local().Hour() >= globals.OTA_END_HOUR || time.Now().Local().Hour() < globals.OTA_BEGIN_HOUR { if time.Now().Local().Hour() >= globals.OTA_END_HOUR || time.Now().Local().Hour() < globals.OTA_BEGIN_HOUR {
log.Println(log.DebugLog, "Cur not in right time,exit!") log.Println(log.DebugLog, "Cur not in right time,exit!")

View File

@ -37,6 +37,7 @@ func SyncAfterNetworkConnect() {
cvui.UpdateResFromServer() cvui.UpdateResFromServer()
http.UpdateCfgList() http.UpdateCfgList()
customization.AfterInternetConnectCheckOem() customization.AfterInternetConnectCheckOem()
btOnWifiOffCheckFlag()
} }
func AccountChange() { func AccountChange() {

View File

@ -45,6 +45,9 @@ func DbusYunxinSysMsgControl(data []byte) {
eventPoint.EpRecord("A224", map[string]interface{}{"msgid": cmd.MsgId, "sourceos": eventPoint.EpOs_Server}) eventPoint.EpRecord("A224", map[string]interface{}{"msgid": cmd.MsgId, "sourceos": eventPoint.EpOs_Server})
switch cmd.CmdId { switch cmd.CmdId {
case YxSCmd_InBtOnWifiOff:
schedule.SendSCmd(schedule.SCMD_SuperTask_Enter_btOnWifiOff)
case YxSCmd_IotWifiParingResult: case YxSCmd_IotWifiParingResult:
var tmp struct { var tmp struct {
Tts string `json:"tts"` Tts string `json:"tts"`
@ -250,11 +253,12 @@ func DbusYunxinSysMsgControl(data []byte) {
case YxSCmd_ChangeAccountMode: case YxSCmd_ChangeAccountMode:
log.Println(log.DebugLog, "Change account mode!") log.Println(log.DebugLog, "Change account mode!")
player.ResetWifiPlayer()
schedule.SendSCmdStruct(schedule.SCmdStruct{SCmd: schedule.SCMD_MusicPlayer_Pause, Arg: []interface{}{schedule.PlayerArg{NotShowIcon: true}}, ExecCb: func(cb schedule.SCmdStructExecCb) { schedule.SendSCmdStruct(schedule.SCmdStruct{SCmd: schedule.SCMD_MusicPlayer_Pause, Arg: []interface{}{schedule.PlayerArg{NotShowIcon: true}}, ExecCb: func(cb schedule.SCmdStructExecCb) {
tmp := GetCurVboxBroadcastSt(false) tmp := GetCurVboxBroadcastSt(false)
tmp.PlayerStPtr.ContinuousTaskSt = MUSIC_ST_PAUSED tmp.PlayerStPtr.ContinuousTaskSt = MUSIC_ST_IDLE
TrigBroadcastStatus(tmp) TrigBroadcastStatus(tmp)
player.ResetWifiPlayer()
}}) }})
default: default:

View File

@ -0,0 +1,168 @@
package controller
/*
#include <uvdbus/smart_sound.h>
#include <uvdbus/ota.h>
*/
import "C"
import (
"netease_control_center/globals"
"netease_control_center/interfaces/log"
. "netease_control_center/interfaces/schedule"
"netease_control_center/interfaces/vui"
"netease_control_center/modules/hardware/led_mcu"
"netease_control_center/modules/hardware/mcu_leds/atservice"
"netease_control_center/modules/player"
"fmt"
"netease_control_center/interfaces/http"
)
const (
modename_btOnWifiOffwifiparing = "btOnWifiOff_service"
)
var (
btOnWifiOff_hd TaskHd
backupBtstatus bool
btOnWifiOffneedInform2server bool = false
)
func btOnWifiOff_Interrupt(ByWho string) {
log.Println(log.DebugLog, modename_btOnWifiOffwifiparing, " be interrupt by ", ByWho)
switch globals.WifiSwitch {
case globals.WifiSwitch_Oning:
log.Println(log.DebugLog, "Wifi is oning!")
globals.WifiSwitch = globals.WifiSwitch_On
case globals.WifiSwitch_Offing:
log.Println(log.DebugLog, "Wifi is offing!")
globals.WifiSwitch = globals.WifiSwitch_Off
}
}
func btOnWifiOff_Resume() {
log.Println(log.DebugLog, "Should not come here!")
}
func btOnWifiOffCheckFlag() {
if btOnWifiOffneedInform2server {
if err := http.InformMsgToServer(http.Type_Inform_BtOnWifiOff, map[string]interface{}{"switch": 0}); err == nil {
btOnWifiOffneedInform2server = false
}
}
}
func btOnWifiOffTask_exec(canExec bool, scmd SCMD, arg ...interface{}) {
if canExec {
switch scmd {
case SCMD_SuperTask_Enter_btOnWifiOff:
switch globals.WifiSwitch {
case globals.WifiSwitch_On:
log.Println(log.DebugLog, "Turn off wifi!")
globals.WifiSwitch = globals.WifiSwitch_Offing
if err := http.InformMsgToServer(http.Type_Inform_BtOnWifiOff, map[string]interface{}{"switch": 1}); err == nil {
btOnWifiOffneedInform2server = true
}
SendWifiCmd(uint32(C.CMD_WIFI_OFF))
SetInternetConnect(false, "user force")
led_mcu.DirectLedControl(atservice.GUIDE_EFFECT_ID_NET_MODE, atservice.GUIDE_ACTION_START, 0, []byte{})
player.SoundEffectPlayCmd(globals.CMD_SE_PLAY, vui.SoundNotice_Exit_BtOnWifiOff.GetPath())
backupBtstatus = globals.CurMusicSrcOnOffSt.BtOn
if backupBtstatus == false {
//open bt
log.Println(log.DebugLog, "Turn on bt!")
player.OpenBtOfBt()
}
case globals.WifiSwitch_Off:
log.Println(log.DebugLog, "wifi already off, do nothing!")
case globals.WifiSwitch_Oning:
log.Println(log.DebugLog, "Wifi is oning, do nothing!")
case globals.WifiSwitch_Offing:
log.Println(log.DebugLog, "Wifi is offing, do nothing!")
}
case SCMD_SuperTask_Exit_btOnWifiOff:
switch globals.WifiSwitch {
case globals.WifiSwitch_On:
log.Println(log.DebugLog, "wifi on, do nothing!")
case globals.WifiSwitch_Off:
log.Println(log.DebugLog, "Turn on wifi")
globals.WifiSwitch = globals.WifiSwitch_Oning
led_mcu.DirectLedControl(atservice.GUIDE_EFFECT_ID_NET_MODE, atservice.GUIDE_ACTION_START, 0, []byte{})
SendWifiCmd(uint32(C.CMD_WIFI_ON))
player.SoundEffectPlayCmd(globals.CMD_SE_PLAY, vui.SoundNotice_Enter_BtOnWifiOff.GetPath())
if backupBtstatus == false {
log.Println(log.DebugLog, "Turn off bt!")
player.CloseBtOfBt()
}
case globals.WifiSwitch_Oning:
log.Println(log.DebugLog, "Wifi is oning!")
case globals.WifiSwitch_Offing:
log.Println(log.DebugLog, "Wifi is offing!")
}
}
} else {
log.Println(log.DebugLog, modename_btOnWifiOffwifiparing, "can not run.", canExec, scmd)
}
}
func BtOnWifiOffTaskinit() {
var tmp RegistedTask
var err error
tmp.Interrupt = btOnWifiOff_Interrupt
tmp.GetName = func() string {
return modename_btOnWifiOffwifiparing
}
tmp.IsActive = func() bool {
switch globals.WifiSwitch {
case globals.WifiSwitch_Oning, globals.WifiSwitch_Offing:
return true
default:
return false
}
}
tmp.GetTaskLevel = func() TaskLevel {
return TaskLevel_BtOnWifiOff
}
tmp.Resume = btOnWifiOff_Resume
tmp.GetSupportedSCmd = func() []SCMD {
return []SCMD{SCMD_SuperTask_Enter_btOnWifiOff, SCMD_SuperTask_Exit_btOnWifiOff,}
}
tmp.GetScheduleDomain = func() ScheduleDomain {
return ScheduleDomain_NoneMusic
}
tmp.Do = btOnWifiOffTask_exec
tmp.CanBeInterruptByKey = func() bool {
return false
}
tmp.Debug = func() string {
var tmp string
tmp += fmt.Sprintln("Backup bt status:", backupBtstatus)
tmp += fmt.Sprintln("Wifi switch:", globals.WifiSwitch)
return tmp
}
if err, btOnWifiOff_hd = RegisteSTask(tmp); err == nil {
log.Printf(log.DebugLog, "Registe %s task successfully!!\n", tmp.GetName())
} else {
log.Printf(log.ErrorLog, "Registe %s task fail!!\n", tmp.GetName())
}
}

View File

@ -32,7 +32,7 @@ var (
iot_timeout_exit *time.Timer iot_timeout_exit *time.Timer
iot_do_once sync.Once iot_do_once sync.Once
iot_contex, iot_context_cancel = context.WithCancel(context.Background()) iot_contex, iot_context_cancel = context.WithCancel(context.Background())
iot_stage_before_find_dev = true iot_stage_before_find_dev = true
) )
const ( const (
@ -76,12 +76,12 @@ func iotTask_exec(canExec bool, scmd SCMD, arg ...interface{}) {
iot_do_once = sync.Once{} iot_do_once = sync.Once{}
iot_contex, iot_context_cancel = context.WithCancel(context.Background()) iot_contex, iot_context_cancel = context.WithCancel(context.Background())
SendEventnByYunxinWithRid(DeviceEventType_IotWifiParing, DeviceEventAction_Start, "", false, nil) SendEventnByYunxinWithRid(DeviceEventType_IotWifiParing, DeviceEventAction_Start, "", false, nil)
globals.ResetBroadCastTimer()
//begin to show led //begin to show led
led_mcu.DirectLedControl(atservice.GUIDE_EFFECT_ID_NET_MODE, atservice.GUIDE_ACTION_START, 0, []byte{}) led_mcu.DirectLedControl(atservice.GUIDE_EFFECT_ID_NET_MODE, atservice.GUIDE_ACTION_START, 0, []byte{})
vui.IconLed_Wifiparing_Ap.Show() vui.IconLed_Wifiparing_Ap.Show()
//begin to toast tts //begin to toast tts
PlayNoticeAsync(globals.AdSrcType_TTS, iot_tts_enter, globals.CONST_AUDIO_ID, false, iot_contex, nil) PlayNoticeAsync(globals.AdSrcType_FILE, vui.SoundNotice_IOT_Finding.GetPath(), globals.CONST_AUDIO_ID, false, iot_contex, nil)
http.InformMsgToServer(http.Type_Inform_TtsDelay, iot_tts_enter) http.InformMsgToServer(http.Type_Inform_TtsDelay, iot_tts_enter)
SendWifiCmd(uint32(C.CMD_WIFI_BL_CONF)) SendWifiCmd(uint32(C.CMD_WIFI_BL_CONF))
@ -96,7 +96,7 @@ func iotTask_exec(canExec bool, scmd SCMD, arg ...interface{}) {
} }
iot_is_exiting = true iot_is_exiting = true
PlayNoticeAsync(globals.AdSrcType_TTS, iot_tts_not_found_dev, globals.CONST_AUDIO_ID, false, iot_contex, func(id uint32, reason NoticeStopReason) { PlayNoticeAsync(globals.AdSrcType_FILE, vui.SoundNotice_IOT_NotFound.GetPath(), globals.CONST_AUDIO_ID, false, iot_contex, func(id uint32, reason NoticeStopReason) {
iot_lock.Lock() iot_lock.Lock()
defer iot_lock.Unlock() defer iot_lock.Unlock()
if iot_running == false { if iot_running == false {
@ -128,12 +128,16 @@ func iot_wifiparing_exit() {
} }
iot_context_cancel() iot_context_cancel()
//turn off leds/icon
//tell wifi module stop //tell wifi module stop
SendWifiCmd(uint32(C.CMD_WIFI_BL_CONF_ABORT)) SendWifiCmd(uint32(C.CMD_WIFI_BL_CONF_ABORT))
//turn off leds/icon
led_mcu.DirectLedClear(atservice.GUIDE_EFFECT_ID_EXEC_CMD) led_mcu.DirectLedClear(atservice.GUIDE_EFFECT_ID_EXEC_CMD)
led_mcu.DirectLedClear(atservice.GUIDE_EFFECT_ID_NET_MODE) led_mcu.DirectLedClear(atservice.GUIDE_EFFECT_ID_NET_MODE)
vui.IconLed_Clear.Show() vui.IconLed_Clear.Show()
SendSCmd(SCMD_SChedule)
//2s after broad vbox status
globals.SetBroadCastTimer(2*time.Second)
} else { } else {
log.Println(log.DebugLog, "Iot has exit, do nothing!") log.Println(log.DebugLog, "Iot has exit, do nothing!")
} }
@ -152,11 +156,11 @@ func iot_connect_fail_toast() {
debug.PrintStack() debug.PrintStack()
var tts string var tts string
if iot_stage_before_find_dev == true { if iot_stage_before_find_dev == true {
tts = iot_tts_not_found_dev tts = vui.SoundNotice_IOT_NotFound.GetPath()
} else { } else {
tts = iot_tts_fail tts = vui.SoundNotice_IOT_ConnectedFail.GetPath()
} }
PlayNoticeAsync(globals.AdSrcType_TTS, tts, globals.CONST_AUDIO_ID, false, iot_contex, func(id uint32, reason NoticeStopReason) { PlayNoticeAsync(globals.AdSrcType_FILE, tts, globals.CONST_AUDIO_ID, false, iot_contex, func(id uint32, reason NoticeStopReason) {
iot_lock.Lock() iot_lock.Lock()
defer iot_lock.Unlock() defer iot_lock.Unlock()
if iot_running == false { if iot_running == false {
@ -242,7 +246,11 @@ func iotDbusMsg(buscmd uint32, arg string) {
if err := json.Unmarshal([]byte(arg), &req); err == nil { if err := json.Unmarshal([]byte(arg), &req); err == nil {
var rsp http.HttpRspDeviceRegiste var rsp http.HttpRspDeviceRegiste
if code, _, _ := http.HttpPostAuto(req, &rsp); code == int(globals.ERR_SUCCESS) { if code, _, _ := http.HttpPostAuto(req, &rsp); code == int(globals.ERR_SUCCESS) {
PlayNoticeAsync(globals.AdSrcType_TTS, rsp.Tts, globals.CONST_AUDIO_ID, false, iot_contex, nil) PlayNoticeAsync(globals.AdSrcType_TTS, rsp.Tts, globals.CONST_AUDIO_ID, false, iot_contex, func(id uint32, reason NoticeStopReason) {
if reason == NoticeStopReason_Error && iot_is_exiting == false {
PlayNoticeAsync(globals.AdSrcType_FILE, vui.SoundNotice_IOT_Finded.GetPath(), globals.CONST_AUDIO_ID, false, iot_contex, nil)
}
})
iot_stage_before_find_dev = false iot_stage_before_find_dev = false
SendWifiCmd(uint32(C.CMD_WIFI_BL_DEV_TOKEN_BOUND)) SendWifiCmd(uint32(C.CMD_WIFI_BL_DEV_TOKEN_BOUND))
if iot_timeout_exit != nil { if iot_timeout_exit != nil {
@ -312,6 +320,26 @@ func Iot_Wifiparing_end(tts string) {
return return
} }
if reason == NoticeStopReason_Error {
PlayNoticeAsync(globals.AdSrcType_FILE, vui.SoundNotice_IOT_ConnectedSuccess.GetPath(), globals.CONST_AUDIO_ID, true, iot_contex, func(id uint32, reason NoticeStopReason) {
iot_lock.Lock()
defer iot_lock.Unlock()
if iot_running == false {
return
}
if reason.IsStart() {
led_mcu.DirectLedControl(atservice.GUIDE_EFFECT_ID_EXEC_CMD, atservice.GUIDE_ACTION_START, 0, []byte{})
vui.IconLed_VoiceExecResult.Show()
} else if reason.IsStop() {
iot_wifiparing_exit()
}
})
return
}
if reason.IsStart() { if reason.IsStart() {
led_mcu.DirectLedControl(atservice.GUIDE_EFFECT_ID_EXEC_CMD, atservice.GUIDE_ACTION_START, 0, []byte{}) led_mcu.DirectLedControl(atservice.GUIDE_EFFECT_ID_EXEC_CMD, atservice.GUIDE_ACTION_START, 0, []byte{})
vui.IconLed_VoiceExecResult.Show() vui.IconLed_VoiceExecResult.Show()
@ -359,7 +387,7 @@ func IOTTaskinit() {
} }
tmp.GetScheduleDomain = func() ScheduleDomain { tmp.GetScheduleDomain = func() ScheduleDomain {
return ScheduleDomain_NoneMusic return ScheduleDomain_IotWifiParing
} }
tmp.Do = iotTask_exec tmp.Do = iotTask_exec

View File

@ -202,6 +202,14 @@ func voiceService_exec(canExec bool, scmd SCMD, arg ...interface{}) {
log.Println(log.DebugLog, "Mic is close, do not wake up!!") log.Println(log.DebugLog, "Mic is close, do not wake up!!")
return return
} }
if globals.WifiSwitch == globals.WifiSwitch_Off || globals.WifiSwitch == globals.WifiSwitch_Offing {
log.Println(log.DebugLog, "In btOnWifiOff mode!")
PlayNoticeAsync(AdSrcType_FILE, SoundNotice_Warn_BtOnWifiOff.GetPath(), CONST_AUDIO_ID, false, nil, nil)
return
}
if InternetConnect == false { if InternetConnect == false {
log.Println(log.DebugLog, "Wake up, but internet down!") log.Println(log.DebugLog, "Wake up, but internet down!")
ToastNetworkError(false) ToastNetworkError(false)

View File

@ -0,0 +1,162 @@
package controller
/*
#include <uvdbus/smart_sound.h>
#include <uvdbus/ota.h>
*/
import "C"
import (
. "netease_control_center/globals"
"netease_control_center/interfaces/log"
. "netease_control_center/interfaces/schedule"
"fmt"
"netease_control_center/interfaces/eventPoint"
"netease_control_center/interfaces/vui"
)
const (
modename_wifiParingwifiparing = "wifiParing_service"
)
var (
wifiParing_hd TaskHd
)
func wifiParing_Interrupt(ByWho string) {
log.Println(log.DebugLog, modename_wifiParingwifiparing, " be interrupt by ", ByWho)
if CurBootState != BootStage_WIFIPARING {
return
}
if IsNewBoard() {
log.Println(log.DebugLog, "This is a new board, can not interrupt wifi paring!")
} else {
log.Println(log.DebugLog, "Current in wifi paring mode, jump check wifi and exit!")
StartBoard(BootStage_BEFOREDONE, true)
}
}
func wifiParing_Resume() {
log.Println(log.DebugLog, "Wifi paring resume!")
}
func wifiParingTask_exec(canExec bool, scmd SCMD, arg ...interface{}) {
if IsInBackupSystem() {
if CurOTAStatus == OTAStatus_begin || CurBootState < BootStage_BASEINIT {
log.Println(log.DebugLog, "Can not paring wifi, because ota or init system!")
return
}
if CurBootState == BootStage_BACKUPSYSTEM_WIFIPARING {
log.Println(log.DebugLog, "Jump into backup system, curboot: ", CurBootState)
StartBoard(BootStage_BACKUPSYSTEM, true)
} else {
log.Println(log.DebugLog, "Jump into backup system wifiparing, curboot: ", CurBootState)
StartBoard(BootStage_BACKUPSYSTEM_WIFIPARING, true)
}
return
}
if canExec == false {
log.Println(log.DebugLog, modename_wifiParingwifiparing, " Can not exec!")
return
}
switch scmd {
case SCMD_SuperTask_System_WifiParing:
if IsInBackupSystem() == false {
if CurBootState == BootStage_WIFIPARING {
if IsNewBoard() {
log.Println(log.DebugLog, "This is a new board, and current in wifi paring, do nothing!")
PlayNoticeAsync(AdSrcType_FILE, vui.SoundNotice_Alianwang002.GetPath(), CONST_AUDIO_ID, false, nil, nil)
//StartBoard(BootStage_WIFIPARING, true)
} else {
log.Println(log.DebugLog, "Current in wifi paring mode, jump check wifi and exit!")
PlayNoticeAsync(AdSrcType_FILE, vui.SoundNotice_Alianwang011.GetPath(), CONST_AUDIO_ID, false, nil, nil)
StartBoard(BootStage_BEFOREDONE, true)
}
} else {
log.Println(log.DebugLog, "Will jump into wifi paring by key triging in normal system!")
CurWifiParingMode = WifiParingMode_BT
StartBoard(BootStage_WIFIPARING, false)
eventPoint.EpRecord("B211", map[string]interface{}{"type": CurWifiParingMode.String(), "net": false})
}
}
case SCMD_SuperTask_System_WifiModeChange_AP_BT:
switch CurBootState {
case BootStage_WIFIPARING:
log.Println(log.DebugLog, "jump into wifi ap paring in normal system!")
if CurWifiParingMode == WifiParingMode_AP {
CurWifiParingMode = WifiParingMode_BT
} else {
CurWifiParingMode = WifiParingMode_AP
}
StartBoard(BootStage_WIFIPARING, true)
eventPoint.EpRecord("B211", map[string]interface{}{"type": CurWifiParingMode.String(), "net": false})
case BootStage_BACKUPSYSTEM_WIFIPARING:
log.Println(log.DebugLog, "jump into wifi ap paring in backup system!")
if CurWifiParingMode == WifiParingMode_AP {
CurWifiParingMode = WifiParingMode_BT
} else {
CurWifiParingMode = WifiParingMode_AP
}
StartBoard(BootStage_BACKUPSYSTEM_WIFIPARING, true)
default:
log.Println(log.DebugLog, "not in wifi paring, do nothing!")
}
}
}
func WifiParingTaskinit() {
var tmp RegistedTask
var err error
tmp.Interrupt = wifiParing_Interrupt
tmp.GetName = func() string {
return modename_wifiParingwifiparing
}
tmp.IsActive = func() bool {
switch CurBootState {
case BootStage_WIFIPARING, BootStage_BACKUPSYSTEM_WIFIPARING:
return true;
default:
return false
}
}
tmp.GetTaskLevel = func() TaskLevel {
return TaskLevel_WifiParing
}
tmp.Resume = wifiParing_Resume
tmp.GetSupportedSCmd = func() []SCMD {
return []SCMD{SCMD_SuperTask_System_WifiParing,SCMD_SuperTask_System_WifiModeChange_AP_BT,}
}
tmp.GetScheduleDomain = func() ScheduleDomain {
return ScheduleDomain_NoneMusic
}
tmp.Do = wifiParingTask_exec
tmp.CanBeInterruptByKey = func() bool {
return false
}
tmp.Debug = func() string {
var tmp string
tmp += fmt.Sprintln("Backup bt status:", backupBtstatus)
return tmp
}
if err, wifiParing_hd = RegisteSTask(tmp); err == nil {
log.Printf(log.DebugLog, "Registe %s task successfully!!\n", tmp.GetName())
} else {
log.Printf(log.ErrorLog, "Registe %s task fail!!\n", tmp.GetName())
}
}

View File

@ -17,7 +17,7 @@ var (
pingticker = time.NewTicker(10 * time.Second) pingticker = time.NewTicker(10 * time.Second)
recordVolume = time.NewTimer(3 * time.Second) recordVolume = time.NewTimer(500 * time.Microsecond) //lupeng change 3s to 500ms 20180904
calTimeTicker = time.NewTicker(24 * time.Hour) calTimeTicker = time.NewTicker(24 * time.Hour)
@ -25,7 +25,7 @@ var (
) )
func ResetRecordVolumeTimer() { func ResetRecordVolumeTimer() {
recordVolume.Reset(3 * time.Second) recordVolume.Reset(500 * time.Microsecond) //lupeng change 3s to 500ms 20180904
} }
func GetCurVboxBroadcastSt(print bool) VboxBroadcastSt { func GetCurVboxBroadcastSt(print bool) VboxBroadcastSt {
@ -82,6 +82,7 @@ func timerFunc() {
eventPoint.EpRecord("H511", map[string]interface{}{"volume": adau1761.MustGetVol()}) eventPoint.EpRecord("H511", map[string]interface{}{"volume": adau1761.MustGetVol()})
if getCurDeviceMode(false) == Exec_MusicPlay_mode { if getCurDeviceMode(false) == Exec_MusicPlay_mode {
misc.VolTrigeMicAdc() misc.VolTrigeMicAdc()
BroadcastStatus(GetCurVboxBroadcastSt(false)) //lupeng add 20180904
} }
case <-ticker_30min.C: case <-ticker_30min.C:

View File

@ -28,7 +28,7 @@ func AirPlayStopTrig(globalsPause bool) {
} }
func AirPlayPause() { func AirPlayPause() {
sendMusicCmd(CMD_AIRPLAYER_PAUSE) sendMusicCmd(PlayerType_Airplay, CMD_AIRPLAYER_PAUSE)
ctrlAirPlayCmdToPhone(SPLAYER_ACTION_PAUSE) ctrlAirPlayCmdToPhone(SPLAYER_ACTION_PAUSE)
} }
@ -49,13 +49,13 @@ func AirPlayPlay(start int, arg SCmd_Args) bool {
return false return false
} }
} else { } else {
sendMusicCmd(CMD_AIRPLAYER_PLAY) sendMusicCmd(PlayerType_Airplay, CMD_AIRPLAYER_PLAY)
return true return true
} }
} }
func AirPlayStop() { func AirPlayStop() {
//sendMusicCmd(CMD_PLAYER_STOP) //sendMusicCmd(PlayerType_Airplay, CMD_PLAYER_STOP)
// todo : trig phone stop // todo : trig phone stop
ctrlAirPlayCmdToPhone(SPLAYER_ACTION_PAUSE) ctrlAirPlayCmdToPhone(SPLAYER_ACTION_PAUSE)
} }
@ -78,14 +78,14 @@ func AirPlayPlayNext(arg interface{}) {
// todo : 反向airplay控制 // todo : 反向airplay控制
ctrlAirPlayCmdToPhone(SPLAYER_ACTION_NEXT) ctrlAirPlayCmdToPhone(SPLAYER_ACTION_NEXT)
//MonitorAirplayPlayerBroadcast(MUSIC_ST_PLAYING) //MonitorAirplayPlayerBroadcast(MUSIC_ST_PLAYING)
sendMusicCmd(CMD_AIRPLAYER_PLAY) sendMusicCmd(PlayerType_Airplay, CMD_AIRPLAYER_PLAY)
} }
func AirPlayPlayPre(arg interface{}) { func AirPlayPlayPre(arg interface{}) {
// todo : 反向airplay控制 // todo : 反向airplay控制
ctrlAirPlayCmdToPhone(SPLAYER_ACTION_PRE) ctrlAirPlayCmdToPhone(SPLAYER_ACTION_PRE)
//MonitorAirplayPlayerBroadcast(MUSIC_ST_PLAYING) //MonitorAirplayPlayerBroadcast(MUSIC_ST_PLAYING)
sendMusicCmd(CMD_AIRPLAYER_PLAY) sendMusicCmd(PlayerType_Airplay, CMD_AIRPLAYER_PLAY)
} }
func AirPlayPrepareNext() { func AirPlayPrepareNext() {
@ -154,7 +154,7 @@ func airPlayPlayApi(arg interface{}) {
case AirParams2Play: case AirParams2Play:
log.Printf(log.DebugLog, "airplay arg:%+v\n", argVal) log.Printf(log.DebugLog, "airplay arg:%+v\n", argVal)
sendMusicCmd(CMD_AIRPLAYER_PLAY, arg, &AirPlayUuid) sendMusicCmd(PlayerType_Airplay, CMD_AIRPLAYER_PLAY, arg, &AirPlayUuid)
default: default:
log.Println(log.WarningLog, "err params type") log.Println(log.WarningLog, "err params type")
} }

View File

@ -83,8 +83,12 @@ func BtPlayPlayNext(arg interface{}) {
MonitorBtPlayerBroadcast(MUSIC_ST_PLAYING) MonitorBtPlayerBroadcast(MUSIC_ST_PLAYING)
if tmp, ok := arg.(PlayerArg); ok && len(tmp.RspId) > 0 { if tmp, ok := arg.(PlayerArg); ok && len(tmp.RspId) > 0 {
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: tmp.RspId, Cmd: int(MSC_CMD_NEXT), Data: TTS_MUSIC_NEXT, Tts: TTS_MUSIC_NEXT, if tmp.RspId == CONST_AUDIO_ID {
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING}) http.InformLocalMsgToServer(http.Type_Inform_TtsPush, int(MSC_CMD_NEXT), TTS_MUSIC_NEXT, TTS_MUSIC_NEXT) //快捷指令上传信息流
} else {
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: tmp.RspId, Cmd: int(MSC_CMD_NEXT), Data: TTS_MUSIC_NEXT, Tts: TTS_MUSIC_NEXT,
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING})
}
} }
} }

View File

@ -36,7 +36,12 @@ type MusicCmdExtra struct {
RespId string RespId string
} }
func sendMusicCmd(cmd uint32, params ...interface{}) error { func sendCurPlayerMusicCmd(cmd uint32, params ...interface{}) error {
playerID := schedule.GetCurPlayerId()
return sendMusicCmd(playerID ,cmd, params ...)
}
func sendMusicCmd(playerId PlayerType,cmd uint32, params ...interface{}) error {
defer func() { defer func() {
if err := recover(); err != nil { if err := recover(); err != nil {
log.Println(log.ErrorLog, err) log.Println(log.ErrorLog, err)
@ -47,7 +52,11 @@ func sendMusicCmd(cmd uint32, params ...interface{}) error {
var err error var err error
var tosend PlayerCmdStruct var tosend PlayerCmdStruct
tosend.PlayerId = schedule.GetCurPlayerId() tosend.PlayerId = playerId
if playerId >= PlayerType_Other || playerId < PlayerType_Wifi {
log.Printf(log.ErrorLog, "playerId error:%d\n", playerId)
return PARAMS_ERR_INVALID
}
switch cmd { switch cmd {
case CMD_SE_PLAY: case CMD_SE_PLAY:
@ -217,9 +226,9 @@ func VolChangeByPercent(percent int) {
/** /**
only for airplay dlna blue vol change only for airplay dlna blue vol change
*/ */
func VolChange(vol int) { func VolChangeBroadcast(vol int) {
log.Println(log.DebugLog, "vol:", vol) log.Println(log.DebugLog, "vol:", vol)
adau1761.SetVol(vol) //adau1761.SetVol(vol)
CurVboxVolSt.VolumeScale = MaxVolume CurVboxVolSt.VolumeScale = MaxVolume
CurVboxVolSt.VolumePer = uint8(GetPerByVol(vol)) CurVboxVolSt.VolumePer = uint8(GetPerByVol(vol))
@ -359,8 +368,7 @@ func getSongPlayInfo(playerType PlayerType, id *string, ttsNow bool) (*ServerSon
if len(err.Error()) > 0 { if len(err.Error()) > 0 {
if ttsNow { if ttsNow {
forcePausePlayer(playerType) forcePausePlayer(playerType)
//NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, *tts, CONST_AUDIO_ID, AdSrcType_TTS, TTS_LEVEL_1, true, false) mscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
mscToastTts(err.Error(), CONST_AUDIO_ID, true, false, nil)
} else { } else {
ttsNoMusic = true ttsNoMusic = true
ttsMusicUuid = *wifiPlayerSt.MusicId ttsMusicUuid = *wifiPlayerSt.MusicId
@ -375,9 +383,7 @@ func getSongPlayInfo(playerType PlayerType, id *string, ttsNow bool) (*ServerSon
if ttsNow { if ttsNow {
forcePausePlayer(playerType) forcePausePlayer(playerType)
//NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, Server_ERR_RET.Error(), CONST_AUDIO_ID, AdSrcType_TTS, mscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
// TTS_LEVEL_1, true, false)
mscToastTts(Server_ERR_RET.Error(), CONST_AUDIO_ID, true, false, nil)
} else { } else {
if nil != wifiPlayerSt.MusicId && len(*wifiPlayerSt.MusicId) > 0 { if nil != wifiPlayerSt.MusicId && len(*wifiPlayerSt.MusicId) > 0 {
ttsNoMusic = true ttsNoMusic = true
@ -392,6 +398,54 @@ func getSongPlayInfo(playerType PlayerType, id *string, ttsNow bool) (*ServerSon
return song, nil return song, nil
} }
//获取音乐单个歌单的歌曲数目
func GetMusicPlayListInfo(playerType PlayerType, ttsNow bool, listinfo http.PlayListServerType) (*MusicPlayListInfo, error) {
defer func() {
if playerRecoverLevel <= LOW_RECOVER_LEVEL {
if err := recover(); err != nil {
log.Println(log.ErrorLog, err)
}
}
}()
listInfo, _, _, err := http.GetMusicPlayListInfoDo(listinfo)
if nil != err {
log.Println(log.ErrorLog, err.Error())
return nil, err
}
if nil == listInfo {
log.Println(log.WarningLog, Server_ERR_RET.Error())
return nil, Server_ERR_RET
} else {
log.Printf(log.DebugLog, "music playList Info:%+v\n", listInfo)
}
return listInfo, nil
}
//获取一个电台的总节目数
func GetRadioPlayListInfo(playerType PlayerType, ttsNow bool, listinfo http.PlayListServerType) (*RadioPlayListInfo, error) {
defer func() {
if playerRecoverLevel <= LOW_RECOVER_LEVEL {
if err := recover(); err != nil {
log.Println(log.ErrorLog, err)
}
}
}()
listInfo, _, _, err := http.GetRadioPlayListInfoDo(listinfo)
if nil != err {
log.Println(log.ErrorLog, err.Error())
return nil, err
}
if nil == listInfo {
log.Println(log.WarningLog, Server_ERR_RET.Error())
return nil, Server_ERR_RET
} else {
log.Printf(log.DebugLog, "radio playList Info:%+v\n", listInfo)
}
return listInfo, nil
}
func GetSongDetail(playerType PlayerType, id *string, ttsNow bool) (*ServerSongDetail, error) { func GetSongDetail(playerType PlayerType, id *string, ttsNow bool) (*ServerSongDetail, error) {
return getSongDetailInfo(playerType, id, ttsNow) return getSongDetailInfo(playerType, id, ttsNow)
} }
@ -410,8 +464,7 @@ func getSongDetailInfo(playerType PlayerType, id *string, ttsNow bool) (*ServerS
if len(err.Error()) > 0 { if len(err.Error()) > 0 {
if ttsNow { if ttsNow {
forcePausePlayer(playerType) forcePausePlayer(playerType)
//NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, *tts, CONST_AUDIO_ID, AdSrcType_TTS, TTS_LEVEL_1, true, false) mscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
mscToastTts(err.Error(), CONST_AUDIO_ID, true, false, nil)
} else { } else {
if nil != wifiPlayerSt.MusicId && len(*wifiPlayerSt.MusicId) > 0 { if nil != wifiPlayerSt.MusicId && len(*wifiPlayerSt.MusicId) > 0 {
ttsNoMusic = true ttsNoMusic = true
@ -429,9 +482,7 @@ func getSongDetailInfo(playerType PlayerType, id *string, ttsNow bool) (*ServerS
if ttsNow { if ttsNow {
forcePausePlayer(playerType) forcePausePlayer(playerType)
//NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, Server_ERR_RET.Error(), CONST_AUDIO_ID, AdSrcType_TTS, mscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
// TTS_LEVEL_1, true, false)
mscToastTts(Server_ERR_RET.Error(), CONST_AUDIO_ID, true, false, nil)
} else { } else {
if nil != wifiPlayerSt.MusicId && len(*wifiPlayerSt.MusicId) > 0 { if nil != wifiPlayerSt.MusicId && len(*wifiPlayerSt.MusicId) > 0 {
ttsNoMusic = true ttsNoMusic = true
@ -526,8 +577,7 @@ func GetMusicListNew(playerType PlayerType, ttsNow bool, serverList http.MusicLi
if len(err.Error()) > 0 { if len(err.Error()) > 0 {
if ttsNow { if ttsNow {
forcePausePlayer(playerType) forcePausePlayer(playerType)
//NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, *tts, CONST_AUDIO_ID, AdSrcType_TTS, TTS_LEVEL_1, true, false) mscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
mscToastTts(err.Error(), CONST_AUDIO_ID, true, false, nil)
} else { } else {
ttsNoMusic = true ttsNoMusic = true
ttsMusicUuid = *wifiPlayerSt.MusicId ttsMusicUuid = *wifiPlayerSt.MusicId
@ -549,9 +599,7 @@ func GetMusicListNew(playerType PlayerType, ttsNow bool, serverList http.MusicLi
if ttsNow { if ttsNow {
forcePausePlayer(playerType) forcePausePlayer(playerType)
//NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, Server_ERR_RET.Error(), CONST_AUDIO_ID, AdSrcType_TTS, mscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
// TTS_LEVEL_1, true, false)
mscToastTts(Server_ERR_RET.Error(), CONST_AUDIO_ID, true, false, nil)
} else { } else {
if nil != wifiPlayerSt.MusicId && len(*wifiPlayerSt.MusicId) > 0 { if nil != wifiPlayerSt.MusicId && len(*wifiPlayerSt.MusicId) > 0 {
ttsNoMusic = true ttsNoMusic = true
@ -608,8 +656,7 @@ try:
if ttsNow { if ttsNow {
forcePausePlayer(playerType) forcePausePlayer(playerType)
//NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, *tts, CONST_AUDIO_ID, AdSrcType_TTS, TTS_LEVEL_1, true, false) mscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
mscToastTts(err.Error(), CONST_AUDIO_ID, true, false, nil)
} else { } else {
ttsNoMusic = true ttsNoMusic = true
ttsMusicUuid = *wifiPlayerSt.MusicId ttsMusicUuid = *wifiPlayerSt.MusicId
@ -624,9 +671,7 @@ try:
if ttsNow { if ttsNow {
forcePausePlayer(playerType) forcePausePlayer(playerType)
//NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, Server_ERR_RET.Error(), CONST_AUDIO_ID, AdSrcType_TTS, mscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
// TTS_LEVEL_1, true, false)
mscToastTts(Server_ERR_RET.Error(), CONST_AUDIO_ID, true, false, nil)
} else { } else {
if nil != wifiPlayerSt.MusicId && len(*wifiPlayerSt.MusicId) > 0 { if nil != wifiPlayerSt.MusicId && len(*wifiPlayerSt.MusicId) > 0 {
ttsNoMusic = true ttsNoMusic = true
@ -823,13 +868,15 @@ func ProjectorVolProcess(newVolPer int) {
if goalVerPer == oldVerPer { if goalVerPer == oldVerPer {
log.Println(log.WarningLog, "finis vol change") log.Println(log.WarningLog, "finis vol change")
VolChangeBroadcast(goalVerPer)
goto Out_Vol goto Out_Vol
} else if goalVerPer > oldVerPer { } else if goalVerPer > oldVerPer {
oldVerPer = oldVerPer + step oldVerPer = oldVerPer + step
} else { } else {
oldVerPer = oldVerPer - step oldVerPer = oldVerPer - step
} }
VolChange(oldVerPer) adau1761.SetVol(oldVerPer)
//VolChange(oldVerPer)
log.Println(log.WarningLog, "cur perVol:", oldVerPer) log.Println(log.WarningLog, "cur perVol:", oldVerPer)
case <-outVol: case <-outVol:
log.Println(log.WarningLog, "trig out") log.Println(log.WarningLog, "trig out")
@ -914,7 +961,7 @@ func mscToastFile(file string, uuid string, needRepeat bool, keep bool, configCh
//检查是否网络缓存播放失败 //检查是否网络缓存播放失败
if arg.StopReason == schedule.NoticeStopReason_Error { if arg.StopReason == schedule.NoticeStopReason_Error {
go mscToastFile(vui.SoundNotice_Song_Get_Timeout.GetPath(), CONST_AUDIO_ID, false, false, nil) go mscToastFile(vui.SoundNotice_Song_Get_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
} }
} }

View File

@ -76,7 +76,7 @@ func GetDlnaPlayPauseState() bool {
} }
func DlnaPause() { func DlnaPause() {
sendMusicCmd(CMD_PLAYER_PAUSE) sendMusicCmd(PlayerType_Dlna, CMD_PLAYER_PAUSE)
if !GetDlnaPlayPauseState() { if !GetDlnaPlayPauseState() {
SetDlnaPlayPauseState(false) SetDlnaPlayPauseState(false)
} else { } else {
@ -106,22 +106,14 @@ func DlnaPlay(start int, arg SCmd_Args) bool {
} }
log.Println(log.WarningLog, "start:", start) log.Println(log.WarningLog, "start:", start)
if REQUEST_PLAY_PARAMS == start { if dlnaHasSetrg {
log.Println(log.WarningLog, "dlnaHasSetrg:", dlnaHasSetrg) log.Println(log.WarningLog, "dlnaHasSetrg:", dlnaHasSetrg)
if dlnaHasSetrg { dlnaHasSetrg = false
dlnaHasSetrg = false dlnaPlayApi(dlnaPlayArg)
dlnaPlayApi(dlnaPlayArg) return true
return true
} else if nil != dlnaPlayArg {
dlnaPlayApi(dlnaPlayArg)
return true
} else {
log.Println(log.ErrorLog, "hasSetDlnaArg false && dlnaPlayArg nil")
return false
}
} else { } else {
isChange := PlayerHander[PlayerType_Dlna].IsPlayerChange(true) isChange := PlayerHander[PlayerType_Dlna].IsPlayerChange(true)
//sendMusicCmd(CMD_PLAYER_PLAY) //sendMusicCmd(PlayerType_Dlna, CMD_PLAYER_PLAY)
log.Printf(log.DebugLog, "\nstatus:%+v ,isChange:%d\n", log.Printf(log.DebugLog, "\nstatus:%+v ,isChange:%d\n",
PlayerHander[PlayerType_Dlna].GetPlayerStatus(), PlayerHander[PlayerType_Dlna].GetPlayerStatus(),
isChange) isChange)
@ -154,14 +146,14 @@ func DlnaPlay(start int, arg SCmd_Args) bool {
} }
func DlnaStop() { func DlnaStop() {
sendMusicCmd(CMD_PLAYER_PAUSE) sendMusicCmd(PlayerType_Dlna, CMD_PLAYER_PAUSE)
DlnaPlaySeek = false DlnaPlaySeek = false
CtrlDlnaCmdToPhone(CTRL_DLNA_STOP) CtrlDlnaCmdToPhone(CTRL_DLNA_STOP)
SetDlnaPlayPauseState(false) SetDlnaPlayPauseState(false)
} }
func DlnaSeek(pos uint32) { func DlnaSeek(pos uint32) {
sendMusicCmd(CMD_PLAYER_SEEKTO, pos*1000) sendMusicCmd(PlayerType_Dlna, CMD_PLAYER_SEEKTO, pos*1000)
} }
func DlnaIsOnline() bool { func DlnaIsOnline() bool {
@ -236,7 +228,7 @@ func DlnaPlayerStatusChange(status PlayerDetail) {
if "" != status.Uuid { if "" != status.Uuid {
if dlnaNeedSeekPos { if dlnaNeedSeekPos {
dlnaNeedSeekPos = false dlnaNeedSeekPos = false
sendMusicCmd(CMD_PLAYER_SEEKTO, dlnaSeekPos) sendMusicCmd(PlayerType_Dlna, CMD_PLAYER_SEEKTO, dlnaSeekPos)
} }
updateDlnaPlayerStatus(status) updateDlnaPlayerStatus(status)
@ -251,7 +243,7 @@ func DlnaPlayerStatusChange(status PlayerDetail) {
dlnaWaitNextTimer.Stop() dlnaWaitNextTimer.Stop()
} }
dlnaWaitNextTimer = time.AfterFunc(DlnaWaitNextTime.GetCfgListTime(), func() { dlnaWaitNextTimer = time.AfterFunc(DlnaWaitNextTime.GetCfgListTime(), func() {
//DlnaStopTrig() DlnaStopTrig()
//CtrlDlnaCmdToPhone(CTRL_DLNA_NEXT) //CtrlDlnaCmdToPhone(CTRL_DLNA_NEXT)
log.Printf(log.WarningLog, "wait dlna next timeout\n") log.Printf(log.WarningLog, "wait dlna next timeout\n")
}) })
@ -263,7 +255,7 @@ func DlnaPlayerStatusChange(status PlayerDetail) {
updateDlnaPlayerStatus(status) updateDlnaPlayerStatus(status)
} }
case PLAYER_ERR_TINA_NOTIFY, PLAYER_ERR_TINA_START, PLAYER_ERR_TINA_RESET, case PLAYER_ERR_TINA_NOTIFY, PLAYER_ERR_TINA_START, PLAYER_ERR_TINA_RESET,
PLAYER_ERR_TINA_SETSOURCE, PLAYER_ERR_TINA_PREPARE, PLAYER_ERR_TINA_SEEKTO: PLAYER_ERR_TINA_SETSOURCE, PLAYER_ERR_TINA_PREPARE:
log.Println(log.DebugLog, "...tinaplayer err...", status.Status) log.Println(log.DebugLog, "...tinaplayer err...", status.Status)
if nil != dlnaErrTimer { if nil != dlnaErrTimer {
@ -286,6 +278,8 @@ func DlnaPlayerStatusChange(status PlayerDetail) {
mscToastTts(TTS_DLNA_ERR_1, CONST_AUDIO_ID, true, false, nil) mscToastTts(TTS_DLNA_ERR_1, CONST_AUDIO_ID, true, false, nil)
} }
}) })
case PLAYER_ERR_TINA_SEEKTO:
log.Println(log.WarningLog, "tina play seek err:", status.Status)
case MUSIC_ST_PREPARING_TIMEOUT: case MUSIC_ST_PREPARING_TIMEOUT:
log.Println(log.ErrorLog, "dlna perparing timeout") log.Println(log.ErrorLog, "dlna perparing timeout")
//NoticePlayerSendSCmd(SCMD_SuperTask_Tts_Play, vui.SoundNotice_Song_Get_Timeout.GetPath(), CONST_AUDIO_ID, AdSrcType_FILE, TTS_LEVEL_1, //NoticePlayerSendSCmd(SCMD_SuperTask_Tts_Play, vui.SoundNotice_Song_Get_Timeout.GetPath(), CONST_AUDIO_ID, AdSrcType_FILE, TTS_LEVEL_1,
@ -356,7 +350,7 @@ func dlnaPlayApi(arg ...interface{}) {
Url string `json:"url"` Url string `json:"url"`
} }
if 0 == len(arg) { if 0 == len(arg) {
sendMusicCmd(CMD_PLAYER_PLAY) sendMusicCmd(PlayerType_Dlna, CMD_PLAYER_PLAY)
} else if 1 == len(arg) { } else if 1 == len(arg) {
// params: json string // params: json string
switch argVal := arg[0].(type) { switch argVal := arg[0].(type) {
@ -370,17 +364,17 @@ func dlnaPlayApi(arg ...interface{}) {
log.Println(log.DebugLog, "url:", *dlnaUrl) log.Println(log.DebugLog, "url:", *dlnaUrl)
if nil != dlnaUrl { if nil != dlnaUrl {
sendMusicCmd(CMD_PLAYER_PLAY, dlnaUrl, dlnaUrl, nil, AdSrcType_FILE, uint32(0), float32(0), dlnaBgUrl) // dlna 的duration暂时不处理 sendMusicCmd(PlayerType_Dlna, CMD_PLAYER_PLAY, dlnaUrl, dlnaUrl, nil, AdSrcType_FILE, uint32(0), float32(0), dlnaBgUrl) // dlna 的duration暂时不处理
dlnaUrl = nil dlnaUrl = nil
} else { } else {
sendMusicCmd(CMD_PLAYER_PLAY) sendMusicCmd(PlayerType_Dlna, CMD_PLAYER_PLAY)
} }
default: default:
log.Println(log.WarningLog, "err params type") log.Println(log.WarningLog, "err params type")
} }
} else if 2 == len(arg) { } else if 2 == len(arg) {
// params: songId *string , songUrl *string // params: songId *string , songUrl *string
sendMusicCmd(CMD_PLAYER_PLAY, arg[0].(*string), arg[1].(*string), nil, AdSrcType_FILE, uint32(0), float32(0), dlnaBgUrl) sendMusicCmd(PlayerType_Dlna, CMD_PLAYER_PLAY, arg[0].(*string), arg[1].(*string), nil, AdSrcType_FILE, uint32(0), float32(0), dlnaBgUrl)
} }
} }

View File

@ -33,7 +33,7 @@ var (
) )
func NormalPause() { func NormalPause() {
sendMusicCmd(CMD_PLAYER_PAUSE) sendCurPlayerMusicCmd(CMD_PLAYER_PAUSE)
} }
func NormalPlay(start int, arg SCmd_Args) bool { func NormalPlay(start int, arg SCmd_Args) bool {
@ -80,11 +80,11 @@ func NormalPlay(start int, arg SCmd_Args) bool {
} }
func NormalStop() { func NormalStop() {
sendMusicCmd(CMD_PLAYER_STOP) sendCurPlayerMusicCmd(CMD_PLAYER_STOP)
} }
func NormalSeek(pos uint32) { func NormalSeek(pos uint32) {
sendMusicCmd(CMD_PLAYER_SEEKTO, pos) sendCurPlayerMusicCmd(CMD_PLAYER_SEEKTO, pos)
} }
func NormalIsOnline() bool { func NormalIsOnline() bool {
@ -150,7 +150,7 @@ func NormalPlayerStatusChange(status PlayerDetail) {
func normalPlayApi(e interface{}) { func normalPlayApi(e interface{}) {
if nil == e { if nil == e {
sendMusicCmd(CMD_PLAYER_PLAY) sendCurPlayerMusicCmd(CMD_PLAYER_PLAY)
return return
} }
@ -498,7 +498,7 @@ func normalPlayerStHd(status PlayerDetail) error {
if "" != status.Uuid { if "" != status.Uuid {
if normalNeedSeekToPos { if normalNeedSeekToPos {
normalNeedSeekToPos = false normalNeedSeekToPos = false
sendMusicCmd(CMD_PLAYER_SEEKTO, normalSeekPos) sendCurPlayerMusicCmd(CMD_PLAYER_SEEKTO, normalSeekPos)
} }
updateNormalPlayerStatus(status) updateNormalPlayerStatus(status)
@ -921,10 +921,10 @@ func lowLevelPlayApi(arg commonPlayApiArg) error {
} }
} }
if arg.prepare { if arg.prepare {
sendMusicCmd(CMD_PLAYER_PERPARE_NEXT, &arg.songId.Id, arg.songUrl, tts, ttsAdSrcType, sendCurPlayerMusicCmd(CMD_PLAYER_PERPARE_NEXT, &arg.songId.Id, arg.songUrl, tts, ttsAdSrcType,
arg.songId.Duration, arg.songId.Gain, arg.songId.BGUrl) arg.songId.Duration, arg.songId.Gain, arg.songId.BGUrl)
} else { } else {
sendMusicCmd(CMD_PLAYER_PLAY, &arg.songId.Id, arg.songUrl, tts, ttsAdSrcType, sendCurPlayerMusicCmd(CMD_PLAYER_PLAY, &arg.songId.Id, arg.songUrl, tts, ttsAdSrcType,
arg.songId.Duration, arg.songId.Gain, arg.songId.BGUrl) arg.songId.Duration, arg.songId.Gain, arg.songId.BGUrl)
} }
LocalMusicList[PLAYSONG_MUSIC_LIST].Push(arg.songId, true) LocalMusicList[PLAYSONG_MUSIC_LIST].Push(arg.songId, true)

View File

@ -59,9 +59,9 @@ func GetDefaultNoticePlayerParams() schedule.NoticePlayerParams {
tmp.Level = TTS_LEVEL_1 tmp.Level = TTS_LEVEL_1
tmp.SpecialCmd = "" tmp.SpecialCmd = ""
tmp.SpecialFunc = nil tmp.SpecialFunc = func(arg schedule.TtsPlayerArg) {}
tmp.BeforeSpecialFunc = nil tmp.BeforeSpecialFunc = func() {}
tmp.BeforeExecFunc = nil tmp.BeforeExecFunc = func() {}
tmp.Uuid = CONST_AUDIO_ID tmp.Uuid = CONST_AUDIO_ID
return tmp return tmp
@ -254,9 +254,9 @@ func noticePlayerCallback(id uint32, reason schedule.NoticeStopReason, params *s
schedule.NoticeStopReason_Error: schedule.NoticeStopReason_Error:
if reason == schedule.NoticeStopReason_Error { if reason == schedule.NoticeStopReason_Error {
if params.Uuid != CONST_AUDIO_ID { if params.Uuid != CONST_AUDIO_ID {
//log.Println(log.WarningLog, "end srcUuid:", params.Uuid) //log.Println(log.WarningLog, "end srcUuid:", params.Uuid)
if IsLocalAudioUuid(params.Uuid) { if IsLocalAudioUuid(params.Uuid) {
eventPoint.AudioErrorEp(params.Uuid, params.Tts, "error", eventPoint.EpOs_Device) eventPoint.AudioErrorEp(params.Uuid, params.Tts, "error", eventPoint.EpOs_Device)
} else { } else {
eventPoint.AudioErrorEp(params.Uuid, params.Tts, "error", eventPoint.EpOs_Server) eventPoint.AudioErrorEp(params.Uuid, params.Tts, "error", eventPoint.EpOs_Server)
@ -266,9 +266,9 @@ func noticePlayerCallback(id uint32, reason schedule.NoticeStopReason, params *s
if params.Uuid != CONST_AUDIO_ID { if params.Uuid != CONST_AUDIO_ID {
//log.Println(log.WarningLog, "end srcUuid:", params.Uuid) //log.Println(log.WarningLog, "end srcUuid:", params.Uuid)
if IsLocalAudioUuid(params.Uuid) { if IsLocalAudioUuid(params.Uuid) {
eventPoint.AudioEnd(params.Uuid, params.Tts, "break", eventPoint.EpOs_Device) eventPoint.AudioEnd(params.Uuid, params.Tts, "break", eventPoint.EpOs_Device)
} else { } else {
eventPoint.AudioEnd(params.Uuid, params.Tts, "break", eventPoint.EpOs_Server) eventPoint.AudioEnd(params.Uuid, params.Tts, "break", eventPoint.EpOs_Server)
} }
} }
} }
@ -354,7 +354,7 @@ func noticePlayerCallback(id uint32, reason schedule.NoticeStopReason, params *s
* notice exec api * notice exec api
*/ */
func SoundEffectPlayCmd(cmd uint32, url string) { func SoundEffectPlayCmd(cmd uint32, url string) {
sendMusicCmd(cmd, &url, &url) sendCurPlayerMusicCmd(cmd, &url, &url)
} }
func noticePlayCmdSync(canExcel bool, cmd uint32, id uint32, tts string, uuid string, srcType AdSrcType, level TtsLevel, func noticePlayCmdSync(canExcel bool, cmd uint32, id uint32, tts string, uuid string, srcType AdSrcType, level TtsLevel,

View File

@ -79,6 +79,11 @@ const (
VOICE_GRADUATE_DISAPPEAR_TIME time.Duration = 5 * time.Minute VOICE_GRADUATE_DISAPPEAR_TIME time.Duration = 5 * time.Minute
) )
func sendScenesMusicCmd(hd SSceneHd, cmd uint32, params ...interface{}) error {
playerID := (PlayerType)(hd.GetPlayerHd().GetPlayerId())
return sendMusicCmd(playerID ,cmd, params ...)
}
func ScenesPause(hd SSceneHd) { func ScenesPause(hd SSceneHd) {
ignoreRestoreVol := hd.GetIgnoreVolRestore() ignoreRestoreVol := hd.GetIgnoreVolRestore()
log.Printf(log.ErrorLog, "ignoreRestoreVol:%+v\n", ignoreRestoreVol) log.Printf(log.ErrorLog, "ignoreRestoreVol:%+v\n", ignoreRestoreVol)
@ -86,7 +91,7 @@ func ScenesPause(hd SSceneHd) {
EndVoiceGrandateDisappear(RESTORE_VOL) EndVoiceGrandateDisappear(RESTORE_VOL)
} }
sendMusicCmd(CMD_PLAYER_PAUSE) sendScenesMusicCmd(hd ,CMD_PLAYER_PAUSE)
} }
func ScenesPlay(startType PlayerStartType, position int, hd SSceneHd, taskno int) { func ScenesPlay(startType PlayerStartType, position int, hd SSceneHd, taskno int) {
@ -242,7 +247,7 @@ func ScenesPlay(startType PlayerStartType, position int, hd SSceneHd, taskno int
func ScenesStop(hd SSceneHd) { func ScenesStop(hd SSceneHd) {
EndVoiceGrandateDisappear(RESTORE_VOL) EndVoiceGrandateDisappear(RESTORE_VOL)
sendMusicCmd(CMD_PLAYER_STOP) sendScenesMusicCmd(hd ,CMD_PLAYER_STOP)
} }
func ScenesPlayNext(hd SSceneHd) { func ScenesPlayNext(hd SSceneHd) {
@ -254,7 +259,7 @@ func ScenesPlayPre(hd SSceneHd) {
} }
func ScenesPlaySeek(hd SSceneHd, pos uint32) { func ScenesPlaySeek(hd SSceneHd, pos uint32) {
sendMusicCmd(CMD_PLAYER_SEEKTO, pos) sendScenesMusicCmd(hd ,CMD_PLAYER_SEEKTO, pos)
} }
func ScenesPlayerStatusChange(status PlayerDetail, hd SSceneHd) { func ScenesPlayerStatusChange(status PlayerDetail, hd SSceneHd) {
@ -268,7 +273,7 @@ func ScenesAppCtrlPlay(e interface{}) {
func scenesPlayApi(e interface{}) { func scenesPlayApi(e interface{}) {
log.Printf(log.DebugLog, "scene params:%+v\n", e) log.Printf(log.DebugLog, "scene params:%+v\n", e)
if nil == e { if nil == e {
sendMusicCmd(CMD_PLAYER_PLAY) sendScenesMusicCmd(hdCur ,CMD_PLAYER_PLAY)
return return
} }
@ -589,7 +594,7 @@ func scenesNextApi(prepare bool) (MusicChangeAction, error) {
// 当前列表空 // 当前列表空
case ACTION_STOP_PLAYER: case ACTION_STOP_PLAYER:
log.Println(log.DebugLog, "scenes player auto stop, taskNoCur:", taskNoCur) log.Println(log.DebugLog, "scenes player auto stop, taskNoCur:", taskNoCur)
sendMusicCmd(CMD_PLAYER_PAUSE) sendScenesMusicCmd(hdCur ,CMD_PLAYER_PAUSE)
hdCur.GetPlayerHd().ReportOffline() hdCur.GetPlayerHd().ReportOffline()
// todo scenes play auto stop, process your things // todo scenes play auto stop, process your things
@ -757,7 +762,7 @@ func scenesPlayerStHd(status PlayerDetail) error {
if "" != status.Uuid { if "" != status.Uuid {
if scenesNeedSeekToPos { if scenesNeedSeekToPos {
scenesNeedSeekToPos = false scenesNeedSeekToPos = false
sendMusicCmd(CMD_PLAYER_SEEKTO, scenesSeekPos) sendScenesMusicCmd(hdCur ,CMD_PLAYER_SEEKTO, scenesSeekPos)
} }
updateScenesPlayerStatus(status) updateScenesPlayerStatus(status)
@ -1225,10 +1230,10 @@ func lowLevelScenesPlayApi(arg commonPlayApiArg) error {
} }
if arg.prepare { if arg.prepare {
sendMusicCmd(CMD_PLAYER_PERPARE_NEXT, &arg.songId.Id, arg.songUrl, tts, ttsAdSrcType, sendScenesMusicCmd(hdCur ,CMD_PLAYER_PERPARE_NEXT, &arg.songId.Id, arg.songUrl, tts, ttsAdSrcType,
arg.songId.Duration, arg.songId.Gain, arg.songId.BGUrl) arg.songId.Duration, arg.songId.Gain, arg.songId.BGUrl)
} else { } else {
sendMusicCmd(CMD_PLAYER_PLAY, &arg.songId.Id, arg.songUrl, tts, ttsAdSrcType, sendScenesMusicCmd(hdCur ,CMD_PLAYER_PLAY, &arg.songId.Id, arg.songUrl, tts, ttsAdSrcType,
arg.songId.Duration, arg.songId.Gain, arg.songId.BGUrl) arg.songId.Duration, arg.songId.Gain, arg.songId.BGUrl)
} }
LocalMusicList[PLAYSONG_MUSIC_LIST].Push(arg.songId, true) LocalMusicList[PLAYSONG_MUSIC_LIST].Push(arg.songId, true)

View File

@ -55,7 +55,7 @@ func getInputCmd() {
case CMD_PLAYER_PLAY, case CMD_PLAYER_PLAY,
CMD_PLAYER_PAUSE, CMD_PLAYER_PAUSE,
CMD_PLAYER_STOP: CMD_PLAYER_STOP:
sendMusicCmd(cmd) sendCurPlayerMusicCmd(cmd)
case CMD_PLAYER_NEXT: case CMD_PLAYER_NEXT:
schedule.SendSCmd(schedule.SCMD_MusicPlayer_PlayNext, nil) schedule.SendSCmd(schedule.SCMD_MusicPlayer_PlayNext, nil)
case CMD_PLAYER_PRE: case CMD_PLAYER_PRE:
@ -68,7 +68,7 @@ func getInputCmd() {
if nil != err { if nil != err {
continue continue
} }
sendMusicCmd(CMD_PLAYER_SEEKTO, uint32(seek*1000)) sendCurPlayerMusicCmd(CMD_PLAYER_SEEKTO, uint32(seek*1000))
case uint32(MUSIC_ST_FOR_NEXT): case uint32(MUSIC_ST_FOR_NEXT):
var playerSt schedule.PlayerDetail var playerSt schedule.PlayerDetail
playerSt.Status = MUSIC_ST_FOR_NEXT playerSt.Status = MUSIC_ST_FOR_NEXT
@ -155,7 +155,7 @@ func getInputCmd() {
} }
case CMD_ALARM_S: case CMD_ALARM_S:
// todo // todo
sendMusicCmd(CMD_SEARCH_PLAYER_REQ) sendCurPlayerMusicCmd(CMD_SEARCH_PLAYER_REQ)
case CMD_ALARM_L: case CMD_ALARM_L:
// todo // todo
case CMD_OTA_TTS: case CMD_OTA_TTS:

View File

@ -6,6 +6,9 @@ import (
"netease_control_center/interfaces/http" "netease_control_center/interfaces/http"
"netease_control_center/interfaces/log" "netease_control_center/interfaces/log"
. "netease_control_center/interfaces/schedule" . "netease_control_center/interfaces/schedule"
"netease_control_center/modules/hardware/mcu_leds/atservice"
"time"
"netease_control_center/interfaces/vui"
) )
const ( const (
@ -30,6 +33,24 @@ func WifiPause() {
wifiPauseApi() wifiPauseApi()
} }
func toastNetworkError(isJustPlayEror bool) {
tmpconfig := GetDefaultNoticePlayerParams()
tmpconfig.Keep = false
tmpconfig.NeedRepeat = true
tmpconfig.Level = TTS_LEVEL_1
tmpconfig.SrcType = AdSrcType_FILE
tmpconfig.Tts = vui.SoundNotice_Alianwang010.GetPath()
tmpconfig.LedOn = DirectLed{EffectId: atservice.GUIDE_EFFECT_ID_SYSTEM_ERR, Action: atservice.GUIDE_ACTION_START}
tmpconfig.LedOff = DirectLed{EffectId: atservice.GUIDE_EFFECT_ID_SYSTEM_ERR, Action: atservice.GUIDE_ACTION_STOP}
if isJustPlayEror == false {
tmpconfig.BeforeExecFunc = func() {
SoundEffectPlayCmd(CMD_SE_PLAY, vui.SoundNotice_Slianwangshibai001.GetPath())
time.Sleep(800 * time.Millisecond)
}
}
NoticePlayerSendSCmd2(SCMD_SuperTask_Tts_Ctrl_Play, tmpconfig)
}
func WifiPlay(start int, arg SCmd_Args) bool { func WifiPlay(start int, arg SCmd_Args) bool {
if !isNetConnect() { if !isNetConnect() {
log.Println(log.ErrorLog, "WifiPlay: internet is down") log.Println(log.ErrorLog, "WifiPlay: internet is down")
@ -139,6 +160,7 @@ func WifiPlay(start int, arg SCmd_Args) bool {
func WifiStop() { func WifiStop() {
if !isNetConnect() { if !isNetConnect() {
log.Println(log.ErrorLog, "WifiStop: internet is down") log.Println(log.ErrorLog, "WifiStop: internet is down")
toastNetworkError(false)
return return
} }
@ -148,6 +170,7 @@ func WifiStop() {
func WifiSeek(pos uint32) { func WifiSeek(pos uint32) {
if !isNetConnect() { if !isNetConnect() {
log.Println(log.ErrorLog, "WifiSeek: internet is down") log.Println(log.ErrorLog, "WifiSeek: internet is down")
toastNetworkError(false)
return return
} }
wifiSeekApi(pos) wifiSeekApi(pos)
@ -165,6 +188,7 @@ func WifiIfForcePause() bool {
func WifiPlayNext(arg interface{}) { func WifiPlayNext(arg interface{}) {
if !isNetConnect() { if !isNetConnect() {
log.Println(log.ErrorLog, "WifiPlayNext: internet is down") log.Println(log.ErrorLog, "WifiPlayNext: internet is down")
toastNetworkError(false)
return return
} }
wifiNextApi(arg) wifiNextApi(arg)
@ -173,6 +197,7 @@ func WifiPlayNext(arg interface{}) {
func WifiPlayPre(arg interface{}) { func WifiPlayPre(arg interface{}) {
if !isNetConnect() { if !isNetConnect() {
log.Println(log.ErrorLog, "WifiPlayPre: internet is down") log.Println(log.ErrorLog, "WifiPlayPre: internet is down")
toastNetworkError(false)
return return
} }
wifiPreApi(arg) wifiPreApi(arg)
@ -296,7 +321,7 @@ func KeyTriggerPlayorPause() {
playMusic(nil) playMusic(nil)
} else if MUSIC_ST_PLAYING == wifiPlayerSt.ContinuousTaskSt { } else if MUSIC_ST_PLAYING == wifiPlayerSt.ContinuousTaskSt {
// 暂停音乐 // 暂停音乐
sendMusicCmd(CMD_PLAYER_PAUSE) sendMusicCmd(PlayerType_Wifi,CMD_PLAYER_PAUSE)
} }
} }
@ -326,7 +351,8 @@ func WifiMusicFilterSet(tts *string, denyinfo []DenyInfo) bool {
} else { } else {
if nil != tmp.Data { if nil != tmp.Data {
for _, id := range tmp.Data { for _, id := range tmp.Data {
err := LocalMusicFilter.Push(tmp.Type, &id) tmpsongId := id
err := LocalMusicFilter.Push(tmp.Type, &tmpsongId)
if nil != err { if nil != err {
log.Println(log.WarningLog, err.Error()) log.Println(log.WarningLog, err.Error())
} }

View File

@ -15,6 +15,7 @@ import (
"strings" "strings"
"sync" "sync"
"time" "time"
"math"
) )
var ( var (
@ -65,7 +66,7 @@ wifiPlayApi
*/ */
func wifiPlayApi(e interface{}) bool { func wifiPlayApi(e interface{}) bool {
if nil == e { if nil == e {
sendMusicCmd(CMD_PLAYER_PLAY) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY)
//songId := PlayerHander[PlayerType_Wifi].GetPlayerStatus().Uuid //songId := PlayerHander[PlayerType_Wifi].GetPlayerStatus().Uuid
//songDetail, err := getSongDetailInfo(PlayerType_Wifi, &songId, false) //songDetail, err := getSongDetailInfo(PlayerType_Wifi, &songId, false)
@ -113,11 +114,11 @@ func wifiPlayApi(e interface{}) bool {
} }
func wifiPauseApi() { func wifiPauseApi() {
sendMusicCmd(CMD_PLAYER_PAUSE) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PAUSE)
} }
func wifiStopApi() { func wifiStopApi() {
sendMusicCmd(CMD_PLAYER_STOP) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_STOP)
} }
func wifiNextApi(arg interface{}) { func wifiNextApi(arg interface{}) {
@ -143,11 +144,11 @@ func wifiPrepareNextApi() {
} }
func wifiSeekApi(pos uint32) { func wifiSeekApi(pos uint32) {
sendMusicCmd(CMD_PLAYER_SEEKTO, pos) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_SEEKTO, pos)
} }
func wifiSeekPlayApi(pos uint32) { func wifiSeekPlayApi(pos uint32) {
sendMusicCmd(CMD_PLAYER_SEEKTO_PLAY, pos) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_SEEKTO_PLAY, pos)
} }
/** /**
@ -198,7 +199,7 @@ func wifiPlayerStHd(status schedule.PlayerDetail) error {
if wifiNeedSeekToPos { if wifiNeedSeekToPos {
wifiNeedSeekToPos = false wifiNeedSeekToPos = false
sendMusicCmd(CMD_PLAYER_SEEKTO, wifiSeekPos) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_SEEKTO, wifiSeekPos)
} }
if nil == wifiPlayerSt.MusicId || *wifiPlayerSt.MusicId != status.Uuid || if nil == wifiPlayerSt.MusicId || *wifiPlayerSt.MusicId != status.Uuid ||
@ -230,8 +231,13 @@ func wifiPlayerStHd(status schedule.PlayerDetail) error {
forcePausePlayer(PlayerType_Wifi) forcePausePlayer(PlayerType_Wifi)
//NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, ttsInfo, CONST_AUDIO_ID, AdSrcType_TTS, TTS_LEVEL_1, //NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, ttsInfo, CONST_AUDIO_ID, AdSrcType_TTS, TTS_LEVEL_1,
// true, false) // true, false)
mscToastTts(ttsInfo, CONST_AUDIO_ID, true, false, nil) if ttsInfo == TTS_TEXT_ORDER_PLAY_END_FLAG {
log.Println(log.DebugLog, "tts when music end:", ttsInfo) PlayListSrcRec.ListHasEnd = true
log.Println(log.WarningLog, "play list end, pause player!")
} else {
mscToastTts(ttsInfo, CONST_AUDIO_ID, true, false, nil)
log.Println(log.DebugLog, "tts when music end:", ttsInfo)
}
} }
if "" != status.Uuid { if "" != status.Uuid {
@ -277,6 +283,7 @@ func wifiPlayerStHd(status schedule.PlayerDetail) error {
} else { } else {
errWifiPlayCnt = 0 errWifiPlayCnt = 0
log.Println(log.ErrorLog, "SYSTEM ERR: tinaplayer err, and has try ", ERR_PLAY_MAX, " times") log.Println(log.ErrorLog, "SYSTEM ERR: tinaplayer err, and has try ", ERR_PLAY_MAX, " times")
mscToastFile(vui.SoundNotice_Song_Get_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil)
} }
} }
}) })
@ -305,7 +312,7 @@ func playMusic(e interface{}) MusicAction {
if MUSIC_ST_PAUSED == wifiPlayerSt.ContinuousTaskSt { if MUSIC_ST_PAUSED == wifiPlayerSt.ContinuousTaskSt {
timePause := time.Now().Sub(wifiPlayerSt.ContinuousStChangeTime) timePause := time.Now().Sub(wifiPlayerSt.ContinuousStChangeTime)
if timePause < T1Timeout.GetCfgListTime() { if timePause < T1Timeout.GetCfgListTime() {
sendMusicCmd(CMD_PLAYER_PLAY) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY)
} else if timePause < T2Timeout.GetCfgListTime() { } else if timePause < T2Timeout.GetCfgListTime() {
log.Println(log.DebugLog, "t1~t2 now:", time.Now().Unix(), " listTime:", log.Println(log.DebugLog, "t1~t2 now:", time.Now().Unix(), " listTime:",
wifiPlayerSt.ContinuousStChangeTime.Unix()) wifiPlayerSt.ContinuousStChangeTime.Unix())
@ -425,6 +432,7 @@ func playMusic(e interface{}) MusicAction {
// 清除歌曲过滤列表 // 清除歌曲过滤列表
LocalMusicFilter.Init() LocalMusicFilter.Init()
PlayListSrcRec.ListHasEnd = false //歌单播放结束标志位false
switch srcType { switch srcType {
case NEW_TOPLIST, HOT_TOPLIST, DAILY_PUSH, DENON_TOPLIST, CLASSIC_TOPLIST, BEATPORT_TOPLIST, case NEW_TOPLIST, HOT_TOPLIST, DAILY_PUSH, DENON_TOPLIST, CLASSIC_TOPLIST, BEATPORT_TOPLIST,
@ -464,6 +472,9 @@ func playAppMusic(appReq *AppPlayReq) (MusicAction, error) {
return APP_NIL_ID_ACTION, MusicList_ERR_MUSICINFO_NULL return APP_NIL_ID_ACTION, MusicList_ERR_MUSICINFO_NULL
} }
log.Printf(log.DebugLog, "param when play from app:%+v\n", appReq)
PlayListSrcRec.ListHasEnd = false //歌单播放结束标志位false
if INVAILED_INDEX != appReq.Index { if INVAILED_INDEX != appReq.Index {
// 当前播放列表中歌曲 // 当前播放列表中歌曲
listType := GetMusicListIndex() listType := GetMusicListIndex()
@ -870,7 +881,7 @@ func playNewHotDailyMusic(serverData *ServerMusicList, rcmdSrc bool) (MusicActio
/* 此时,不需要对推送的歌单进行鉴权保护,因为此时是直接播放暂停的歌曲,歌单鉴权保护,等待歌曲切换时再进行保护 */ /* 此时,不需要对推送的歌单进行鉴权保护,因为此时是直接播放暂停的歌曲,歌单鉴权保护,等待歌曲切换时再进行保护 */
// 恢复播放 // 恢复播放
log.Println(log.DebugLog, "replay playNewHotDailyMusic") log.Println(log.DebugLog, "replay playNewHotDailyMusic")
//sendMusicCmd(CMD_PLAYER_PLAY) //sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY)
// 检查更新 // 检查更新
if NewHotDailyRec[srcType-NEW_TOPLIST].MusicListTimeStamp != serverData.MusicList.UpdateTime || PlayListSrcRec.HasInsert { if NewHotDailyRec[srcType-NEW_TOPLIST].MusicListTimeStamp != serverData.MusicList.UpdateTime || PlayListSrcRec.HasInsert {
// 歌单有更新 // 歌单有更新
@ -878,7 +889,7 @@ func playNewHotDailyMusic(serverData *ServerMusicList, rcmdSrc bool) (MusicActio
" t2:", serverData.MusicList.UpdateTime) " t2:", serverData.MusicList.UpdateTime)
musicAction = NHD_LESS_T1_UPDATE musicAction = NHD_LESS_T1_UPDATE
forcePlayCur = true //forcePlayCur = true 现在产品的逻辑是重复意图切换下一首
} else { } else {
needReplay = true needReplay = true
// 歌单无更新 // 歌单无更新
@ -1036,7 +1047,7 @@ func playNewHotDailyMusic(serverData *ServerMusicList, rcmdSrc bool) (MusicActio
} }
} }
if needReplay { if needReplay {
/*sendMusicCmd(CMD_PLAYER_PLAY) /*sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY)
// 歌曲续播的该次语音的rspid清除掉 // 歌曲续播的该次语音的rspid清除掉
RspId = nil*/ RspId = nil*/
//重复意图,直接切歌 //重复意图,直接切歌
@ -1123,7 +1134,7 @@ func playPrivateFM(serverData *ServerMusicList) (MusicAction, error) {
// 恢复播放 // 恢复播放
//log.Println(log.DebugLog, "replay playPrivateFM") //log.Println(log.DebugLog, "replay playPrivateFM")
//needReplay = true //全新开始不是replay //needReplay = true //全新开始不是replay
//sendMusicCmd(CMD_PLAYER_PLAY) //sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY)
//musicAction = FM_LESS_T1 //musicAction = FM_LESS_T1
//needUpdate = false //全新开始需要update //needUpdate = false //全新开始需要update
log.Println(log.DebugLog, "some FM repeat cmd, now get fm list again..") log.Println(log.DebugLog, "some FM repeat cmd, now get fm list again..")
@ -1155,7 +1166,7 @@ func playPrivateFM(serverData *ServerMusicList) (MusicAction, error) {
log.Println(log.DebugLog, "FM play start with songId:", songId) log.Println(log.DebugLog, "FM play start with songId:", songId)
if needReplay { if needReplay {
/*sendMusicCmd(CMD_PLAYER_PLAY) /*sendMusicCmd((PlayerType_Wifi, CMD_PLAYER_PLAY)
// 歌曲续播的该次语音的rspid清除掉 // 歌曲续播的该次语音的rspid清除掉
RspId = nil*/ RspId = nil*/
//重复意图,直接切歌 //重复意图,直接切歌
@ -1315,7 +1326,7 @@ func playNormalListMusic(replace bool, e interface{}) (MusicAction, error) {
// 更新时间变,需要替换歌单 // 更新时间变,需要替换歌单
musicAction = NORMAL_LESS_T1_UPDATE musicAction = NORMAL_LESS_T1_UPDATE
forcePlayCur = true //forcePlayCur = true //现在产品的逻辑是重复意图切换下一首
log.Println(log.DebugLog, "play list changed, will replace the list, updateTime:", updateTime, ", PlayListSrcRec.UpdateTime:", PlayListSrcRec.UpdateTime) log.Println(log.DebugLog, "play list changed, will replace the list, updateTime:", updateTime, ", PlayListSrcRec.UpdateTime:", PlayListSrcRec.UpdateTime)
songId, songUrl = getCanPlaySong(e) songId, songUrl = getCanPlaySong(e)
} }
@ -1366,7 +1377,7 @@ func playNormalListMusic(replace bool, e interface{}) (MusicAction, error) {
} }
if needReplay { if needReplay {
/*sendMusicCmd(CMD_PLAYER_PLAY) /*sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY)
// 歌曲续播的该次语音的rspid清除掉 // 歌曲续播的该次语音的rspid清除掉
RspId = nil*/ RspId = nil*/
//重复意图,直接切歌 //重复意图,直接切歌
@ -1930,23 +1941,25 @@ func prepareNextMusic() error {
back, _ := NormalListMap[NORMAL_LIST_PAGE].GetLast() back, _ := NormalListMap[NORMAL_LIST_PAGE].GetLast()
if nil == back || 1 == back.Value.(*PageNode).PageIndex || if nil == back || 1 == back.Value.(*PageNode).PageIndex ||
MUSIC_LIST_NULL == PlayListSrcRec.MusicSrc { MUSIC_LIST_NULL == PlayListSrcRec.MusicSrc {
tmpCurPos, err := LocalMusicList[curMusicList].GetFirst() if CurPlayingMode != LIST_ORDER_PLAY {
if nil != err { tmpCurPos, err := LocalMusicList[curMusicList].GetFirst()
log.Println(log.ErrorLog, err.Error()) if nil != err {
return err log.Println(log.ErrorLog, err.Error())
} return err
LocalMusicList[curMusicList].SetCurPos(tmpCurPos) }
LocalMusicList[curMusicList].SetCurPos(tmpCurPos)
if LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo).CanPlay { if LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo).CanPlay {
} else { } else {
LocalMusicList[curMusicList].GetValidNext() LocalMusicList[curMusicList].GetValidNext()
}
songId = LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo)
} }
log.Println(log.DebugLog, "loop list for only one list, one page") //开始重复播放,有且只有一个歌单,只有一页 log.Println(log.DebugLog, "loop list for only one list, one page") //开始重复播放,有且只有一个歌单,只有一页
isRepeat = true isRepeat = true
songId = LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo)
} else { } else {
if CurPlayingMode != LIST_ORDER_PLAY { if CurPlayingMode != LIST_ORDER_PLAY {
// 拉取第一页 // 拉取第一页
@ -1991,9 +2004,13 @@ func prepareNextMusic() error {
if ACTION_NEXT_LIST_REPLACE_LIST == action { if ACTION_NEXT_LIST_REPLACE_LIST == action {
PlayListSrcRec.MusicListIdIndex += 1 PlayListSrcRec.MusicListIdIndex += 1
} else if ACTION_CYCLY_TO_FRONT_LIST_REPLACE_LIST == action { } else if ACTION_CYCLY_TO_FRONT_LIST_REPLACE_LIST == action {
PlayListSrcRec.MusicListIdIndex = 0 log.Println(log.DebugLog, "loop list for get front list")
log.Println(log.DebugLog, "loop list for get front list") //开始重复播放,重新播放第一个歌单
isRepeat = true isRepeat = true
if CurPlayingMode == LIST_ORDER_PLAY {
break
}
//开始重复播放,重新播放第一个歌单
PlayListSrcRec.MusicListIdIndex = 0
} }
var listCnt MusicLenType = 0 var listCnt MusicLenType = 0
@ -2051,10 +2068,14 @@ func prepareNextMusic() error {
// 当前播放的是我的歌单,在创建的歌单和收藏的歌单之间循环 // 当前播放的是我的歌单,在创建的歌单和收藏的歌单之间循环
action = ACTION_USER_LIST_CYCLE action = ACTION_USER_LIST_CYCLE
} else { } else {
// 歌单播放完毕,且后续没有歌单,重新播放第一个歌单
action = ACTION_CYCLY_TO_FRONT_LIST_REPLACE_LIST
log.Println(log.DebugLog, "loop list for get front list") log.Println(log.DebugLog, "loop list for get front list")
isRepeat = true isRepeat = true
if CurPlayingMode == LIST_ORDER_PLAY {
break
}
// 歌单播放完毕,且后续没有歌单,重新播放第一个歌单
action = ACTION_CYCLY_TO_FRONT_LIST_REPLACE_LIST
} }
} else { } else {
//下一个歌单 //下一个歌单
@ -2071,9 +2092,12 @@ func prepareNextMusic() error {
// 切换时歌单index需要清零 // 切换时歌单index需要清零
listIndex = 0 listIndex = 0
if USER_LISTS_COLLECT == curUserListsType { if USER_LISTS_COLLECT == curUserListsType {
srcType = USER_LISTS_CREATE
log.Println(log.DebugLog, "loop list for get create user list") log.Println(log.DebugLog, "loop list for get create user list")
isRepeat = true isRepeat = true
if CurPlayingMode == LIST_ORDER_PLAY {
break
}
srcType = USER_LISTS_CREATE
} else { } else {
srcType = USER_LISTS_COLLECT srcType = USER_LISTS_COLLECT
} }
@ -2110,6 +2134,9 @@ func prepareNextMusic() error {
if srcType != curUserListsType { if srcType != curUserListsType {
log.Println(log.DebugLog, "loop list for no collect user list") //没有收藏的歌单,开始重复播放 log.Println(log.DebugLog, "loop list for no collect user list") //没有收藏的歌单,开始重复播放
isRepeat = true isRepeat = true
if CurPlayingMode == LIST_ORDER_PLAY {
break
}
} }
NormalListMap[NORMAL_LIST_PAGE].Init() NormalListMap[NORMAL_LIST_PAGE].Init()
@ -2129,11 +2156,11 @@ func prepareNextMusic() error {
//第一次循环播放时播放copyright tts //第一次循环播放时播放copyright tts
var isFirstRepeat bool = false var isFirstRepeat bool = false
if isRepeat { if isRepeat {
if CurPlayingMode == LIST_ORDER_PLAY && PlayListSrcRec.BizType != BIZ_TYPE_MUSIC { if CurPlayingMode == LIST_ORDER_PLAY {
log.Println(log.DebugLog, "play list end because list order play mode") log.Println(log.DebugLog, "play list end because list order play mode")
/*ttsNoMusic = true ttsNoMusic = true
ttsMusicUuid = curSongInfo.Id ttsMusicUuid = curSongInfo.Id
ttsInfo = TTS_TEXT_RADIO_END*/ ttsInfo = TTS_TEXT_ORDER_PLAY_END_FLAG
return nil return nil
} }
if needPlayCopyrightTTs == true && len(tts) == 0 && len(ttsUrl) == 0 { if needPlayCopyrightTTs == true && len(tts) == 0 && len(ttsUrl) == 0 {
@ -2270,16 +2297,20 @@ func prevMusic(arg interface{}) (MusicChangeAction, error) {
filterTts = false filterTts = false
} }
case ACTION_PLAY_BACK: case ACTION_PLAY_BACK:
if CurPlayingMode == LIST_ORDER_PLAY && PlayListSrcRec.BizType != BIZ_TYPE_MUSIC { if CurPlayingMode == LIST_ORDER_PLAY {
if schedule.GetCurPlayer().IsPlaying() { if schedule.GetCurPlayer().IsPlaying() {
sendMusicCmd(CMD_PLAYER_PAUSE) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PAUSE)
} }
log.Println(log.DebugLog, "play list no back because list order play mode") log.Println(log.DebugLog, "play list no back because list order play mode")
//push tts to server var noPreOne string
http.InformMsgToServer(http.Type_Inform_TtsDelay, TTS_TEXT_FIRST_RADIO) if PlayListSrcRec.BizType == BIZ_TYPE_MUSIC {
noPreOne = TTS_TEXT_FIRST_MUSIC
} else {
noPreOne = TTS_TEXT_FIRST_RADIO
}
schedule.PlayNoticeAsync(AdSrcType_TTS, TTS_TEXT_FIRST_RADIO, CONST_AUDIO_ID, true, nil, schedule.PlayNoticeAsync(AdSrcType_TTS, noPreOne, CONST_AUDIO_ID, true, nil,
func(id uint32, reason schedule.NoticeStopReason) { func(id uint32, reason schedule.NoticeStopReason) {
switch reason { switch reason {
case schedule.NoticeStart_Play: case schedule.NoticeStart_Play:
@ -2292,11 +2323,15 @@ func prevMusic(arg interface{}) (MusicChangeAction, error) {
ttsExecVuiStop() ttsExecVuiStop()
//schedule.SendSCmd(schedule.SCMD_MusicPlayer_Play, nil) //schedule.SendSCmd(schedule.SCMD_MusicPlayer_Play, nil)
sendMusicCmd(CMD_PLAYER_PLAY) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY)
default: default:
} }
}) })
//push tts to server
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: rspId, Cmd: int(MSC_CMD_PRE), Data: noPreOne, Tts: noPreOne,
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING})
return ACTION_NULL, nil return ACTION_NULL, nil
} else { } else {
tmpCurPos, err := LocalMusicList[curMusicList].GetLast() tmpCurPos, err := LocalMusicList[curMusicList].GetLast()
@ -2312,18 +2347,32 @@ func prevMusic(arg interface{}) (MusicChangeAction, error) {
LocalMusicList[curMusicList].GetValidPre() LocalMusicList[curMusicList].GetValidPre()
} }
} }
case ACTION_NEXT_PAGE_REPLACE_LIST, ACTION_MISS_PAGE_REPLACE_LIST, ACTION_LAST_PAGE: case ACTION_PRE_PAGE_REPLACE_LIST, ACTION_MISS_PAGE_REPLACE_LIST, ACTION_LAST_PAGE, ACTION_NEXT_PAGE_REPLACE_LIST:
if ACTION_NEXT_PAGE_REPLACE_LIST == action { if ACTION_PRE_PAGE_REPLACE_LIST == action {
if CurPlayingMode == LIST_ORDER_PLAY && PlayListSrcRec.BizType != BIZ_TYPE_MUSIC { // 还有前一个分页,拉取分页
index = (NormalListMap[NORMAL_LIST_PAGE].CurPos.Value.(*PageNode).PageIndex - 2) * PAGE_SIZE
} else if ACTION_MISS_PAGE_REPLACE_LIST == action {
// 有缺失的分页,拉取分页
index = (NormalListMap[NORMAL_LIST_PAGE].GetMissPage() - 1) * PAGE_SIZE
} else {
if CurPlayingMode == LIST_ORDER_PLAY {
if schedule.GetCurPlayer().IsPlaying() { if schedule.GetCurPlayer().IsPlaying() {
sendMusicCmd(CMD_PLAYER_PAUSE) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PAUSE)
} }
log.Println(log.DebugLog, "play list no back because list order play mode") log.Println(log.DebugLog, "play list no back because list order play mode")
//push tts to server var noPreOne string
http.InformMsgToServer(http.Type_Inform_TtsDelay, TTS_TEXT_FIRST_RADIO) if PlayListSrcRec.BizType == BIZ_TYPE_MUSIC {
noPreOne = TTS_TEXT_FIRST_MUSIC
} else {
noPreOne = TTS_TEXT_FIRST_RADIO
}
schedule.PlayNoticeAsync(AdSrcType_TTS, TTS_TEXT_FIRST_RADIO, CONST_AUDIO_ID, true, nil, //push tts to server
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: rspId, Cmd: int(MSC_CMD_PRE), Data: TTS_MUSIC_PRE, Tts: noPreOne,
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING})
schedule.PlayNoticeAsync(AdSrcType_TTS, noPreOne, CONST_AUDIO_ID, true, nil,
func(id uint32, reason schedule.NoticeStopReason) { func(id uint32, reason schedule.NoticeStopReason) {
switch reason { switch reason {
case schedule.NoticeStart_Play: case schedule.NoticeStart_Play:
@ -2336,24 +2385,48 @@ func prevMusic(arg interface{}) (MusicChangeAction, error) {
ttsExecVuiStop() ttsExecVuiStop()
//schedule.SendSCmd(schedule.SCMD_MusicPlayer_Play, nil) //schedule.SendSCmd(schedule.SCMD_MusicPlayer_Play, nil)
sendMusicCmd(CMD_PLAYER_PLAY) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY)
default: default:
} }
}) })
return ACTION_NULL, nil return ACTION_NULL, nil
} }
// 还有剩余分页,拉取分页
if val, err := NormalListMap[NORMAL_LIST_PAGE].GetLast(); nil == err { var err error
index = val.Value.(*PageNode).PageIndex * PAGE_SIZE var playListCnt MusicLenType = 0
//从服务器拉取节目歌单总数
if PlayListSrcRec.BizType == BIZ_TYPE_MUSIC {
var listInfo *MusicPlayListInfo
listInfo, err = GetMusicPlayListInfo(PlayerType_Wifi, true, http.PlayListServerType{
Id: PlayListSrcRec.MusicListId,
ModeId: PlayListSrcRec.ModeId,
})
if nil == err {
playListCnt = MusicLenType(listInfo.ListInfo.TrackCount)
}
} else if PlayListSrcRec.BizType == BIZ_TYPE_RADIO_STATION {
var listInfo *RadioPlayListInfo
listInfo, err = GetRadioPlayListInfo(PlayerType_Wifi, true, http.PlayListServerType{
Id: PlayListSrcRec.MusicListId,
ModeId: PlayListSrcRec.ModeId,
})
if nil == err {
playListCnt = MusicLenType(listInfo.ListInfo.ProgramCount)
}
}
if nil == err {
index = MusicLenType(math.Ceil(float64(playListCnt)/PAGE_SIZE)-1) * PAGE_SIZE
} else {
log.Println(log.ErrorLog, err.Error())
if val, err := NormalListMap[NORMAL_LIST_PAGE].GetLast(); nil == err {
index = (val.Value.(*PageNode).PageIndex - 1) * PAGE_SIZE
} else {
// 分页全部拉取完毕,重新拉取第一页
NormalListMap[NORMAL_LIST_PAGE].Init()
index = 0
}
} }
} else if ACTION_MISS_PAGE_REPLACE_LIST == action {
// 有缺失的分页,拉取分页
index = (NormalListMap[NORMAL_LIST_PAGE].GetMissPage() - 1) * PAGE_SIZE
} else {
// 分页全部拉取完毕,重新拉取第一页
NormalListMap[NORMAL_LIST_PAGE].Init()
index = 0
} }
srcType := getMusicSrcType(PlayerType_Wifi) srcType := getMusicSrcType(PlayerType_Wifi)
@ -2482,6 +2555,7 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) {
if (SINGLE_CYCLE == CurPlayingMode && false) || forcePlayCur { // 上/下一曲忽略单曲循环 if (SINGLE_CYCLE == CurPlayingMode && false) || forcePlayCur { // 上/下一曲忽略单曲循环
// 单曲循环时,直接拿当前的音乐节点播放 // 单曲循环时,直接拿当前的音乐节点播放
songId = LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo) songId = LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo)
log.Printf(log.WarningLog, "force play cur song:%+v\n", songId)
forcePlayCur = false forcePlayCur = false
} else { } else {
pullNextListByIdAgain: pullNextListByIdAgain:
@ -2538,9 +2612,7 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) {
var pageSize MusicLenType = PAGE_SIZE var pageSize MusicLenType = PAGE_SIZE
if ACTION_NEXT_PAGE_REPLACE_LIST == action { if ACTION_NEXT_PAGE_REPLACE_LIST == action {
// 还有剩余分页,拉取分页,不重置分页信息 // 还有剩余分页,拉取分页,不重置分页信息
if val, err := NormalListMap[NORMAL_LIST_PAGE].GetLast(); nil == err { index = NormalListMap[NORMAL_LIST_PAGE].CurPos.Value.(*PageNode).PageIndex * PAGE_SIZE
index = val.Value.(*PageNode).PageIndex * PAGE_SIZE
}
} else if ACTION_MISS_PAGE_REPLACE_LIST == action { } else if ACTION_MISS_PAGE_REPLACE_LIST == action {
// 有缺失的分页,拉取分页,不重置分页信息 // 有缺失的分页,拉取分页,不重置分页信息
index = (NormalListMap[NORMAL_LIST_PAGE].GetMissPage() - 1) * PAGE_SIZE index = (NormalListMap[NORMAL_LIST_PAGE].GetMissPage() - 1) * PAGE_SIZE
@ -2589,23 +2661,25 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) {
back, _ := NormalListMap[NORMAL_LIST_PAGE].GetLast() back, _ := NormalListMap[NORMAL_LIST_PAGE].GetLast()
if nil == back || 1 == back.Value.(*PageNode).PageIndex || if nil == back || 1 == back.Value.(*PageNode).PageIndex ||
MUSIC_LIST_NULL == PlayListSrcRec.MusicSrc { MUSIC_LIST_NULL == PlayListSrcRec.MusicSrc {
tmpCurPos, err := LocalMusicList[curMusicList].GetFirst() if CurPlayingMode != LIST_ORDER_PLAY {
if nil != err { tmpCurPos, err := LocalMusicList[curMusicList].GetFirst()
log.Println(log.ErrorLog, err.Error()) if nil != err {
return ACTION_NULL, err log.Println(log.ErrorLog, err.Error())
} return ACTION_NULL, err
LocalMusicList[curMusicList].SetCurPos(tmpCurPos) }
LocalMusicList[curMusicList].SetCurPos(tmpCurPos)
if LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo).CanPlay { if LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo).CanPlay {
} else { } else {
LocalMusicList[curMusicList].GetValidNext() LocalMusicList[curMusicList].GetValidNext()
}
songId = LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo)
} }
log.Println(log.DebugLog, "loop list for only one list, one page") //开始重复播放,有且只有一个歌单,只有一页 log.Println(log.DebugLog, "loop list for only one list, one page") //开始重复播放,有且只有一个歌单,只有一页
isRepeat = true isRepeat = true
songId = LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo)
} else { } else {
if CurPlayingMode != LIST_ORDER_PLAY { if CurPlayingMode != LIST_ORDER_PLAY {
// 拉取第一页 // 拉取第一页
@ -2650,9 +2724,14 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) {
if ACTION_NEXT_LIST_REPLACE_LIST == action { if ACTION_NEXT_LIST_REPLACE_LIST == action {
PlayListSrcRec.MusicListIdIndex += 1 PlayListSrcRec.MusicListIdIndex += 1
} else if ACTION_CYCLY_TO_FRONT_LIST_REPLACE_LIST == action { } else if ACTION_CYCLY_TO_FRONT_LIST_REPLACE_LIST == action {
PlayListSrcRec.MusicListIdIndex = 0 log.Println(log.DebugLog, "loop list for get front list")
log.Println(log.DebugLog, "loop list for get front list") //开始重复播放,重新播放第一个歌单
isRepeat = true isRepeat = true
if CurPlayingMode == LIST_ORDER_PLAY {
break
}
//开始重复播放,重新播放第一个歌单
PlayListSrcRec.MusicListIdIndex = 0
} }
var listCnt MusicLenType = 0 var listCnt MusicLenType = 0
@ -2710,10 +2789,13 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) {
// 当前播放的是我的歌单,在创建的歌单和收藏的歌单之间循环 // 当前播放的是我的歌单,在创建的歌单和收藏的歌单之间循环
action = ACTION_USER_LIST_CYCLE action = ACTION_USER_LIST_CYCLE
} else { } else {
// 歌单播放完毕,且后续没有歌单,重新播放第一个歌单
action = ACTION_CYCLY_TO_FRONT_LIST_REPLACE_LIST
log.Println(log.DebugLog, "loop list for get front list") log.Println(log.DebugLog, "loop list for get front list")
isRepeat = true isRepeat = true
if CurPlayingMode == LIST_ORDER_PLAY {
break
}
// 歌单播放完毕,且后续没有歌单,重新播放第一个歌单
action = ACTION_CYCLY_TO_FRONT_LIST_REPLACE_LIST
} }
} else { } else {
//下一个歌单 //下一个歌单
@ -2733,6 +2815,9 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) {
srcType = USER_LISTS_CREATE srcType = USER_LISTS_CREATE
log.Println(log.DebugLog, "loop list for get create user list") log.Println(log.DebugLog, "loop list for get create user list")
isRepeat = true isRepeat = true
if CurPlayingMode == LIST_ORDER_PLAY {
break
}
} else { } else {
srcType = USER_LISTS_COLLECT srcType = USER_LISTS_COLLECT
} }
@ -2768,6 +2853,9 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) {
if srcType != curUserListsType { if srcType != curUserListsType {
log.Println(log.DebugLog, "loop list for no collect user list") //没有收藏的歌单,开始重复播放 log.Println(log.DebugLog, "loop list for no collect user list") //没有收藏的歌单,开始重复播放
isRepeat = true isRepeat = true
if CurPlayingMode == LIST_ORDER_PLAY {
break
}
} }
NormalListMap[NORMAL_LIST_PAGE].Init() NormalListMap[NORMAL_LIST_PAGE].Init()
@ -2787,16 +2875,20 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) {
//第一次循环播放时播放copyright tts //第一次循环播放时播放copyright tts
var isFirstRepeat bool = false var isFirstRepeat bool = false
if isRepeat { if isRepeat {
if CurPlayingMode == LIST_ORDER_PLAY && PlayListSrcRec.BizType != BIZ_TYPE_MUSIC { if CurPlayingMode == LIST_ORDER_PLAY {
if schedule.GetCurPlayer().IsPlaying() { if schedule.GetCurPlayer().IsPlaying() {
sendMusicCmd(CMD_PLAYER_PAUSE) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PAUSE)
} }
log.Println(log.DebugLog, "play list end because list order play mode") log.Println(log.DebugLog, "play list end because list order play mode")
//push tts to server var noNextOne string
http.InformMsgToServer(http.Type_Inform_TtsDelay, TTS_TEXT_LAST_RADIO) if PlayListSrcRec.BizType == BIZ_TYPE_MUSIC {
noNextOne = TTS_TEXT_LAST_MUSIC
} else {
noNextOne = TTS_TEXT_LAST_RADIO
}
schedule.PlayNoticeAsync(AdSrcType_TTS, TTS_TEXT_LAST_RADIO, CONST_AUDIO_ID, true, nil, schedule.PlayNoticeAsync(AdSrcType_TTS, noNextOne, CONST_AUDIO_ID, true, nil,
func(id uint32, reason schedule.NoticeStopReason) { func(id uint32, reason schedule.NoticeStopReason) {
switch reason { switch reason {
case schedule.NoticeStart_Play: case schedule.NoticeStart_Play:
@ -2809,11 +2901,22 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) {
ttsExecVuiStop() ttsExecVuiStop()
//schedule.SendSCmd(schedule.SCMD_MusicPlayer_Play, nil) //schedule.SendSCmd(schedule.SCMD_MusicPlayer_Play, nil)
sendMusicCmd(CMD_PLAYER_PLAY) if !PlayListSrcRec.ListHasEnd {
sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY)
}
default: default:
} }
}) })
//push tts to server
if rspId == CONST_AUDIO_ID {
http.InformLocalMsgToServer(http.Type_Inform_TtsPush, int(MSC_CMD_NEXT), TTS_MUSIC_NEXT, noNextOne) //快捷指令上传信息流
} else {
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: rspId, Cmd: int(MSC_CMD_NEXT), Data: noNextOne, Tts: noNextOne,
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING})
}
return ACTION_NULL, nil return ACTION_NULL, nil
} }
if needPlayCopyrightTTs == true && len(tts) == 0 && len(ttsUrl) == 0 { if needPlayCopyrightTTs == true && len(tts) == 0 && len(ttsUrl) == 0 {
@ -2902,6 +3005,8 @@ func commonPlayApi(arg commonPlayApiArg) error {
MusicActionSrcNew = &arg.actionSrc MusicActionSrcNew = &arg.actionSrc
} }
//log.Println(log.ErrorLog, "PlayListSrcRec.MusicListId:", *PlayListSrcRec.MusicListId)
var tts *string = nil var tts *string = nil
var ttsR *string = &arg.tts var ttsR *string = &arg.tts
var ttsAdSrcType AdSrcType //混音tts type var ttsAdSrcType AdSrcType //混音tts type
@ -2940,6 +3045,9 @@ func commonPlayApi(arg commonPlayApiArg) error {
if arg.songId != nil { if arg.songId != nil {
log.Printf(log.DebugLog, "common Play:song will play:%+v\n", arg.songId) log.Printf(log.DebugLog, "common Play:song will play:%+v\n", arg.songId)
if SongInfo, err := GetCurWifiSongInfo(); err == nil {
arg.songId.AlbumId = SongInfo.AlbumId
}
} else { } else {
log.Println(log.DebugLog, "common Play:songId is nil") log.Println(log.DebugLog, "common Play:songId is nil")
} }
@ -2992,7 +3100,7 @@ func commonPlayApi(arg commonPlayApiArg) error {
" musicListLen:", MusicLenType(LocalMusicList[curMusicList].List.Len())) " musicListLen:", MusicLenType(LocalMusicList[curMusicList].List.Len()))
if !found || musicCnt >= MusicLenType(LocalMusicList[curMusicList].List.Len()) { if !found || musicCnt >= MusicLenType(LocalMusicList[curMusicList].List.Len()) {
searchPage: searchPage:
// case 1: 歌单中还有分页需要处理 // case 1: 歌单中还有分页需要处理
if denyTimesCnt < DENY_MAX_TIMES && (NormalListMap[NORMAL_LIST_PAGE].HasMore || if denyTimesCnt < DENY_MAX_TIMES && (NormalListMap[NORMAL_LIST_PAGE].HasMore ||
pageCnt < NormalListMap[NORMAL_LIST_PAGE].MaxPage) { pageCnt < NormalListMap[NORMAL_LIST_PAGE].MaxPage) {
denyTimesCnt++ denyTimesCnt++
@ -3022,9 +3130,13 @@ func commonPlayApi(arg commonPlayApiArg) error {
// 本地歌单列表中还有歌单待拉取 // 本地歌单列表中还有歌单待拉取
PlayListSrcRec.MusicListIdIndex += 1 PlayListSrcRec.MusicListIdIndex += 1
if PlayListSrcRec.MusicListIdIndex >= PlayListSrcRec.MusicListIdsLen { if PlayListSrcRec.MusicListIdIndex >= PlayListSrcRec.MusicListIdsLen {
PlayListSrcRec.MusicListIdIndex = 0 log.Println(log.DebugLog, "loop list for get front list")
log.Println(log.DebugLog, "loop list for get front list") //开始重复播放,重新播放第一个歌单
isRepeat = true isRepeat = true
if CurPlayingMode == LIST_ORDER_PLAY {
goto out
}
//开始重复播放,重新播放第一个歌单
PlayListSrcRec.MusicListIdIndex = 0
} }
list, err := GetMusicListNew(PlayerType_Wifi, false, http.MusicListServerType{ list, err := GetMusicListNew(PlayerType_Wifi, false, http.MusicListServerType{
Src: getMusicSrcType(PlayerType_Wifi), Src: getMusicSrcType(PlayerType_Wifi),
@ -3098,9 +3210,12 @@ func commonPlayApi(arg commonPlayApiArg) error {
log.Printf(log.DebugLog, "play user lists, need to pull more, type: %d\n", arg.srcType) log.Printf(log.DebugLog, "play user lists, need to pull more, type: %d\n", arg.srcType)
listIndex = 0 listIndex = 0
if USER_LISTS_COLLECT == curUserListsType { if USER_LISTS_COLLECT == curUserListsType {
curUserListsType = USER_LISTS_CREATE
log.Println(log.DebugLog, "loop list for get create user list") log.Println(log.DebugLog, "loop list for get create user list")
isRepeat = true isRepeat = true
if CurPlayingMode == LIST_ORDER_PLAY {
goto out
}
curUserListsType = USER_LISTS_CREATE
} else { } else {
curUserListsType = USER_LISTS_COLLECT curUserListsType = USER_LISTS_COLLECT
} }
@ -3114,11 +3229,14 @@ func commonPlayApi(arg commonPlayApiArg) error {
if curUserListsType != UserListsType { if curUserListsType != UserListsType {
log.Println(log.DebugLog, "loop list for no collect user list") //没有收藏的歌单,开始重复播放 log.Println(log.DebugLog, "loop list for no collect user list") //没有收藏的歌单,开始重复播放
isRepeat = true isRepeat = true
if CurPlayingMode == LIST_ORDER_PLAY {
goto out
}
} }
listCnt = 1 listCnt = 1
log.Println(log.ErrorLog, "list Cnt:", listCnt, ", listIdsLen:", PlayListSrcRec.MusicListIdsLen, log.Println(log.ErrorLog, "list Cnt:", listCnt, ", listIdsLen:", PlayListSrcRec.MusicListIdsLen,
"GetCurPos:", LocalMusicList[GetMusicListIndex()].GetCurPos()) ", GetCurPos:", LocalMusicList[GetMusicListIndex()].GetCurPos())
if nil != LocalMusicList[GetMusicListIndex()].GetCurPos() { if nil != LocalMusicList[GetMusicListIndex()].GetCurPos() {
arg.songId = LocalMusicList[GetMusicListIndex()].GetCurPos().Value.(*SongInfo) arg.songId = LocalMusicList[GetMusicListIndex()].GetCurPos().Value.(*SongInfo)
goto searchMusic goto searchMusic
@ -3171,16 +3289,16 @@ func commonPlayApi(arg commonPlayApiArg) error {
goto out goto out
} }
specialOut: specialOut:
//// case 4: 错误信息播报 //// case 4: 错误信息播报
// log.Printf(log.DebugLog, "\n can not play because of lists is invalid:%v srcType:%d\n", // log.Printf(log.DebugLog, "\n can not play because of lists is invalid:%v srcType:%d\n",
// MusicErrTtsMap[string(arg.srcType)], arg.srcType) // MusicErrTtsMap[string(arg.srcType)], arg.srcType)
// //
// forcePausePlayer(PlayerType_Wifi) // forcePausePlayer(PlayerType_Wifi)
// //
// mscToastTts(MusicErrTtsMap[string(arg.srcType)], CONST_AUDIO_ID, true, false, nil) // mscToastTts(MusicErrTtsMap[string(arg.srcType)], CONST_AUDIO_ID, true, false, nil)
// ResetWifiPlayer() // ResetWifiPlayer()
// return MusicList_ERR_MUSIC_NULL // return MusicList_ERR_MUSIC_NULL
// prd reverse 20180428 : 拉取特定的接口如果失败播放备用的tts // prd reverse 20180428 : 拉取特定的接口如果失败播放备用的tts
log.Println(log.WarningLog, "get special music list from server...") log.Println(log.WarningLog, "get special music list from server...")
// case 4: 拉取特定接口 // case 4: 拉取特定接口
PlayListSrcRec.CopyrightTts.TtsType = 0 //开始拉取特殊通道清除版权的ttstype标记 PlayListSrcRec.CopyrightTts.TtsType = 0 //开始拉取特殊通道清除版权的ttstype标记
@ -3235,6 +3353,62 @@ func commonPlayApi(arg commonPlayApiArg) error {
out: out:
} }
if isRepeat {
if CurPlayingMode == LIST_ORDER_PLAY {
log.Println(log.DebugLog, "play list end because list order play mode")
if curSongInfo != nil && curSongInfo.MusicListId != *PlayListSrcRec.MusicListId {
//如果是版权问题引起的这里的list id会恢复回正在播放的listId否则APP歌单列表会错误
log.Println(log.WarningLog, "restore music list id, curSongInfo MusicListId:", curSongInfo.MusicListId,
", PlayListSrcRec.MusicListId:", *PlayListSrcRec.MusicListId)
PlayListSrcRec.MusicListId = &(curSongInfo.MusicListId)
}
//用户主动切换就播报tts
if arg.switchSongByUser {
if schedule.GetCurPlayer().IsPlaying() {
sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PAUSE)
}
var noNextOne string
if PlayListSrcRec.BizType == BIZ_TYPE_MUSIC {
noNextOne = TTS_TEXT_LAST_MUSIC
} else {
noNextOne = TTS_TEXT_LAST_RADIO
}
schedule.PlayNoticeAsync(AdSrcType_TTS, noNextOne, CONST_AUDIO_ID, true, nil,
func(id uint32, reason schedule.NoticeStopReason) {
switch reason {
case schedule.NoticeStart_Play:
ttsExecVuiStart()
case schedule.NoticeStopReason_Complete,
schedule.NoticeStopReason_Interrupt,
schedule.NoticeStopReason_Cancel,
schedule.NoticeStopReason_Error:
ttsExecVuiStop()
//schedule.SendSCmd(schedule.SCMD_MusicPlayer_Play, nil)
if !PlayListSrcRec.ListHasEnd {
sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY)
}
default:
}
})
//push tts to server
if arg.rspId == CONST_AUDIO_ID {
http.InformLocalMsgToServer(http.Type_Inform_TtsPush, int(MSC_CMD_NEXT), TTS_MUSIC_NEXT, noNextOne) //快捷指令上传信息流
} else {
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_NEXT), Data: noNextOne, Tts: noNextOne,
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING})
}
}
return nil
}
}
srcType, isNewHotDailyPlaying := isNewHotDailySrc() srcType, isNewHotDailyPlaying := isNewHotDailySrc()
if isNewHotDailyPlaying && arg.needChangeNHDIndex { if isNewHotDailyPlaying && arg.needChangeNHDIndex {
_, index, ret := LocalMusicList[CUR_MUSIC_LIST].Search(arg.songId, false) _, index, ret := LocalMusicList[CUR_MUSIC_LIST].Search(arg.songId, false)
@ -3283,7 +3457,7 @@ func commonPlayApi(arg commonPlayApiArg) error {
if curSongInfo != nil && curSongInfo.Id == arg.songId.Id && 1 == LocalMusicList[CUR_MUSIC_LIST].GetValidMusicLen() { if curSongInfo != nil && curSongInfo.Id == arg.songId.Id && 1 == LocalMusicList[CUR_MUSIC_LIST].GetValidMusicLen() {
if schedule.GetCurPlayer().IsPlaying() { if schedule.GetCurPlayer().IsPlaying() {
//schedule.SendSCmd(schedule.SCMD_MusicPlayer_Pause, nil)//改为直接发送暂停否则这个命令会比下面的PlayNoticeAsync调度的更晚造成时序错误 //schedule.SendSCmd(schedule.SCMD_MusicPlayer_Pause, nil)//改为直接发送暂停否则这个命令会比下面的PlayNoticeAsync调度的更晚造成时序错误
sendMusicCmd(CMD_PLAYER_PAUSE) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PAUSE)
} }
var listOnlyOne string var listOnlyOne string
@ -3295,14 +3469,6 @@ func commonPlayApi(arg commonPlayApiArg) error {
//当前只有一首歌了播报tts后返回 //当前只有一首歌了播报tts后返回
log.Println(log.DebugLog, "only one song at music list") log.Println(log.DebugLog, "only one song at music list")
if arg.nextOrPreSong {
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_NEXT), Data: listOnlyOne, Tts: listOnlyOne,
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING})
} else {
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_PRE), Data: listOnlyOne, Tts: listOnlyOne,
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING})
}
schedule.PlayNoticeAsync(AdSrcType_TTS, listOnlyOne, CONST_AUDIO_ID, true, nil, schedule.PlayNoticeAsync(AdSrcType_TTS, listOnlyOne, CONST_AUDIO_ID, true, nil,
func(id uint32, reason schedule.NoticeStopReason) { func(id uint32, reason schedule.NoticeStopReason) {
switch reason { switch reason {
@ -3316,11 +3482,24 @@ func commonPlayApi(arg commonPlayApiArg) error {
ttsExecVuiStop() ttsExecVuiStop()
//schedule.SendSCmd(schedule.SCMD_MusicPlayer_Play, nil) //schedule.SendSCmd(schedule.SCMD_MusicPlayer_Play, nil)
sendMusicCmd(CMD_PLAYER_PLAY) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY)
default: default:
} }
}) })
//push tts to server
if arg.nextOrPreSong {
if arg.rspId == CONST_AUDIO_ID {
http.InformLocalMsgToServer(http.Type_Inform_TtsPush, int(MSC_CMD_NEXT), TTS_MUSIC_NEXT, listOnlyOne) //快捷指令上传信息流
} else {
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_NEXT), Data: listOnlyOne, Tts: listOnlyOne,
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING})
}
} else {
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_PRE), Data: listOnlyOne, Tts: listOnlyOne,
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING})
}
return nil return nil
} else { } else {
@ -3340,16 +3519,24 @@ func commonPlayApi(arg commonPlayApiArg) error {
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_NEXT), Data: *ttsR, Tts: *ttsR, http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_NEXT), Data: *ttsR, Tts: *ttsR,
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING,}) PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING,})
}*/ }*/
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_NEXT), Data: *ttsR, Tts: *ttsR, if arg.rspId == CONST_AUDIO_ID {
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING}) http.InformLocalMsgToServer(http.Type_Inform_TtsPush, int(MSC_CMD_NEXT), *ttsR, *ttsR) //快捷指令上传信息流
} else {
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_NEXT), Data: *ttsR, Tts: *ttsR,
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING})
}
} else { } else {
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_PRE), Data: *ttsR, Tts: *ttsR, http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_PRE), Data: *ttsR, Tts: *ttsR,
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING}) PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING})
} }
} else { } else {
if arg.nextOrPreSong { if arg.nextOrPreSong {
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_NEXT), Data: TTS_MUSIC_NEXT, Tts: TTS_MUSIC_NEXT, if arg.rspId == CONST_AUDIO_ID {
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING}) http.InformLocalMsgToServer(http.Type_Inform_TtsPush, int(MSC_CMD_NEXT), TTS_MUSIC_NEXT, TTS_MUSIC_NEXT) //快捷指令上传信息流
} else {
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_NEXT), Data: TTS_MUSIC_NEXT, Tts: TTS_MUSIC_NEXT,
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING})
}
} else { } else {
http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_PRE), Data: TTS_MUSIC_PRE, Tts: TTS_MUSIC_PRE, http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_PRE), Data: TTS_MUSIC_PRE, Tts: TTS_MUSIC_PRE,
PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING}) PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING})
@ -3386,6 +3573,10 @@ func commonPlayApi(arg commonPlayApiArg) error {
} }
curSongInfo = arg.songId curSongInfo = arg.songId
if PlayListSrcRec.MusicListId != nil {
//备份listId由于版权问题顺序播放的时候如果版权有问题list可能被覆盖会造成同步listId不对需要恢复listId
curSongInfo.MusicListId = *PlayListSrcRec.MusicListId
}
if arg.prepare { if arg.prepare {
/* 准备下一首是播放器自己调度的,播放器内部修改一下状态 */ /* 准备下一首是播放器自己调度的,播放器内部修改一下状态 */
status := PlayerHander[PlayerType_Wifi].GetPlayerStatus() status := PlayerHander[PlayerType_Wifi].GetPlayerStatus()
@ -3396,7 +3587,7 @@ func commonPlayApi(arg commonPlayApiArg) error {
status.PlayerId = uint32(PlayerType_Wifi) status.PlayerId = uint32(PlayerType_Wifi)
PlayerHander[PlayerType_Wifi].SetPlayerStatus(status) PlayerHander[PlayerType_Wifi].SetPlayerStatus(status)
sendMusicCmd(CMD_PLAYER_PERPARE_NEXT, &arg.songId.Id, arg.songUrl, tts, ttsAdSrcType, arg.songId.Duration, arg.songId.Gain, arg.songId.BGUrl) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PERPARE_NEXT, &arg.songId.Id, arg.songUrl, tts, ttsAdSrcType, arg.songId.Duration, arg.songId.Gain, arg.songId.BGUrl)
} else { } else {
if backGroundPlayerTest && nil == arg.songId.BGUrl && nil != tts && len(*tts) > 0 { // 有tts播报的音乐播放背景音测试 if backGroundPlayerTest && nil == arg.songId.BGUrl && nil != tts && len(*tts) > 0 { // 有tts播报的音乐播放背景音测试
bgUrl := vui.SoundNotice_Volume.GetPath() bgUrl := vui.SoundNotice_Volume.GetPath()
@ -3404,14 +3595,14 @@ func commonPlayApi(arg commonPlayApiArg) error {
} }
if arg.filterTts && !isFirstRepeat { if arg.filterTts && !isFirstRepeat {
sendMusicCmd(CMD_PLAYER_PLAY, &arg.songId.Id, arg.songUrl, nil, ttsAdSrcType, arg.songId.Duration, arg.songId.Gain, arg.songId.BGUrl) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY, &arg.songId.Id, arg.songUrl, nil, ttsAdSrcType, arg.songId.Duration, arg.songId.Gain, arg.songId.BGUrl)
} else { } else {
if nil != tts && len(*tts) > 0 { if nil != tts && len(*tts) > 0 {
if strings.Contains(*tts, "%s") && songDetail != nil { //判断服务器下发的tts里是否有%s字段 if strings.Contains(*tts, "%s") && songDetail != nil { //判断服务器下发的tts里是否有%s字段
*tts = fmt.Sprintf(*tts, songDetail.Song.Name) *tts = fmt.Sprintf(*tts, songDetail.Song.Name)
} }
} }
sendMusicCmd(CMD_PLAYER_PLAY, &arg.songId.Id, arg.songUrl, tts, ttsAdSrcType, arg.songId.Duration, arg.songId.Gain, arg.songId.BGUrl, MusicCmdExtra{RespId: arg.rspId}) sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY, &arg.songId.Id, arg.songUrl, tts, ttsAdSrcType, arg.songId.Duration, arg.songId.Gain, arg.songId.BGUrl, MusicCmdExtra{RespId: arg.rspId})
} }
} }
errPush := LocalMusicList[PLAYSONG_MUSIC_LIST].Push(arg.songId, true) errPush := LocalMusicList[PLAYSONG_MUSIC_LIST].Push(arg.songId, true)
@ -3730,20 +3921,30 @@ func getNextPrevAction(needNextAction bool) MusicChangeAction {
ret = ACTION_PLAY_BACK ret = ACTION_PLAY_BACK
} else if MUSIC_SHARE_RCMD == PlayListSrcRec.MusicSrc { } else if MUSIC_SHARE_RCMD == PlayListSrcRec.MusicSrc {
ret = ACTION_ADD_LIST_MUSIC_SHARE ret = ACTION_ADD_LIST_MUSIC_SHARE
} else if NormalListMap[NORMAL_LIST_PAGE].HasMore { } else if NormalListMap[NORMAL_LIST_PAGE].CurPos.Value.(*PageNode).PageIndex >= 2 {
// 还有分页 // 前一分页
ret = ACTION_NEXT_PAGE_REPLACE_LIST ret = ACTION_PRE_PAGE_REPLACE_LIST
} else if MUSIC_LIST_WORD == PlayListSrcRec.MusicSrc || MUSIC_LIST_SERACH_WORD == PlayListSrcRec.MusicSrc { } else if MUSIC_LIST_WORD == PlayListSrcRec.MusicSrc || MUSIC_LIST_SERACH_WORD == PlayListSrcRec.MusicSrc {
ret = ACTION_PLAY_BACK ret = ACTION_PLAY_BACK
} else if nil != back && } else if nil != back &&
back.Value.(*PageNode).PageIndex != tmpMaxpage { back.Value.(*PageNode).PageIndex != tmpMaxpage {
log.Println(log.ErrorLog, "pre miss page inex", back.Value.(*PageNode).PageIndex,
", list len:", NormalListMap[NORMAL_LIST_PAGE].List.Len(),
", max page:", NormalListMap[NORMAL_LIST_PAGE].MaxPage)
// 有缺失的分页,拉取分页 // 有缺失的分页,拉取分页
ret = ACTION_MISS_PAGE_REPLACE_LIST ret = ACTION_MISS_PAGE_REPLACE_LIST
} else { } else {
if 1 == MusicLenType(NormalListMap[NORMAL_LIST_PAGE].List.Len()) || if 1 == MusicLenType(NormalListMap[NORMAL_LIST_PAGE].List.Len()) ||
MUSIC_LIST_NULL == PlayListSrcRec.MusicSrc { MUSIC_LIST_NULL == PlayListSrcRec.MusicSrc {
// 如果只有1页 / 如果都是单曲插入直接播放最后1首 if NormalListMap[NORMAL_LIST_PAGE].HasMore {
ret = ACTION_PLAY_BACK // 当前只有一页信息,而且还有下一页,只能拉取下一分页
ret = ACTION_LAST_PAGE
} else {
// 如果只有1页 / 如果都是单曲插入直接播放最后1首
log.Println(log.ErrorLog, "len list:", MusicLenType(NormalListMap[NORMAL_LIST_PAGE].List.Len()), ", PlayListSrcRec.MusicSrc:", PlayListSrcRec.MusicSrc)
ret = ACTION_PLAY_BACK
}
} else { } else {
ret = ACTION_LAST_PAGE ret = ACTION_LAST_PAGE
} }
@ -3971,8 +4172,12 @@ func ResetWifiPlayer() {
MusicListIdsLen: INVALID_MUSIC_LEN, HasInsert: false, HasMore: false, UpdateTime: 0, MusicSrc: MUSIC_LIST_NULL} MusicListIdsLen: INVALID_MUSIC_LEN, HasInsert: false, HasMore: false, UpdateTime: 0, MusicSrc: MUSIC_LIST_NULL}
wifiPlayerSt = PlayerStatus{PlayerSrc: WIFI_SRC, MusicId: nil, MusicListId: nil, ContinuousTaskSt: MUSIC_ST_IDLE, CurPlayingPos: 0, wifiPlayerSt = PlayerStatus{PlayerSrc: WIFI_SRC, MusicId: nil, MusicListId: nil, ContinuousTaskSt: MUSIC_ST_IDLE, CurPlayingPos: 0,
TaskField: FIELD_NULL, TaskField: FIELD_NULL,
SingleTaskSt: AUDIO_ST_IDLE} SingleTaskSt: AUDIO_ST_IDLE}
status := PlayerHander[PlayerType_Wifi].GetPlayerStatus()
status.Status = MUSIC_ST_IDLE
PlayerHander[PlayerType_Wifi].SetPlayerStatus(status)
log.Println(log.DebugLog, "unlock") log.Println(log.DebugLog, "unlock")
} }

17
app/netease_voice_common_module/src/yunxin.c Normal file → Executable file
View File

@ -373,13 +373,20 @@ static void Netease_yunxin_msgcb(const char *content,
// n_toast("%s\n", json_dumps(js, 0)); // n_toast("%s\n", json_dumps(js, 0));
char *body = NULL; char *body = NULL;
char *talk_id = NULL; char *talk_id = NULL;
json_unpack(js, "{s:{s:s, s:s}}", kNIMSessionListContent, long long ts = 0;
kNIMSessionMsgBody, &body, "talk_id", &talk_id); long long cTs = Netease_gettime_ms();
int offline = -1;
json_unpack(js, "{s:{s:s, s:s, s:I, s:i}}", kNIMSessionListContent,
kNIMSessionMsgBody, &body, "talk_id", &talk_id, "time", &ts,
"offline_msg", &offline);
if (body && talk_id) { if (body && talk_id) {
n_toast("\nBody:%s\n body-len:%d\n Id:%s\n", body, strlen(body), n_toast("\nBody:%s\n body-len:%d\n Id:%s "
talk_id); "offline:%d\ntimeStamp:%llu curTs:%llu\n",
body, strlen(body), talk_id, offline, ts, cTs);
Netease_Dbus_Send_CMD(MODULE_VOICEENGINE, MODULE_CONTROLLER, Netease_Dbus_Send_CMD(MODULE_VOICEENGINE, MODULE_CONTROLLER,
CMD_YUNXIN_RECVMSG, body, strlen(body)); CMD_YUNXIN_RECVMSG, content, strlen(content));
} else { } else {
n_error("Decode error!!!!!\n"); n_error("Decode error!!!!!\n");
} }