diff --git a/app/netease_control_center_common_module/src/netease_control_center/globals/bleWifiModule.go b/app/netease_control_center_common_module/src/netease_control_center/globals/bleWifiModule.go old mode 100644 new mode 100755 index 9ffb5a9..f6a7a85 --- a/app/netease_control_center_common_module/src/netease_control_center/globals/bleWifiModule.go +++ b/app/netease_control_center_common_module/src/netease_control_center/globals/bleWifiModule.go @@ -3,27 +3,29 @@ package globals type APPInitStatus int const ( - APPInitStatus_UNKNOW APPInitStatus = -1 - APPInitStatus_SUCCESS APPInitStatus = 0 - APPInitStatus_SYSTEM_ERROR APPInitStatus = 0xf001 - APPInitStatus_FMT_NOTMATCH APPInitStatus = 0xf002 - APPInitStatus_JSON_ERROR APPInitStatus = 0xf003 - APPInitStatus_ARG_ERROR APPInitStatus = 0xf004 - APPInitStatus_SSID_NOTFOUND APPInitStatus = 0xf005 - APPInitStatus_PASSWD_ERROR APPInitStatus = 0xf006 - APPInitStatus_WIFI_BUSY APPInitStatus = 0xf007 - APPInitStatus_CONNECT_TIMEOUT APPInitStatus = 0xf008 - APPInitStatus_WIFI_NOT_RESPONSE APPInitStatus = 0xf009 - APPInitStatus_ENCRYPT_NOT_SUPPORT APPInitStatus = 0xf00a - APPInitStatus_OTHER_CONNECT_ERROR APPInitStatus = 0xf00b - APPInitStatus_PARING_NOT_RESPONSE APPInitStatus = 0xf00c - APPInitStatus_REQUEST_SERVER_ERROR APPInitStatus = 0xf00d - APPInitStatus_NOT_IN_WIFIPARING APPInitStatus = 0xf00e - APPInitStatus_BINDNUM_BEYOND_MAX APPInitStatus = 0xf00f - APPInitStatus_YUNXIN_FAIL APPInitStatus = 0xf010 - APPInitStatus_ACCOUNT_NOT_EXIST APPInitStatus = 0xf011 - APPInitStatus_SERVER_ARG_ERROR APPInitStatus = 0xf012 - APPInitStatus_SERVER_SYSTEM_ERROR APPInitStatus = 0xf013 + APPInitStatus_UNKNOW APPInitStatus = -1 + APPInitStatus_SUCCESS APPInitStatus = 0 + APPInitStatus_SYSTEM_ERROR APPInitStatus = 0xf001 + APPInitStatus_FMT_NOTMATCH APPInitStatus = 0xf002 + APPInitStatus_JSON_ERROR APPInitStatus = 0xf003 + APPInitStatus_ARG_ERROR APPInitStatus = 0xf004 + APPInitStatus_SSID_NOTFOUND APPInitStatus = 0xf005 + APPInitStatus_PASSWD_ERROR APPInitStatus = 0xf006 + APPInitStatus_WIFI_BUSY APPInitStatus = 0xf007 + APPInitStatus_CONNECT_TIMEOUT APPInitStatus = 0xf008 + APPInitStatus_WIFI_NOT_RESPONSE APPInitStatus = 0xf009 + APPInitStatus_ENCRYPT_NOT_SUPPORT APPInitStatus = 0xf00a + APPInitStatus_OTHER_CONNECT_ERROR APPInitStatus = 0xf00b + APPInitStatus_PARING_NOT_RESPONSE APPInitStatus = 0xf00c + APPInitStatus_REQUEST_SERVER_ERROR APPInitStatus = 0xf00d + APPInitStatus_NOT_IN_WIFIPARING APPInitStatus = 0xf00e + APPInitStatus_BINDNUM_BEYOND_MAX APPInitStatus = 0xf00f + APPInitStatus_YUNXIN_FAIL APPInitStatus = 0xf010 + APPInitStatus_ACCOUNT_NOT_EXIST APPInitStatus = 0xf011 + APPInitStatus_SERVER_ARG_ERROR APPInitStatus = 0xf012 + APPInitStatus_SERVER_SYSTEM_ERROR APPInitStatus = 0xf013 + APPInitStatus_SERVER_ACCOUNT_BOUNDED APPInitStatus = 0xf014 + APPInitStatus_SERVER_DEVICE_BOUNDED APPInitStatus = 0xf015 APPInitStatus_BLE_DISCONNECT APPInitStatus = 0xffff ) diff --git a/app/netease_control_center_common_module/src/netease_control_center/globals/deviceStatus.go b/app/netease_control_center_common_module/src/netease_control_center/globals/deviceStatus.go index e6b931d..613fb68 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/globals/deviceStatus.go +++ b/app/netease_control_center_common_module/src/netease_control_center/globals/deviceStatus.go @@ -50,6 +50,18 @@ var ( CurMcuVersion string 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 diff --git a/app/netease_control_center_common_module/src/netease_control_center/globals/errorDefines.go b/app/netease_control_center_common_module/src/netease_control_center/globals/errorDefines.go index 378338c..e2b11c2 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/globals/errorDefines.go +++ b/app/netease_control_center_common_module/src/netease_control_center/globals/errorDefines.go @@ -19,7 +19,7 @@ var ( Tts_ERR_NODE_NULL = errors.New("节点信息为空") - Server_ERR_RET = errors.New("网络有点抖动,暂时没法为你继续播放啦") //请求音乐失败,服务器下发数据异常 + Server_ERR_RET = errors.New("暂时没办法为你继续播放了,待会儿再试试吧") //请求音乐失败,服务器下发数据异常 No_Permission_Err = errors.New("付费歌曲或者下架歌曲") Repeat_ERR_NULL = errors.New("没有可执行任务") diff --git a/app/netease_control_center_common_module/src/netease_control_center/globals/musicList.go b/app/netease_control_center_common_module/src/netease_control_center/globals/musicList.go index d0f48e9..dd791c6 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/globals/musicList.go +++ b/app/netease_control_center_common_module/src/netease_control_center/globals/musicList.go @@ -490,6 +490,7 @@ func (this *NormalList) Init() { this.List.Init() this.HasMore = false this.CurPos = nil + this.MaxPage = 0 } func (this *NormalList) GetFirst() (*list.Element, error) { diff --git a/app/netease_control_center_common_module/src/netease_control_center/globals/musicListStruct.go b/app/netease_control_center_common_module/src/netease_control_center/globals/musicListStruct.go index ef88fcd..2492266 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/globals/musicListStruct.go +++ b/app/netease_control_center_common_module/src/netease_control_center/globals/musicListStruct.go @@ -99,6 +99,7 @@ type PlayListSrcInfo struct { BizType BizTypeDef Order MusicLenType + ListHasEnd bool //顺序播放的时候,是否播放完成 } // 本地存储播放列表的数据结构 @@ -237,6 +238,30 @@ type ServerSongPlay struct { 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 { IsAlarm bool @@ -451,6 +476,8 @@ const ( ACTION_ADD_LIST_MUSIC_SHARE // 13 + ACTION_PRE_PAGE_REPLACE_LIST //14 前一页 page + ACTION_STOP_PLAYER // 停止播放器 ACTION_NULL diff --git a/app/netease_control_center_common_module/src/netease_control_center/globals/playerDatastruct.go b/app/netease_control_center_common_module/src/netease_control_center/globals/playerDatastruct.go index 3b4c0ec..ac77004 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/globals/playerDatastruct.go +++ b/app/netease_control_center_common_module/src/netease_control_center/globals/playerDatastruct.go @@ -1,6 +1,9 @@ package globals -import "strings" +import ( + "strings" + "time" +) type PlayerType uint32 @@ -52,6 +55,8 @@ const ( WAKEUP_AUDIO_ID string = "wakeup_audio_uuid" SUB_AUDIO_ID string = "audio_uuid" + + BT_WIFI_RESUME_TIME_LIMIT time.Duration = 30 * time.Second ) const ( @@ -89,4 +94,6 @@ var ( KeyVolTest bool = false GetFrom163Test bool = true + + BtAvkDataRecving bool = false ) diff --git a/app/netease_control_center_common_module/src/netease_control_center/globals/serverConst.go b/app/netease_control_center_common_module/src/netease_control_center/globals/serverConst.go index 3ead964..43da592 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/globals/serverConst.go +++ b/app/netease_control_center_common_module/src/netease_control_center/globals/serverConst.go @@ -15,6 +15,8 @@ const ( ERR_ACCOUNT_NOT_EXIST ErrCode = 1003 ERR_SERVER_ARGS_ERROR ErrCode = 3000 ERR_BIND_ACCOUNT_BEYOND_MAX ErrCode = 2000 + ERR_DEVICE_BOUNDED ErrCode = 4100 + ERR_ACCOUNT_BOUNDED ErrCode = 4101 ) type Cmd int @@ -62,6 +64,7 @@ const ( const ( MSC_CMD_QUERY_VOL Cmd = 3025 MSC_CMD_MODE_CHANGE Cmd = 3026 + MSC_CMD_ORDER_PLAY Cmd = 3027 //顺序播放 ) const ( MSC_CMD_LIGHT_ON Cmd = 3010 + iota @@ -94,6 +97,7 @@ const ( const ( MSC_CMD_IOTWIFIPARING Cmd = 3700 + MSC_CMD_BTONWIFIOFF Cmd = 3701 ) const ( diff --git a/app/netease_control_center_common_module/src/netease_control_center/globals/ttsDefines.go b/app/netease_control_center_common_module/src/netease_control_center/globals/ttsDefines.go index 5d1cf3b..05ff1c8 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/globals/ttsDefines.go +++ b/app/netease_control_center_common_module/src/netease_control_center/globals/ttsDefines.go @@ -40,12 +40,13 @@ const ( TTS_REPEAT_NIL = "可惜,这个我帮不到你" TTS_MUSIC_ERR_1 = "当前没有音乐内容,想听音乐你可以说,嘀嗒嘀嗒,来点音乐" - TTS_MUSIC_ERR_2 = "抱歉,当前音乐来自手机等设备,我也无法切换播放模式" - TTS_MUSIC_ERR_3 = "抱歉,当前音乐来自手机等设备,我也无法为你收藏" + TTS_MUSIC_ERR_2 = "抱歉,当前内容来自手机等设备,我也无法切换播放模式" + TTS_MUSIC_ERR_3 = "抱歉,当前内容来自手机等设备,我也无法为你收藏" TTS_MUSIC_ERR_4 = "没有播放中的音乐,无法收藏" TTS_MUSIC_ERR_5 = "没有音乐可以播放,你可以说:嘀嗒嘀嗒,来点音乐" - TTS_DLNA_ERR_1 = "播放源失效,请点击下一首继续" + //TTS_DLNA_ERR_1 = "播放源失效,请点击下一首继续" + TTS_DLNA_ERR_1 = "很抱歉,暂时无法播放这首歌,想听歌的话可以对我说,播放每日推荐" TTS_MUSIC_LIST_ONE = "现在只有一首歌了,想听更多歌曲的话可以对我说,嘀嗒嘀嗒,来首歌" TTS_RADIO_LIST_ONE = "现在只有一个节目了,为你继续播放" @@ -55,9 +56,17 @@ const ( TTS_TEXT_BT_CONNECT_CONFLICT = "当前音箱蓝牙已被占用,请先断开" - TTS_TEXT_RADIO_END = "这个节目已经播放完了,你可以尝试点播新的内容" + TTS_TEXT_RADIO_END = "好的,不过你之前点的节目已经播完了,一起回味下最后收听的内容" + TTS_TEXT_MUSIC_END = "列表中歌曲已全部播完" TTS_TEXT_LAST_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 ( diff --git a/app/netease_control_center_common_module/src/netease_control_center/globals/vboxStatusData.go b/app/netease_control_center_common_module/src/netease_control_center/globals/vboxStatusData.go index 47561ae..e087775 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/globals/vboxStatusData.go +++ b/app/netease_control_center_common_module/src/netease_control_center/globals/vboxStatusData.go @@ -6,7 +6,7 @@ import ( ) const ( - BRAODCAST_ST_PERIOD = 10 * time.Second + BRAODCAST_ST_PERIOD = 30 * time.Second ) type MusicFieldSt uint16 @@ -50,6 +50,10 @@ func ResetBroadCastTimer() { BroadcastStTimer.Reset(0) } +func SetBroadCastTimer(afterTime time.Duration) { + BroadcastStTimer.Reset(afterTime) +} + func TrigBroadcastStatus(st VboxBroadcastSt) { st.TimeStamp = time.Now().Unix() select { diff --git a/app/netease_control_center_common_module/src/netease_control_center/globals/yunxinDatastruct.go b/app/netease_control_center_common_module/src/netease_control_center/globals/yunxinDatastruct.go index 50d68ee..62a609a 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/globals/yunxinDatastruct.go +++ b/app/netease_control_center_common_module/src/netease_control_center/globals/yunxinDatastruct.go @@ -1,5 +1,11 @@ package globals +import ( + "time" + "strconv" + "strings" +) + const ( YunxinServerAccount = "000000" ) @@ -16,6 +22,50 @@ type VboxInfo struct { 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 { Cmd Cmd `json:"cmd"` Timestamp int64 `json:"ts"` @@ -69,6 +119,7 @@ const ( YxSCmd_UploadLog YunxinServerCmdId = 8300 //exec vol=0 YxSCmd_RefreshCfglist YunxinServerCmdId = 8302 YxSCmd_IotWifiParingResult YunxinServerCmdId = 8303 + YxSCmd_InBtOnWifiOff YunxinServerCmdId = 8304 YxSCmd_MscTest YunxinServerCmdId = 77777 //exec vol=0 ) diff --git a/app/netease_control_center_common_module/src/netease_control_center/interfaces/eventPoint/ep.go b/app/netease_control_center_common_module/src/netease_control_center/interfaces/eventPoint/ep.go index e10640c..1aadee0 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/interfaces/eventPoint/ep.go +++ b/app/netease_control_center_common_module/src/netease_control_center/interfaces/eventPoint/ep.go @@ -51,7 +51,7 @@ func EpRecord(eventId string, args map[string]interface{}) { log.Println(log.ErrorLog, err) } }() - return + var tmp EventPoint tmp.Base = http.Reqbase args["event"] = eventId diff --git a/app/netease_control_center_common_module/src/netease_control_center/interfaces/http/httpApi.go b/app/netease_control_center_common_module/src/netease_control_center/interfaces/http/httpApi.go index faddf0c..1a0d845 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/interfaces/http/httpApi.go +++ b/app/netease_control_center_common_module/src/netease_control_center/interfaces/http/httpApi.go @@ -8,9 +8,10 @@ import ( type InformType int const ( - Type_Inform_Ota InformType = 103 - Type_Inform_TtsDelay InformType = 108 - Type_Inform_TtsPush InformType = 109 //上传成对出现的tts信息流 + Type_Inform_Ota InformType = 103 + Type_Inform_TtsDelay InformType = 108 + Type_Inform_TtsPush InformType = 109 //上传成对出现的tts信息流 + Type_Inform_BtOnWifiOff InformType = 110 ) const ( Type_Inform_Top3_Play InformType = 104 + iota @@ -44,7 +45,7 @@ func GetWeatherInfo() (*WeatherResp, int, *string, error) { return &res, code, nil, nil } -func InformMsgToServer(informType InformType, data interface{}) { +func InformMsgToServer(informType InformType, data interface{}) error { defer func() { if err := recover(); err != nil { 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 { log.Println(log.DebugLog, "has inform server of data:", data, " rsp:", res) + return err } else { log.Println(log.WarningLog, "inform server failed, data:", data, "code: ", code, " err:", err) + return err } } diff --git a/app/netease_control_center_common_module/src/netease_control_center/interfaces/http/httpDatastruct.go b/app/netease_control_center_common_module/src/netease_control_center/interfaces/http/httpDatastruct.go index a185dba..3d4489d 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/interfaces/http/httpDatastruct.go +++ b/app/netease_control_center_common_module/src/netease_control_center/interfaces/http/httpDatastruct.go @@ -86,6 +86,12 @@ const ( //电台detail接口 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 { @@ -408,6 +414,16 @@ type reqGetRadioPlayListRcmd struct { 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 { AlbumId string `json:"id,omitempty"` Size globals.MusicLenType `json:"size"` @@ -580,6 +596,12 @@ type MusicListServerType struct { NextMusic bool } +//获取歌单信息 +type PlayListServerType struct { + Id *string + ModeId int64 +} + type DataType uint8 const ( diff --git a/app/netease_control_center_common_module/src/netease_control_center/interfaces/http/httpMusic.go b/app/netease_control_center_common_module/src/netease_control_center/interfaces/http/httpMusic.go index 845497a..c009f82 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/interfaces/http/httpMusic.go +++ b/app/netease_control_center_common_module/src/netease_control_center/interfaces/http/httpMusic.go @@ -51,6 +51,9 @@ func init() { 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(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) { @@ -99,6 +102,50 @@ func GetSongDetailInfoDo(id *string) (*ServerSongDetail, int, *string, error) { 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) { var res ServerMusicList var code int diff --git a/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/Core.go b/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/Core.go index 8304c95..d8cc21b 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/Core.go +++ b/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/Core.go @@ -282,6 +282,13 @@ func coreSchedule(cmd SCmdStruct) { if curRunningPlayer != player { changePlayer(curRunningPlayer, player) } + + if curRunningPlayer != nil && curRunningPlayer.Player.GetScheduleDomain != nil { + setscheduleDomain(curRunningPlayer.Player.GetScheduleDomain) + } else { + setscheduleDomain(scheduleDomain_default_player) + } + //uncontrol player if curRunningPlayer.Player.IfForcePause() == false { //curRunningPlayer.ClearPlayStatus() @@ -302,8 +309,8 @@ func coreSchedule(cmd SCmdStruct) { player.Player.Pause() player.playerDetail.Status = globals.MUSIC_ST_PAUSED } - player.PlayAfterResume = false - player.HasRequestPlayWhenInterrupt = false + //player.PlayAfterResume = false + //player.HasRequestPlayWhenInterrupt = false if cmd.ExecCb != nil { cmd.ExecCb(SCmdStructExecCb{Result: SCmdExecStatus_NotEnoughPrivilege}) @@ -572,6 +579,11 @@ func reCheckScheduleTask() { curRunningTask = nil //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 result := curRunningPlayer.Resume(); result == true && globals.CurBootState == globals.BootStage_FINISH { @@ -584,28 +596,30 @@ func reCheckScheduleTask() { } else { //curplayer is offline, change to the wifi player if curRunningPlayer.GetPlayerId() != uint32(globals.PlayerType_Wifi) { + prevPlayer := curRunningPlayer.GetPlayerId() if player := playermap[uint32(globals.PlayerType_Wifi)]; player != nil { changePlayer(curRunningPlayer, player) curRunningPlayer = player + + if curRunningPlayer != nil && curRunningPlayer.Player.GetScheduleDomain != nil { + setscheduleDomain(curRunningPlayer.Player.GetScheduleDomain) + } + if isGlobalPause == true { log.Println(log.DebugLog, "Global pause is ", isGlobalPause) isGlobalPause = 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 { vui.ShowIconMusic() misc.VolTrigeMicAdc() @@ -671,14 +685,27 @@ func changePlayer(from *SPlayer, to *SPlayer) { UnlockScene() } + curRunningPlayer = to globals.ResetBroadCastTimer() } func checkTaskCanRun(task *STask) (canRun bool) { - for i := TaskLevel_Min; i < task.Task.GetTaskLevel() && i < TaskLevel_MAX; i++ { - for _, task := range alltask[i] { - if task.Task.IsActive() == true { - return false + for i := TaskLevel_Min; i <= task.Task.GetTaskLevel() && i < TaskLevel_MAX; i++ { + for _, tmptask := range alltask[i] { + if tmptask.Task.GetName() == task.Task.GetName() { + 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) } + if curRunningPlayer != nil && curRunningPlayer.Player.GetScheduleDomain != nil { + setscheduleDomain(curRunningPlayer.Player.GetScheduleDomain) + } else { + setscheduleDomain(scheduleDomain_default_player) + } + curRunningPlayer.OemArg.OemArg = arg //uncontrol player if curRunningPlayer.Player.IfForcePause() == false { @@ -730,8 +763,8 @@ func playerRequestPlay(playerid uint32, arg interface{}) (canPlay bool) { player.Player.Pause() player.playerDetail.Status = globals.MUSIC_ST_PAUSED } - player.PlayAfterResume = false - player.HasRequestPlayWhenInterrupt = false + //player.PlayAfterResume = false + //player.HasRequestPlayWhenInterrupt = false } // wait for st from player diff --git a/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/CoreApi.go b/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/CoreApi.go old mode 100644 new mode 100755 index 130ea4d..341e0b6 --- a/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/CoreApi.go +++ b/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/CoreApi.go @@ -25,7 +25,7 @@ func SendSCmdStruct(scmd SCmdStruct) { select { case coreChan <- scmd: 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: log.Println(log.DebugLog, "Send fail, cmd:", scmd) @@ -58,6 +58,7 @@ const ( ScheduleDomain_Alarm ScheduleDomain_Remind ScheduleDomain_Notice + ScheduleDomain_IotWifiParing ) func (this *ScheduleDomain) String() string { diff --git a/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/PlayerApi.go b/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/PlayerApi.go index 51b1314..24d3774 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/PlayerApi.go +++ b/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/PlayerApi.go @@ -497,7 +497,8 @@ func isPlaying(st globals.PlayerStatuses) bool { func SpeakerIsPlaying() bool { if isPlaying(globals.CurPlayerSt.ContinuousTaskSt) || SeIsPlaying() == true || - NoticeIsPlaying() == true { + NoticeIsPlaying() == true || + globals.BtAvkDataRecving == true { return true } else { return false diff --git a/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/Scmd.go b/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/Scmd.go old mode 100644 new mode 100755 index eeb740a..d4ad4db --- a/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/Scmd.go +++ b/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/Scmd.go @@ -33,6 +33,10 @@ const ( //iot SCMD_SuperTask_Enter_IOT_WifiParing + //btOnWifiOff + SCMD_SuperTask_Enter_btOnWifiOff + SCMD_SuperTask_Exit_btOnWifiOff + //Alarm SCMD_SuperTask_Alarm_Ring //Remind diff --git a/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/TaskDatastruct.go b/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/TaskDatastruct.go old mode 100644 new mode 100755 index f3391c7..7402c99 --- a/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/TaskDatastruct.go +++ b/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/TaskDatastruct.go @@ -23,6 +23,8 @@ const ( const ( TaskLevel_SystemService = TaskLevel_0 TaskLevel_IotWifiParingService = TaskLevel_1 + TaskLevel_BtOnWifiOff = TaskLevel_1 + TaskLevel_WifiParing = TaskLevel_1 TaskLevel_VoiceEventService = TaskLevel_2 TaskLevel_RemindService = TaskLevel_3 TaskLevel_AlarmService = TaskLevel_4 @@ -38,7 +40,7 @@ const ( type TaskStatus uint8 const ( - TaskStatus_Init TaskStatus = iota + TaskStatus_Init TaskStatus = iota TaskStatus_Running TaskStatus_Interrupted ) @@ -55,7 +57,8 @@ type RegistedTask struct { GetName func() string GetTaskLevel func() TaskLevel - CanBeInterruptByKey func() bool + CanBeInterruptByKey func() bool + CanBeInterruptBySameLevelTask func() bool GetSupportedSCmd func() []SCMD GetScheduleDomain ScheduleDomainGetFunc diff --git a/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/ttsPlayerApi.go b/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/ttsPlayerApi.go index 285f43b..3af53a5 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/ttsPlayerApi.go +++ b/app/netease_control_center_common_module/src/netease_control_center/interfaces/schedule/ttsPlayerApi.go @@ -57,7 +57,7 @@ type StartPlayNotice func(id uint32, srcType globals.AdSrcType, src string, uuid type StopPlayNotice func(id uint32) 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 ( curplayid uint32 = audioPlayIdStart noticeChan chan uint8 diff --git a/app/netease_control_center_common_module/src/netease_control_center/interfaces/vui/IconCoreSchedule.go b/app/netease_control_center_common_module/src/netease_control_center/interfaces/vui/IconCoreSchedule.go index 4d96d7f..ba33e02 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/interfaces/vui/IconCoreSchedule.go +++ b/app/netease_control_center_common_module/src/netease_control_center/interfaces/vui/IconCoreSchedule.go @@ -102,7 +102,9 @@ func ShowIcon(icon IconLedDesc) { }() 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 } diff --git a/app/netease_control_center_common_module/src/netease_control_center/interfaces/vui/cvui/vuifiles.go b/app/netease_control_center_common_module/src/netease_control_center/interfaces/vui/cvui/vuifiles.go old mode 100644 new mode 100755 index 844d2c8..174d080 --- a/app/netease_control_center_common_module/src/netease_control_center/interfaces/vui/cvui/vuifiles.go +++ b/app/netease_control_center_common_module/src/netease_control_center/interfaces/vui/cvui/vuifiles.go @@ -21,6 +21,7 @@ import ( func Init() { log.Println(log.DebugLog, "Begin init skin!") C.SkinInit() + log.Println(log.DebugLog, "Init skin end!") } func GetSkinRes(key string) (path string) { diff --git a/app/netease_control_center_common_module/src/netease_control_center/interfaces/vui/voiceSrc.go b/app/netease_control_center_common_module/src/netease_control_center/interfaces/vui/voiceSrc.go index b606dda..61211b5 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/interfaces/vui/voiceSrc.go +++ b/app/netease_control_center_common_module/src/netease_control_center/interfaces/vui/voiceSrc.go @@ -103,6 +103,19 @@ const ( SoundNotice_Mic_Close SoundNotice = "v601" //麦克风已禁用 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 { diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/ModuleInit.go b/app/netease_control_center_common_module/src/netease_control_center/modules/ModuleInit.go old mode 100644 new mode 100755 index 6aab884..5f12fdc --- a/app/netease_control_center_common_module/src/netease_control_center/modules/ModuleInit.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/ModuleInit.go @@ -19,6 +19,8 @@ func Init() { controller.RemindTaskinit() controller.VoiceTaskInit() controller.IOTTaskinit() + //controller.BtOnWifiOffTaskinit() + controller.WifiParingTaskinit() player.PlayerInit() log.Println(log.DebugLog, "Begin to init controller!") controller.Init() diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/blueCommand.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/blueCommand.go index 57a0dd3..4b49e21 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/blueCommand.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/blueCommand.go @@ -17,17 +17,14 @@ import ( ) var ( - timeBtPause time.Time = time.Now() - timeBtPlay time.Time = time.Now() + timeBtPause time.Time + timeBtPlay time.Time enableBtMixProtect bool = false waitLock sync.Mutex waitPlayAfterPauseTimer *time.Timer = nil btCon bool = false -) - -const ( - BT_WIFI_RESUME_TIME_LIMIT time.Duration = 30 * time.Second + pauseBtNeedResumeWifiPlay bool = false ) func BtMsgProcess(cmdid uint32, msg string) { @@ -46,13 +43,18 @@ func BtMsgProcess(cmdid uint32, msg string) { } 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) } else { 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), uint32(C.CMD_BT_AVK_SOUND_STOP_EVT): + //case uint32(C.CMD_BT_AVK_RC_PAUSE): + case uint32(C.CMD_BT_AVK_RC_PAUSE), uint32(C.CMD_BT_AVK_SOUND_STOP_EVT): switch cmdid { case uint32(C.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 { 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) } } else { @@ -116,7 +121,11 @@ func BtMsgProcess(cmdid uint32, msg string) { 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) case uint32(C.CMD_BT_AVK_CRTED): diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/callBack.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/callBack.go old mode 100644 new mode 100755 index 97251ea..4fa5ebc --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/callBack.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/callBack.go @@ -4,6 +4,10 @@ import ( "netease_control_center/utils/customization" "netease_control_center/utils/ntp" "sync" + "netease_control_center/globals" + "time" + "netease_control_center/interfaces/log" + "math/rand" ) var ( @@ -20,5 +24,8 @@ func calTimeSuccess() { UpdateMicStatus(true) UpdateCronTime() go customization.DoCheck(5) + globals.FirstCalTime = time.Now() + rand.Seed(time.Now().UnixNano()) + log.Println(log.DebugLog, "Firstly cal time:", globals.FirstCalTime) }) } diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/cronTab.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/cronTab.go old mode 100644 new mode 100755 index 6ea96b2..6d0adaf --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/cronTab.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/cronTab.go @@ -31,7 +31,7 @@ func CrontabInit() { 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) }); err != nil { log.Println(log.ErrorLog, "Set Nduilite_fespa_set_arg with sdk init", err) diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/dlnaCommond.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/dlnaCommond.go index ec3a3e1..44cd1f2 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/dlnaCommond.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/dlnaCommond.go @@ -55,7 +55,7 @@ func DlnaCmdProcess(cmdid uint32, msg string) { } log.Println(log.WarningLog, "GetCurPlayerId():", GetCurPlayerId(), "PlayerType_Dlna.IsActive():", player.PlayerHander[PlayerType_Dlna].IsActive(), "playPauseState: ", player.GetDlnaPlayPauseState()) - player.DlnaPlaySeek = true + if GetCurPlayerId() == PlayerType_Dlna && player.PlayerHander[PlayerType_Dlna].IsActive() { if !player.GetDlnaPlayPauseState() { //SendSCmd(SCMD_MusicPlayer_Play, nil) @@ -100,13 +100,13 @@ func DlnaCmdProcess(cmdid uint32, msg string) { return } log.Println(log.WarningLog, "recive stop cmd from phone") + SendSCmd(SCMD_MusicPlayer_Stop) dlnaTrigStop() player.DlnaPlaySeek = false player.ClearProjectorVolProcess() player.SetDlnaPlayPauseState(false) // prd reverse : 20180322 //player.SoundEffectPlayCmd(CMD_SE_PLAY, SoundNotice_Slianjiechenggong001.GetPath()) - SendSCmd(SCMD_MusicPlayer_Stop) eventPoint.DeviceDisconEvent(eventPoint.ModelValDlna) case CMD_KPLAYER_CTR_SEEK: if GetCurPlayerId() != PlayerType_Dlna { @@ -128,6 +128,7 @@ func DlnaCmdProcess(cmdid uint32, msg string) { hasSetUrl = true hasPostUrl = true } + player.DlnaPlaySeek = false case CMD_KPLAYER_CTR_CTREATED: player.GetSystemVolPer() log.Println(log.DebugLog, "dlna has on") diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/entry.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/entry.go index 75837fb..3697350 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/entry.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/entry.go @@ -19,6 +19,8 @@ import ( "netease_control_center/utils/godbus/dbus" "strconv" "time" + "netease_control_center/modules/hardware/led_mcu" + "netease_control_center/modules/hardware/mcu_leds/atservice" ) var ( @@ -310,7 +312,25 @@ func goapi(modId uint32, msgmsk uint32, sec uint32, usec uint32, buscmd uint32, case uint32(C.CMD_YUNXIN_RECVMSG): 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): DbusYunxinSysMsgControl(data) @@ -416,7 +436,7 @@ func _sigProcess(sig *dbus.Signal) { if err := json.Unmarshal([]byte(buf), &tmp); err == nil { if CurBootState == BootStage_WIFIPARING || IsInBackupSystem() { 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!") ADBControl(true) SendBleStatus(APPInitStatus_PARING_NOT_RESPONSE) @@ -469,6 +489,11 @@ func _sigProcess(sig *dbus.Signal) { default: 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) } else { log.Printf(log.DebugLog, "invalid msg.cmd:0x%x", buscmd) @@ -480,6 +505,17 @@ func _sigProcess(sig *dbus.Signal) { } buscmd := sig.Body[2].(uint32) 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): IsWifiAutoConnecting = false SRevent.BroadCastSRevent(SRevent.SRevent_type_AutoConnectEnd) diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/init.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/init.go index 37382c0..7fa778e 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/init.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/init.go @@ -544,62 +544,6 @@ func systemService_exec(canExec bool, scmd SCMD, arg ...interface{}) { if tmp := GetOtaSource(); tmp.IsSilent() == true { 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 { - 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 { @@ -629,9 +573,7 @@ func systemServiceTaskRegiste() { tmp.GetSupportedSCmd = func() []SCMD { return []SCMD{SCMD_SuperTask_System_BeginInit, - SCMD_SuperTask_System_BeginOta, - SCMD_SuperTask_System_WifiParing, - SCMD_SuperTask_System_WifiModeChange_AP_BT} + SCMD_SuperTask_System_BeginOta} } tmp.Do = systemService_exec @@ -675,6 +617,7 @@ func systemServiceTaskRegiste() { tmp += fmt.Sprintln(" Device mode:", getCurDeviceMode(true)) vol, volerr := adau1761.GetVol() tmp += fmt.Sprintln(" Volume:", vol, volerr) + tmp += fmt.Sprintln(" FirstCalTime:", FirstCalTime) tmp += fmt.Sprintln(" CurTime:", time.Now().Local()) tmp += fmt.Sprintln(" PingTime:", DevNetworkStatus.Time) tmp += fmt.Sprintln(" Global cfg list:", GetGlobalCfgList()) diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/keyInputEvent.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/keyInputEvent.go index 95e9d3a..1ee89d0 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/keyInputEvent.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/keyInputEvent.go @@ -1,5 +1,8 @@ package controller - +/* +#include +*/ +import "C" import ( "context" "fmt" @@ -106,6 +109,10 @@ func KeyResponse(keycode int, pressedTimes uint8, longpress bool, insistTime tim return } + if globals.WifiSwitch != globals.WifiSwitch_On { + schedule.SendSCmd(schedule.SCMD_SuperTask_Exit_btOnWifiOff) + return + } //wifi paring 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}) @@ -169,6 +176,33 @@ func KeyResponse(keycode int, pressedTimes uint8, longpress bool, insistTime tim CopyLogfiles() //schedule.PlayNoticeAsync(globals.AdSrcType_TTS, "日志已保存", globals.CONST_AUDIO_ID, false, nil, nil) 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) case 5: //player.TestInterfaceForKey(player.CREATE_LISTS_TYPE) @@ -265,7 +299,7 @@ func TriggerKey(keycode int, isPress bool) { } func KeyApp() error { - dev, err := evdev.Open(globals.GetCurPlatformConfig().InputKeyPath) + dev, err := evdev.Open(devpath) if err != nil { return err } diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/mscCommand.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/mscCommand.go index 0c04c58..4b7c6a9 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/mscCommand.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/mscCommand.go @@ -48,7 +48,7 @@ func MscToastFinish(arg TtsPlayerArg) { //检查是否网络缓存播放失败 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 { - 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.IconOut = vui.IconLed_DoNothing - tmpconfig.BeforeExecFunc = MscToastLed_Before + tmpconfig.BeforeSpecialFunc = MscToastLed_Before tmpconfig.SpecialFunc = MscToastFinish if configChange != nil { @@ -199,6 +199,9 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) { case MSC_CMD_IOTWIFIPARING: SendSCmd(SCMD_SuperTask_Enter_IOT_WifiParing) + case MSC_CMD_BTONWIFIOFF: + SendSCmd(SCMD_SuperTask_Enter_btOnWifiOff) + case MSC_CMD_CHAT: if isMute() { return @@ -427,11 +430,10 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) { case GetScenePlayerId(), PlayerType_Wifi, PlayerType_Bt, PlayerType_Airplay: if retData.Desc == MSC_CMD_ONE_SHOT_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: - 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 { log.Println(log.WarningLog, "can not use one shot cmd :", TTS_NOT_UNSUPPORT) @@ -439,7 +441,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) { } else { 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}) - } + }*/ return default: @@ -451,14 +453,13 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) { case GetScenePlayerId(), PlayerType_Wifi, PlayerType_Bt, PlayerType_Airplay: if retData.Desc == MSC_CMD_ONE_SHOT || retData.Desc == MSC_CMD_ONE_SHOT_WAKEUP { log.Println(log.DebugLog, "one shot cmd for next song") - go http.InformLocalMsgToServer(http.Type_Inform_TtsPush, int(MSC_CMD_NEXT), "下一首", "下一首") //上传信息流 /*播放反馈声音,prd暂时不需要 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") })*/ } 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 { log.Println(log.WarningLog, "can not use one shot cmd :", TTS_NOT_UNSUPPORT) @@ -466,7 +467,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) { } else { 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}) - } + }*/ return default: log.Println(log.ErrorLog, "err playerId:", GetCurPlayerId()) @@ -484,7 +485,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) { switch Cmd(retData.Cmd) { 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") // 拉取新的自然声 serverListParams := http.MusicListServerType{ @@ -513,6 +514,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) { list.RspId = list.RspId SetPlayerArgs(PlayerType_Wifi, list) 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 { RspId = &retData.RspId @@ -565,7 +567,33 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) { player.PlayerHander[PlayerType_Wifi].RequestPlay_Async(nil) } 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: 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 mode := getCurDeviceMode(true) switch mode { @@ -728,6 +756,12 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) { ResetUnPlayListCurNode() } CurPlayingMode = LIST_ORDER_CYCLE + case MSC_CMD_ORDER_PLAY: + // 切换到顺序播放时,如果当前是单曲循环,不需要处理 + if LIST_RANDOM_CYCLE == CurPlayingMode { + ResetUnPlayListCurNode() + } + CurPlayingMode = LIST_ORDER_PLAY case MSC_CMD_CYCLE_RANDOM: if LIST_ORDER_CYCLE == CurPlayingMode || SINGLE_CYCLE == CurPlayingMode { ResetUnPlayListCurNode() @@ -741,6 +775,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) { CurPlayingMode = SINGLE_CYCLE } log.Println(log.DebugLog, "Change playmode:", CurPlayingMode) + playModeBroadCast(CurPlayingMode) var tmp ServerDetailBase err := json.Unmarshal([]byte(retData.Detail), &tmp) if nil != err { @@ -1272,7 +1307,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) { ttsRepeatInfo := GetTtsRepeatInfo() if ttsRepeatInfo.HasSetTtsInfo { 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() MscToastTts(TTS_REPEAT_NIL, retData.RspId, false, false, nil) @@ -1329,6 +1364,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) { status.CurPos = 0 log.Println(log.DebugLog, "MSC_CMD_REPEAT_MUSIC set CurPos to 0") curPlayer.SetPlayerStatus(status) + SendSCmd(SCMD_MusicPlayer_Seek, uint32(status.CurPos)) } else { eventPoint.SetEpOsSouce("F141", eventPoint.EpOs_Server) 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) - SendSCmd(SCMD_MusicPlayer_Pause, PlayerArg{NotShowIcon: true}) - ResetWifiPlayer() SendSCmdStruct(SCmdStruct{SCmd: SCMD_MusicPlayer_Pause, Arg: []interface{}{PlayerArg{NotShowIcon: true}}, ExecCb: func(cb SCmdStructExecCb) { tmp := GetCurVboxBroadcastSt(false) - tmp.PlayerStPtr.ContinuousTaskSt = MUSIC_ST_PAUSED + tmp.PlayerStPtr.ContinuousTaskSt = MUSIC_ST_IDLE TrigBroadcastStatus(tmp) + ResetWifiPlayer() }}) if len(tmp.Tts2) > 0 { @@ -1404,6 +1439,7 @@ func MscSuccessCommand(msg *[]byte, msglen uint32) { } default: log.Printf(log.ErrorLog, "Unknow the cmd %d\n", retData.Cmd) + MscToastTts(TTS_NOT_UNSUPPORT, retData.RspId, true, false, nil) } return @@ -1496,6 +1532,7 @@ func AppSuccessCommand(msg *[]byte, msglen uint32) { case APP_CMD_MUSIC_CONTINUE: RestoreDefaultVolWhen0() eventPoint.SetEpOsSouce("F141", eventPoint.EpOs_App) + PlayListSrcRec.ListHasEnd = false //歌单播放结束标志位false SendSCmd(SCMD_MusicPlayer_Play) case APP_CMD_MUSIC_PAUSE: eventPoint.SetEpOsSouce("F141", eventPoint.EpOs_App) @@ -1519,6 +1556,7 @@ func AppSuccessCommand(msg *[]byte, msglen uint32) { SendSCmd(SCMD_MusicPlayer_Pause, PlayerArg{NotShowIcon: true}) } + PlayListSrcRec.ListHasEnd = false //歌单播放结束标志位false base := ServerPlayerBase{Action: MUSIC_ACTION_PREV, ActionSrc: MUSIC_ACTION_SRC_APP} SendSCmd(SCMD_MusicPlayer_PlayPre, PlayerArg{GloablePause: false, NotShowIcon: false, ServerPlayerBase: base}) @@ -1760,6 +1798,7 @@ func AppSuccessCommand(msg *[]byte, msglen uint32) { default: 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) if nil != err { 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 } if nil == list || nil == list.MusicLists || 0 == len(list.MusicLists) || nil == list.MusicLists[0].SongList { 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 } @@ -1906,7 +1945,7 @@ func createVboxChangeMusicLists(params VboxChangeInfo) *ServerMusicLists { songDetail, err := player.GetSongDetail(PlayerType_Wifi, ¶ms.SongId, true) if nil != err { 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 } tmp.MusicLists[0].Url = songDetail.Song.Url @@ -2012,12 +2051,12 @@ func createVboxChangeMusicList(params VboxChangeInfo) *ServerMusicList { if nil != err { 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 } if nil == list || nil == list.MusicList.SongList { 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 } tmp.ExtraData = list.ExtraData @@ -2101,7 +2140,7 @@ func createVboxChangeMusicList(params VboxChangeInfo) *ServerMusicList { songDetail, err := player.GetSongDetail(PlayerType_Wifi, ¶ms.SongId, true) if nil != err { 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 } tmp.MusicList.Url = songDetail.Song.Url @@ -2117,10 +2156,10 @@ func createVboxChangeMusicList(params VboxChangeInfo) *ServerMusicList { NormalListMap[NORMAL_LIST_PAGE].BackIndex = 0 } } else { - PlayListSrcRec.BizType = OldBizType NormalListMap[NORMAL_LIST_PAGE].BackIndex = 0 } + PlayListSrcRec.BizType = OldBizType tmp.Action = MUSIC_ACTION_NEXT tmp.ActionSrc = MUSIC_ACTION_SRC_APP @@ -2338,6 +2377,47 @@ func VboxChangeTestNaturalSound() { 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() { log.Println(log.ErrorLog, "VboxChangeTest VboxChangeTestRadioStation") diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/networkControl.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/networkControl.go index fef864c..acd382e 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/networkControl.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/networkControl.go @@ -579,6 +579,10 @@ _begin_connect_wifi: SendBleStatus(APPInitStatus_SERVER_ARG_ERROR) case ERR_BIND_ACCOUNT_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: SendBleStatus(APPInitStatus_REQUEST_SERVER_ERROR) } @@ -679,6 +683,9 @@ func DisableBT() { } func RequestWifiAutoConnect(force bool) { + if WifiSwitch != WifiSwitch_On { + return + } go func() { time.Sleep(500 * time.Millisecond) if IsWifiAutoConnecting == false || force == true { @@ -691,9 +698,12 @@ func RequestWifiAutoConnect(force bool) { } func RequestChangeWifi(force bool) { + if WifiSwitch != WifiSwitch_On { + return + } go func() { time.Sleep(500 * time.Millisecond) - if IsWifiChanging == false { + if IsWifiChanging == false || force == true { SendWifiCmd(uint32(C.CMD_WIFI_CHANGE_VALID_AP)) } else { log.Println(log.DebugLog, "Wifi is changing now, do not send cmd!") @@ -886,9 +896,10 @@ func network_check_daemon() { } }() _AllStart: - //log.Println(log.DebugLog, "Begin Check Network!") - if CurBootState != BootStage_FINISH { +//log.Println(log.DebugLog, "Begin Check Network!") + if CurBootState != BootStage_FINISH || WifiSwitch != WifiSwitch_On { //do nothing on boot + fmt.Println("Not in net check daemon, wifiswitch:", WifiSwitch) return } diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/otaControl.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/otaControl.go index 8b941da..de5a6f3 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/otaControl.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/otaControl.go @@ -31,6 +31,7 @@ import ( "os" "strconv" "time" + "math/rand" ) var ( @@ -56,6 +57,8 @@ func otaEveryNightCheck() { log.Println(log.DebugLog, "OTA TIME begin, begin to check ota in midnight! ota night times:", curNightOtaTimes) SetNightOtaTimes(curNightOtaTimes) + time.Sleep(time.Duration(rand.Intn(3600)) * time.Second) + for { 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!") diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/syncWithServer.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/syncWithServer.go index d21173e..0756d33 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/syncWithServer.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/syncWithServer.go @@ -37,6 +37,7 @@ func SyncAfterNetworkConnect() { cvui.UpdateResFromServer() http.UpdateCfgList() customization.AfterInternetConnectCheckOem() + btOnWifiOffCheckFlag() } func AccountChange() { diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/sysMsgControl.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/sysMsgControl.go index ab44059..ce49ee7 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/sysMsgControl.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/sysMsgControl.go @@ -45,6 +45,9 @@ func DbusYunxinSysMsgControl(data []byte) { eventPoint.EpRecord("A224", map[string]interface{}{"msgid": cmd.MsgId, "sourceos": eventPoint.EpOs_Server}) switch cmd.CmdId { + case YxSCmd_InBtOnWifiOff: + schedule.SendSCmd(schedule.SCMD_SuperTask_Enter_btOnWifiOff) + case YxSCmd_IotWifiParingResult: var tmp struct { Tts string `json:"tts"` @@ -250,11 +253,12 @@ func DbusYunxinSysMsgControl(data []byte) { case YxSCmd_ChangeAccountMode: 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) { tmp := GetCurVboxBroadcastSt(false) - tmp.PlayerStPtr.ContinuousTaskSt = MUSIC_ST_PAUSED + tmp.PlayerStPtr.ContinuousTaskSt = MUSIC_ST_IDLE TrigBroadcastStatus(tmp) + player.ResetWifiPlayer() }}) default: diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/alarmTask.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_alarmTask.go similarity index 100% rename from app/netease_control_center_common_module/src/netease_control_center/modules/controller/alarmTask.go rename to app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_alarmTask.go diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_btOnWifiOff.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_btOnWifiOff.go new file mode 100755 index 0000000..4a0d787 --- /dev/null +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_btOnWifiOff.go @@ -0,0 +1,168 @@ +package controller + +/* +#include +#include +*/ +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()) + } +} diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/iotWifiParing.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_iotWifiParing.go old mode 100644 new mode 100755 similarity index 86% rename from app/netease_control_center_common_module/src/netease_control_center/modules/controller/iotWifiParing.go rename to app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_iotWifiParing.go index ca540bc..dcb355c --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/iotWifiParing.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_iotWifiParing.go @@ -32,7 +32,7 @@ var ( iot_timeout_exit *time.Timer iot_do_once sync.Once iot_contex, iot_context_cancel = context.WithCancel(context.Background()) - iot_stage_before_find_dev = true + iot_stage_before_find_dev = true ) const ( @@ -76,12 +76,12 @@ func iotTask_exec(canExec bool, scmd SCMD, arg ...interface{}) { iot_do_once = sync.Once{} iot_contex, iot_context_cancel = context.WithCancel(context.Background()) SendEventnByYunxinWithRid(DeviceEventType_IotWifiParing, DeviceEventAction_Start, "", false, nil) - + globals.ResetBroadCastTimer() //begin to show led led_mcu.DirectLedControl(atservice.GUIDE_EFFECT_ID_NET_MODE, atservice.GUIDE_ACTION_START, 0, []byte{}) vui.IconLed_Wifiparing_Ap.Show() //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) SendWifiCmd(uint32(C.CMD_WIFI_BL_CONF)) @@ -96,7 +96,7 @@ func iotTask_exec(canExec bool, scmd SCMD, arg ...interface{}) { } 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() defer iot_lock.Unlock() if iot_running == false { @@ -128,12 +128,16 @@ func iot_wifiparing_exit() { } iot_context_cancel() + //turn off leds/icon //tell wifi module stop 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_NET_MODE) vui.IconLed_Clear.Show() + SendSCmd(SCMD_SChedule) + + //2s after broad vbox status + globals.SetBroadCastTimer(2*time.Second) } else { log.Println(log.DebugLog, "Iot has exit, do nothing!") } @@ -152,11 +156,11 @@ func iot_connect_fail_toast() { debug.PrintStack() var tts string if iot_stage_before_find_dev == true { - tts = iot_tts_not_found_dev + tts = vui.SoundNotice_IOT_NotFound.GetPath() } 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() defer iot_lock.Unlock() if iot_running == false { @@ -242,7 +246,11 @@ func iotDbusMsg(buscmd uint32, arg string) { if err := json.Unmarshal([]byte(arg), &req); err == nil { var rsp http.HttpRspDeviceRegiste 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 SendWifiCmd(uint32(C.CMD_WIFI_BL_DEV_TOKEN_BOUND)) if iot_timeout_exit != nil { @@ -312,6 +320,26 @@ func Iot_Wifiparing_end(tts string) { 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() { led_mcu.DirectLedControl(atservice.GUIDE_EFFECT_ID_EXEC_CMD, atservice.GUIDE_ACTION_START, 0, []byte{}) vui.IconLed_VoiceExecResult.Show() @@ -359,7 +387,7 @@ func IOTTaskinit() { } tmp.GetScheduleDomain = func() ScheduleDomain { - return ScheduleDomain_NoneMusic + return ScheduleDomain_IotWifiParing } tmp.Do = iotTask_exec diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/remindTask.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_remindTask.go similarity index 100% rename from app/netease_control_center_common_module/src/netease_control_center/modules/controller/remindTask.go rename to app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_remindTask.go diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/voiceControl.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_voiceControl.go similarity index 98% rename from app/netease_control_center_common_module/src/netease_control_center/modules/controller/voiceControl.go rename to app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_voiceControl.go index f31227c..80cbb7f 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/voiceControl.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_voiceControl.go @@ -202,6 +202,14 @@ func voiceService_exec(canExec bool, scmd SCMD, arg ...interface{}) { log.Println(log.DebugLog, "Mic is close, do not wake up!!") 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 { log.Println(log.DebugLog, "Wake up, but internet down!") ToastNetworkError(false) diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_wifiparing.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_wifiparing.go new file mode 100755 index 0000000..74663e5 --- /dev/null +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_wifiparing.go @@ -0,0 +1,162 @@ +package controller + +/* +#include +#include +*/ +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()) + } +} diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/timer.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/timer.go index 62b634e..839afc4 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/timer.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/timer.go @@ -17,7 +17,7 @@ var ( 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) @@ -25,7 +25,7 @@ var ( ) func ResetRecordVolumeTimer() { - recordVolume.Reset(3 * time.Second) + recordVolume.Reset(500 * time.Microsecond) //lupeng change 3s to 500ms 20180904 } func GetCurVboxBroadcastSt(print bool) VboxBroadcastSt { @@ -82,6 +82,7 @@ func timerFunc() { eventPoint.EpRecord("H511", map[string]interface{}{"volume": adau1761.MustGetVol()}) if getCurDeviceMode(false) == Exec_MusicPlay_mode { misc.VolTrigeMicAdc() + BroadcastStatus(GetCurVboxBroadcastSt(false)) //lupeng add 20180904 } case <-ticker_30min.C: diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/player/airPlayer.go b/app/netease_control_center_common_module/src/netease_control_center/modules/player/airPlayer.go index f6b13a2..54c5755 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/player/airPlayer.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/player/airPlayer.go @@ -28,7 +28,7 @@ func AirPlayStopTrig(globalsPause bool) { } func AirPlayPause() { - sendMusicCmd(CMD_AIRPLAYER_PAUSE) + sendMusicCmd(PlayerType_Airplay, CMD_AIRPLAYER_PAUSE) ctrlAirPlayCmdToPhone(SPLAYER_ACTION_PAUSE) } @@ -49,13 +49,13 @@ func AirPlayPlay(start int, arg SCmd_Args) bool { return false } } else { - sendMusicCmd(CMD_AIRPLAYER_PLAY) + sendMusicCmd(PlayerType_Airplay, CMD_AIRPLAYER_PLAY) return true } } func AirPlayStop() { - //sendMusicCmd(CMD_PLAYER_STOP) + //sendMusicCmd(PlayerType_Airplay, CMD_PLAYER_STOP) // todo : trig phone stop ctrlAirPlayCmdToPhone(SPLAYER_ACTION_PAUSE) } @@ -78,14 +78,14 @@ func AirPlayPlayNext(arg interface{}) { // todo : 反向airplay控制 ctrlAirPlayCmdToPhone(SPLAYER_ACTION_NEXT) //MonitorAirplayPlayerBroadcast(MUSIC_ST_PLAYING) - sendMusicCmd(CMD_AIRPLAYER_PLAY) + sendMusicCmd(PlayerType_Airplay, CMD_AIRPLAYER_PLAY) } func AirPlayPlayPre(arg interface{}) { // todo : 反向airplay控制 ctrlAirPlayCmdToPhone(SPLAYER_ACTION_PRE) //MonitorAirplayPlayerBroadcast(MUSIC_ST_PLAYING) - sendMusicCmd(CMD_AIRPLAYER_PLAY) + sendMusicCmd(PlayerType_Airplay, CMD_AIRPLAYER_PLAY) } func AirPlayPrepareNext() { @@ -154,7 +154,7 @@ func airPlayPlayApi(arg interface{}) { case AirParams2Play: log.Printf(log.DebugLog, "airplay arg:%+v\n", argVal) - sendMusicCmd(CMD_AIRPLAYER_PLAY, arg, &AirPlayUuid) + sendMusicCmd(PlayerType_Airplay, CMD_AIRPLAYER_PLAY, arg, &AirPlayUuid) default: log.Println(log.WarningLog, "err params type") } diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/player/bluePlayer.go b/app/netease_control_center_common_module/src/netease_control_center/modules/player/bluePlayer.go index 5689d01..f3f8ced 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/player/bluePlayer.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/player/bluePlayer.go @@ -83,8 +83,12 @@ func BtPlayPlayNext(arg interface{}) { MonitorBtPlayerBroadcast(MUSIC_ST_PLAYING) 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, - PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING}) + if tmp.RspId == CONST_AUDIO_ID { + 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}) + } } } diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/player/commonApi.go b/app/netease_control_center_common_module/src/netease_control_center/modules/player/commonApi.go index 34632f6..433add2 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/player/commonApi.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/player/commonApi.go @@ -36,7 +36,12 @@ type MusicCmdExtra struct { 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() { if err := recover(); err != nil { log.Println(log.ErrorLog, err) @@ -47,7 +52,11 @@ func sendMusicCmd(cmd uint32, params ...interface{}) error { var err error 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 { case CMD_SE_PLAY: @@ -217,9 +226,9 @@ func VolChangeByPercent(percent int) { /** only for airplay dlna blue vol change */ -func VolChange(vol int) { +func VolChangeBroadcast(vol int) { log.Println(log.DebugLog, "vol:", vol) - adau1761.SetVol(vol) + //adau1761.SetVol(vol) CurVboxVolSt.VolumeScale = MaxVolume CurVboxVolSt.VolumePer = uint8(GetPerByVol(vol)) @@ -359,8 +368,7 @@ func getSongPlayInfo(playerType PlayerType, id *string, ttsNow bool) (*ServerSon if len(err.Error()) > 0 { if ttsNow { forcePausePlayer(playerType) - //NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, *tts, CONST_AUDIO_ID, AdSrcType_TTS, TTS_LEVEL_1, true, false) - mscToastTts(err.Error(), CONST_AUDIO_ID, true, false, nil) + mscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil) } else { ttsNoMusic = true ttsMusicUuid = *wifiPlayerSt.MusicId @@ -375,9 +383,7 @@ func getSongPlayInfo(playerType PlayerType, id *string, ttsNow bool) (*ServerSon if ttsNow { forcePausePlayer(playerType) - //NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, Server_ERR_RET.Error(), CONST_AUDIO_ID, AdSrcType_TTS, - // TTS_LEVEL_1, true, false) - mscToastTts(Server_ERR_RET.Error(), CONST_AUDIO_ID, true, false, nil) + mscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil) } else { if nil != wifiPlayerSt.MusicId && len(*wifiPlayerSt.MusicId) > 0 { ttsNoMusic = true @@ -392,6 +398,54 @@ func getSongPlayInfo(playerType PlayerType, id *string, ttsNow bool) (*ServerSon 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) { return getSongDetailInfo(playerType, id, ttsNow) } @@ -410,8 +464,7 @@ func getSongDetailInfo(playerType PlayerType, id *string, ttsNow bool) (*ServerS if len(err.Error()) > 0 { if ttsNow { forcePausePlayer(playerType) - //NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, *tts, CONST_AUDIO_ID, AdSrcType_TTS, TTS_LEVEL_1, true, false) - mscToastTts(err.Error(), CONST_AUDIO_ID, true, false, nil) + mscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil) } else { if nil != wifiPlayerSt.MusicId && len(*wifiPlayerSt.MusicId) > 0 { ttsNoMusic = true @@ -429,9 +482,7 @@ func getSongDetailInfo(playerType PlayerType, id *string, ttsNow bool) (*ServerS if ttsNow { forcePausePlayer(playerType) - //NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, Server_ERR_RET.Error(), CONST_AUDIO_ID, AdSrcType_TTS, - // TTS_LEVEL_1, true, false) - mscToastTts(Server_ERR_RET.Error(), CONST_AUDIO_ID, true, false, nil) + mscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil) } else { if nil != wifiPlayerSt.MusicId && len(*wifiPlayerSt.MusicId) > 0 { ttsNoMusic = true @@ -526,8 +577,7 @@ func GetMusicListNew(playerType PlayerType, ttsNow bool, serverList http.MusicLi if len(err.Error()) > 0 { if ttsNow { forcePausePlayer(playerType) - //NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, *tts, CONST_AUDIO_ID, AdSrcType_TTS, TTS_LEVEL_1, true, false) - mscToastTts(err.Error(), CONST_AUDIO_ID, true, false, nil) + mscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil) } else { ttsNoMusic = true ttsMusicUuid = *wifiPlayerSt.MusicId @@ -549,9 +599,7 @@ func GetMusicListNew(playerType PlayerType, ttsNow bool, serverList http.MusicLi if ttsNow { forcePausePlayer(playerType) - //NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, Server_ERR_RET.Error(), CONST_AUDIO_ID, AdSrcType_TTS, - // TTS_LEVEL_1, true, false) - mscToastTts(Server_ERR_RET.Error(), CONST_AUDIO_ID, true, false, nil) + mscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil) } else { if nil != wifiPlayerSt.MusicId && len(*wifiPlayerSt.MusicId) > 0 { ttsNoMusic = true @@ -608,8 +656,7 @@ try: if ttsNow { forcePausePlayer(playerType) - //NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, *tts, CONST_AUDIO_ID, AdSrcType_TTS, TTS_LEVEL_1, true, false) - mscToastTts(err.Error(), CONST_AUDIO_ID, true, false, nil) + mscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil) } else { ttsNoMusic = true ttsMusicUuid = *wifiPlayerSt.MusicId @@ -624,9 +671,7 @@ try: if ttsNow { forcePausePlayer(playerType) - //NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, Server_ERR_RET.Error(), CONST_AUDIO_ID, AdSrcType_TTS, - // TTS_LEVEL_1, true, false) - mscToastTts(Server_ERR_RET.Error(), CONST_AUDIO_ID, true, false, nil) + mscToastFile(vui.SoundNotice_PullFromServer_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil) } else { if nil != wifiPlayerSt.MusicId && len(*wifiPlayerSt.MusicId) > 0 { ttsNoMusic = true @@ -823,13 +868,15 @@ func ProjectorVolProcess(newVolPer int) { if goalVerPer == oldVerPer { log.Println(log.WarningLog, "finis vol change") + VolChangeBroadcast(goalVerPer) goto Out_Vol } else if goalVerPer > oldVerPer { oldVerPer = oldVerPer + step } else { oldVerPer = oldVerPer - step } - VolChange(oldVerPer) + adau1761.SetVol(oldVerPer) + //VolChange(oldVerPer) log.Println(log.WarningLog, "cur perVol:", oldVerPer) case <-outVol: 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 { - 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) } } diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/player/dlnaPlayer.go b/app/netease_control_center_common_module/src/netease_control_center/modules/player/dlnaPlayer.go index ddbea19..4eade55 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/player/dlnaPlayer.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/player/dlnaPlayer.go @@ -76,7 +76,7 @@ func GetDlnaPlayPauseState() bool { } func DlnaPause() { - sendMusicCmd(CMD_PLAYER_PAUSE) + sendMusicCmd(PlayerType_Dlna, CMD_PLAYER_PAUSE) if !GetDlnaPlayPauseState() { SetDlnaPlayPauseState(false) } else { @@ -106,22 +106,14 @@ func DlnaPlay(start int, arg SCmd_Args) bool { } log.Println(log.WarningLog, "start:", start) - if REQUEST_PLAY_PARAMS == start { + if dlnaHasSetrg { log.Println(log.WarningLog, "dlnaHasSetrg:", dlnaHasSetrg) - if dlnaHasSetrg { - dlnaHasSetrg = false - dlnaPlayApi(dlnaPlayArg) - return true - } else if nil != dlnaPlayArg { - dlnaPlayApi(dlnaPlayArg) - return true - } else { - log.Println(log.ErrorLog, "hasSetDlnaArg false && dlnaPlayArg nil") - return false - } + dlnaHasSetrg = false + dlnaPlayApi(dlnaPlayArg) + return true } else { 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", PlayerHander[PlayerType_Dlna].GetPlayerStatus(), isChange) @@ -154,14 +146,14 @@ func DlnaPlay(start int, arg SCmd_Args) bool { } func DlnaStop() { - sendMusicCmd(CMD_PLAYER_PAUSE) + sendMusicCmd(PlayerType_Dlna, CMD_PLAYER_PAUSE) DlnaPlaySeek = false CtrlDlnaCmdToPhone(CTRL_DLNA_STOP) SetDlnaPlayPauseState(false) } func DlnaSeek(pos uint32) { - sendMusicCmd(CMD_PLAYER_SEEKTO, pos*1000) + sendMusicCmd(PlayerType_Dlna, CMD_PLAYER_SEEKTO, pos*1000) } func DlnaIsOnline() bool { @@ -236,7 +228,7 @@ func DlnaPlayerStatusChange(status PlayerDetail) { if "" != status.Uuid { if dlnaNeedSeekPos { dlnaNeedSeekPos = false - sendMusicCmd(CMD_PLAYER_SEEKTO, dlnaSeekPos) + sendMusicCmd(PlayerType_Dlna, CMD_PLAYER_SEEKTO, dlnaSeekPos) } updateDlnaPlayerStatus(status) @@ -251,7 +243,7 @@ func DlnaPlayerStatusChange(status PlayerDetail) { dlnaWaitNextTimer.Stop() } dlnaWaitNextTimer = time.AfterFunc(DlnaWaitNextTime.GetCfgListTime(), func() { - //DlnaStopTrig() + DlnaStopTrig() //CtrlDlnaCmdToPhone(CTRL_DLNA_NEXT) log.Printf(log.WarningLog, "wait dlna next timeout\n") }) @@ -263,7 +255,7 @@ func DlnaPlayerStatusChange(status PlayerDetail) { updateDlnaPlayerStatus(status) } 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) if nil != dlnaErrTimer { @@ -286,6 +278,8 @@ func DlnaPlayerStatusChange(status PlayerDetail) { 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: 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, @@ -356,7 +350,7 @@ func dlnaPlayApi(arg ...interface{}) { Url string `json:"url"` } if 0 == len(arg) { - sendMusicCmd(CMD_PLAYER_PLAY) + sendMusicCmd(PlayerType_Dlna, CMD_PLAYER_PLAY) } else if 1 == len(arg) { // params: json string switch argVal := arg[0].(type) { @@ -370,17 +364,17 @@ func dlnaPlayApi(arg ...interface{}) { log.Println(log.DebugLog, "url:", *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 } else { - sendMusicCmd(CMD_PLAYER_PLAY) + sendMusicCmd(PlayerType_Dlna, CMD_PLAYER_PLAY) } default: log.Println(log.WarningLog, "err params type") } } else if 2 == len(arg) { // 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) } } diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/player/normalPlayer.go b/app/netease_control_center_common_module/src/netease_control_center/modules/player/normalPlayer.go index 129843f..ebe3cef 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/player/normalPlayer.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/player/normalPlayer.go @@ -33,7 +33,7 @@ var ( ) func NormalPause() { - sendMusicCmd(CMD_PLAYER_PAUSE) + sendCurPlayerMusicCmd(CMD_PLAYER_PAUSE) } func NormalPlay(start int, arg SCmd_Args) bool { @@ -80,11 +80,11 @@ func NormalPlay(start int, arg SCmd_Args) bool { } func NormalStop() { - sendMusicCmd(CMD_PLAYER_STOP) + sendCurPlayerMusicCmd(CMD_PLAYER_STOP) } func NormalSeek(pos uint32) { - sendMusicCmd(CMD_PLAYER_SEEKTO, pos) + sendCurPlayerMusicCmd(CMD_PLAYER_SEEKTO, pos) } func NormalIsOnline() bool { @@ -150,7 +150,7 @@ func NormalPlayerStatusChange(status PlayerDetail) { func normalPlayApi(e interface{}) { if nil == e { - sendMusicCmd(CMD_PLAYER_PLAY) + sendCurPlayerMusicCmd(CMD_PLAYER_PLAY) return } @@ -498,7 +498,7 @@ func normalPlayerStHd(status PlayerDetail) error { if "" != status.Uuid { if normalNeedSeekToPos { normalNeedSeekToPos = false - sendMusicCmd(CMD_PLAYER_SEEKTO, normalSeekPos) + sendCurPlayerMusicCmd(CMD_PLAYER_SEEKTO, normalSeekPos) } updateNormalPlayerStatus(status) @@ -921,10 +921,10 @@ func lowLevelPlayApi(arg commonPlayApiArg) error { } } 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) } 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) } LocalMusicList[PLAYSONG_MUSIC_LIST].Push(arg.songId, true) diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/player/noticePlayer.go b/app/netease_control_center_common_module/src/netease_control_center/modules/player/noticePlayer.go index b8b3ba6..e4d099e 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/player/noticePlayer.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/player/noticePlayer.go @@ -59,9 +59,9 @@ func GetDefaultNoticePlayerParams() schedule.NoticePlayerParams { tmp.Level = TTS_LEVEL_1 tmp.SpecialCmd = "" - tmp.SpecialFunc = nil - tmp.BeforeSpecialFunc = nil - tmp.BeforeExecFunc = nil + tmp.SpecialFunc = func(arg schedule.TtsPlayerArg) {} + tmp.BeforeSpecialFunc = func() {} + tmp.BeforeExecFunc = func() {} tmp.Uuid = CONST_AUDIO_ID return tmp @@ -254,9 +254,9 @@ func noticePlayerCallback(id uint32, reason schedule.NoticeStopReason, params *s schedule.NoticeStopReason_Error: if reason == schedule.NoticeStopReason_Error { - if params.Uuid != CONST_AUDIO_ID { - //log.Println(log.WarningLog, "end srcUuid:", params.Uuid) - if IsLocalAudioUuid(params.Uuid) { + if params.Uuid != CONST_AUDIO_ID { + //log.Println(log.WarningLog, "end srcUuid:", params.Uuid) + if IsLocalAudioUuid(params.Uuid) { eventPoint.AudioErrorEp(params.Uuid, params.Tts, "error", eventPoint.EpOs_Device) } else { 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 { //log.Println(log.WarningLog, "end srcUuid:", params.Uuid) if IsLocalAudioUuid(params.Uuid) { - eventPoint.AudioEnd(params.Uuid, params.Tts, "break", eventPoint.EpOs_Device) - } else { - eventPoint.AudioEnd(params.Uuid, params.Tts, "break", eventPoint.EpOs_Server) + eventPoint.AudioEnd(params.Uuid, params.Tts, "break", eventPoint.EpOs_Device) + } else { + 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 */ 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, diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/player/scenesPlayer.go b/app/netease_control_center_common_module/src/netease_control_center/modules/player/scenesPlayer.go index 4f663ce..6b241fa 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/player/scenesPlayer.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/player/scenesPlayer.go @@ -79,6 +79,11 @@ const ( 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) { ignoreRestoreVol := hd.GetIgnoreVolRestore() log.Printf(log.ErrorLog, "ignoreRestoreVol:%+v\n", ignoreRestoreVol) @@ -86,7 +91,7 @@ func ScenesPause(hd SSceneHd) { EndVoiceGrandateDisappear(RESTORE_VOL) } - sendMusicCmd(CMD_PLAYER_PAUSE) + sendScenesMusicCmd(hd ,CMD_PLAYER_PAUSE) } 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) { EndVoiceGrandateDisappear(RESTORE_VOL) - sendMusicCmd(CMD_PLAYER_STOP) + sendScenesMusicCmd(hd ,CMD_PLAYER_STOP) } func ScenesPlayNext(hd SSceneHd) { @@ -254,7 +259,7 @@ func ScenesPlayPre(hd SSceneHd) { } func ScenesPlaySeek(hd SSceneHd, pos uint32) { - sendMusicCmd(CMD_PLAYER_SEEKTO, pos) + sendScenesMusicCmd(hd ,CMD_PLAYER_SEEKTO, pos) } func ScenesPlayerStatusChange(status PlayerDetail, hd SSceneHd) { @@ -268,7 +273,7 @@ func ScenesAppCtrlPlay(e interface{}) { func scenesPlayApi(e interface{}) { log.Printf(log.DebugLog, "scene params:%+v\n", e) if nil == e { - sendMusicCmd(CMD_PLAYER_PLAY) + sendScenesMusicCmd(hdCur ,CMD_PLAYER_PLAY) return } @@ -589,7 +594,7 @@ func scenesNextApi(prepare bool) (MusicChangeAction, error) { // 当前列表空 case ACTION_STOP_PLAYER: log.Println(log.DebugLog, "scenes player auto stop, taskNoCur:", taskNoCur) - sendMusicCmd(CMD_PLAYER_PAUSE) + sendScenesMusicCmd(hdCur ,CMD_PLAYER_PAUSE) hdCur.GetPlayerHd().ReportOffline() // todo scenes play auto stop, process your things @@ -757,7 +762,7 @@ func scenesPlayerStHd(status PlayerDetail) error { if "" != status.Uuid { if scenesNeedSeekToPos { scenesNeedSeekToPos = false - sendMusicCmd(CMD_PLAYER_SEEKTO, scenesSeekPos) + sendScenesMusicCmd(hdCur ,CMD_PLAYER_SEEKTO, scenesSeekPos) } updateScenesPlayerStatus(status) @@ -1225,10 +1230,10 @@ func lowLevelScenesPlayApi(arg commonPlayApiArg) error { } 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) } 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) } LocalMusicList[PLAYSONG_MUSIC_LIST].Push(arg.songId, true) diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/player/utilsTest.go b/app/netease_control_center_common_module/src/netease_control_center/modules/player/utilsTest.go index 64817fc..9a84fdc 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/player/utilsTest.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/player/utilsTest.go @@ -55,7 +55,7 @@ func getInputCmd() { case CMD_PLAYER_PLAY, CMD_PLAYER_PAUSE, CMD_PLAYER_STOP: - sendMusicCmd(cmd) + sendCurPlayerMusicCmd(cmd) case CMD_PLAYER_NEXT: schedule.SendSCmd(schedule.SCMD_MusicPlayer_PlayNext, nil) case CMD_PLAYER_PRE: @@ -68,7 +68,7 @@ func getInputCmd() { if nil != err { continue } - sendMusicCmd(CMD_PLAYER_SEEKTO, uint32(seek*1000)) + sendCurPlayerMusicCmd(CMD_PLAYER_SEEKTO, uint32(seek*1000)) case uint32(MUSIC_ST_FOR_NEXT): var playerSt schedule.PlayerDetail playerSt.Status = MUSIC_ST_FOR_NEXT @@ -155,7 +155,7 @@ func getInputCmd() { } case CMD_ALARM_S: // todo - sendMusicCmd(CMD_SEARCH_PLAYER_REQ) + sendCurPlayerMusicCmd(CMD_SEARCH_PLAYER_REQ) case CMD_ALARM_L: // todo case CMD_OTA_TTS: diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/player/wifiPlayer.go b/app/netease_control_center_common_module/src/netease_control_center/modules/player/wifiPlayer.go index 3ad0ba1..e9d435c 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/player/wifiPlayer.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/player/wifiPlayer.go @@ -6,6 +6,9 @@ import ( "netease_control_center/interfaces/http" "netease_control_center/interfaces/log" . "netease_control_center/interfaces/schedule" + "netease_control_center/modules/hardware/mcu_leds/atservice" + "time" + "netease_control_center/interfaces/vui" ) const ( @@ -30,6 +33,24 @@ func WifiPause() { 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 { if !isNetConnect() { log.Println(log.ErrorLog, "WifiPlay: internet is down") @@ -139,6 +160,7 @@ func WifiPlay(start int, arg SCmd_Args) bool { func WifiStop() { if !isNetConnect() { log.Println(log.ErrorLog, "WifiStop: internet is down") + toastNetworkError(false) return } @@ -148,6 +170,7 @@ func WifiStop() { func WifiSeek(pos uint32) { if !isNetConnect() { log.Println(log.ErrorLog, "WifiSeek: internet is down") + toastNetworkError(false) return } wifiSeekApi(pos) @@ -165,6 +188,7 @@ func WifiIfForcePause() bool { func WifiPlayNext(arg interface{}) { if !isNetConnect() { log.Println(log.ErrorLog, "WifiPlayNext: internet is down") + toastNetworkError(false) return } wifiNextApi(arg) @@ -173,6 +197,7 @@ func WifiPlayNext(arg interface{}) { func WifiPlayPre(arg interface{}) { if !isNetConnect() { log.Println(log.ErrorLog, "WifiPlayPre: internet is down") + toastNetworkError(false) return } wifiPreApi(arg) @@ -296,7 +321,7 @@ func KeyTriggerPlayorPause() { playMusic(nil) } 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 { if nil != tmp.Data { for _, id := range tmp.Data { - err := LocalMusicFilter.Push(tmp.Type, &id) + tmpsongId := id + err := LocalMusicFilter.Push(tmp.Type, &tmpsongId) if nil != err { log.Println(log.WarningLog, err.Error()) } diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/player/wifiPlayerApi.go b/app/netease_control_center_common_module/src/netease_control_center/modules/player/wifiPlayerApi.go index 81e0522..3fd3c3d 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/player/wifiPlayerApi.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/player/wifiPlayerApi.go @@ -15,6 +15,7 @@ import ( "strings" "sync" "time" + "math" ) var ( @@ -65,7 +66,7 @@ wifiPlayApi */ func wifiPlayApi(e interface{}) bool { if nil == e { - sendMusicCmd(CMD_PLAYER_PLAY) + sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY) //songId := PlayerHander[PlayerType_Wifi].GetPlayerStatus().Uuid //songDetail, err := getSongDetailInfo(PlayerType_Wifi, &songId, false) @@ -113,11 +114,11 @@ func wifiPlayApi(e interface{}) bool { } func wifiPauseApi() { - sendMusicCmd(CMD_PLAYER_PAUSE) + sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PAUSE) } func wifiStopApi() { - sendMusicCmd(CMD_PLAYER_STOP) + sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_STOP) } func wifiNextApi(arg interface{}) { @@ -143,11 +144,11 @@ func wifiPrepareNextApi() { } func wifiSeekApi(pos uint32) { - sendMusicCmd(CMD_PLAYER_SEEKTO, pos) + sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_SEEKTO, pos) } 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 { wifiNeedSeekToPos = false - sendMusicCmd(CMD_PLAYER_SEEKTO, wifiSeekPos) + sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_SEEKTO, wifiSeekPos) } if nil == wifiPlayerSt.MusicId || *wifiPlayerSt.MusicId != status.Uuid || @@ -230,8 +231,13 @@ func wifiPlayerStHd(status schedule.PlayerDetail) error { forcePausePlayer(PlayerType_Wifi) //NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, ttsInfo, CONST_AUDIO_ID, AdSrcType_TTS, TTS_LEVEL_1, // true, false) - mscToastTts(ttsInfo, CONST_AUDIO_ID, true, false, nil) - log.Println(log.DebugLog, "tts when music end:", ttsInfo) + if ttsInfo == TTS_TEXT_ORDER_PLAY_END_FLAG { + 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 { @@ -277,6 +283,7 @@ func wifiPlayerStHd(status schedule.PlayerDetail) error { } else { errWifiPlayCnt = 0 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 { timePause := time.Now().Sub(wifiPlayerSt.ContinuousStChangeTime) if timePause < T1Timeout.GetCfgListTime() { - sendMusicCmd(CMD_PLAYER_PLAY) + sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY) } else if timePause < T2Timeout.GetCfgListTime() { log.Println(log.DebugLog, "t1~t2 now:", time.Now().Unix(), " listTime:", wifiPlayerSt.ContinuousStChangeTime.Unix()) @@ -425,6 +432,7 @@ func playMusic(e interface{}) MusicAction { // 清除歌曲过滤列表 LocalMusicFilter.Init() + PlayListSrcRec.ListHasEnd = false //歌单播放结束标志位false switch srcType { 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 } + log.Printf(log.DebugLog, "param when play from app:%+v\n", appReq) + PlayListSrcRec.ListHasEnd = false //歌单播放结束标志位false + if INVAILED_INDEX != appReq.Index { // 当前播放列表中歌曲 listType := GetMusicListIndex() @@ -870,7 +881,7 @@ func playNewHotDailyMusic(serverData *ServerMusicList, rcmdSrc bool) (MusicActio /* 此时,不需要对推送的歌单进行鉴权保护,因为此时是直接播放暂停的歌曲,歌单鉴权保护,等待歌曲切换时再进行保护 */ // 恢复播放 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 { // 歌单有更新 @@ -878,7 +889,7 @@ func playNewHotDailyMusic(serverData *ServerMusicList, rcmdSrc bool) (MusicActio " t2:", serverData.MusicList.UpdateTime) musicAction = NHD_LESS_T1_UPDATE - forcePlayCur = true + //forcePlayCur = true 现在产品的逻辑是重复意图切换下一首 } else { needReplay = true // 歌单无更新 @@ -1036,7 +1047,7 @@ func playNewHotDailyMusic(serverData *ServerMusicList, rcmdSrc bool) (MusicActio } } if needReplay { - /*sendMusicCmd(CMD_PLAYER_PLAY) + /*sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY) // 歌曲续播的,该次语音的rspid清除掉 RspId = nil*/ //重复意图,直接切歌 @@ -1123,7 +1134,7 @@ func playPrivateFM(serverData *ServerMusicList) (MusicAction, error) { // 恢复播放 //log.Println(log.DebugLog, "replay playPrivateFM") //needReplay = true //全新开始,不是replay - //sendMusicCmd(CMD_PLAYER_PLAY) + //sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY) //musicAction = FM_LESS_T1 //needUpdate = false //全新开始,需要update 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) if needReplay { - /*sendMusicCmd(CMD_PLAYER_PLAY) + /*sendMusicCmd((PlayerType_Wifi, CMD_PLAYER_PLAY) // 歌曲续播的,该次语音的rspid清除掉 RspId = nil*/ //重复意图,直接切歌 @@ -1315,7 +1326,7 @@ func playNormalListMusic(replace bool, e interface{}) (MusicAction, error) { // 更新时间变,需要替换歌单 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) songId, songUrl = getCanPlaySong(e) } @@ -1366,7 +1377,7 @@ func playNormalListMusic(replace bool, e interface{}) (MusicAction, error) { } if needReplay { - /*sendMusicCmd(CMD_PLAYER_PLAY) + /*sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY) // 歌曲续播的,该次语音的rspid清除掉 RspId = nil*/ //重复意图,直接切歌 @@ -1930,23 +1941,25 @@ func prepareNextMusic() error { back, _ := NormalListMap[NORMAL_LIST_PAGE].GetLast() if nil == back || 1 == back.Value.(*PageNode).PageIndex || MUSIC_LIST_NULL == PlayListSrcRec.MusicSrc { - tmpCurPos, err := LocalMusicList[curMusicList].GetFirst() - if nil != err { - log.Println(log.ErrorLog, err.Error()) - return err - } - LocalMusicList[curMusicList].SetCurPos(tmpCurPos) + if CurPlayingMode != LIST_ORDER_PLAY { + tmpCurPos, err := LocalMusicList[curMusicList].GetFirst() + if nil != err { + log.Println(log.ErrorLog, err.Error()) + return err + } + LocalMusicList[curMusicList].SetCurPos(tmpCurPos) - if LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo).CanPlay { + if LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo).CanPlay { - } else { - LocalMusicList[curMusicList].GetValidNext() + } else { + LocalMusicList[curMusicList].GetValidNext() + } + + songId = LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo) } log.Println(log.DebugLog, "loop list for only one list, one page") //开始重复播放,有且只有一个歌单,只有一页 isRepeat = true - - songId = LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo) } else { if CurPlayingMode != LIST_ORDER_PLAY { // 拉取第一页 @@ -1991,9 +2004,13 @@ func prepareNextMusic() error { if ACTION_NEXT_LIST_REPLACE_LIST == action { PlayListSrcRec.MusicListIdIndex += 1 } 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 + if CurPlayingMode == LIST_ORDER_PLAY { + break + } + //开始重复播放,重新播放第一个歌单 + PlayListSrcRec.MusicListIdIndex = 0 } var listCnt MusicLenType = 0 @@ -2051,10 +2068,14 @@ func prepareNextMusic() error { // 当前播放的是我的歌单,在创建的歌单和收藏的歌单之间循环 action = ACTION_USER_LIST_CYCLE } else { - // 歌单播放完毕,且后续没有歌单,重新播放第一个歌单 - action = ACTION_CYCLY_TO_FRONT_LIST_REPLACE_LIST log.Println(log.DebugLog, "loop list for get front list") isRepeat = true + if CurPlayingMode == LIST_ORDER_PLAY { + break + } + + // 歌单播放完毕,且后续没有歌单,重新播放第一个歌单 + action = ACTION_CYCLY_TO_FRONT_LIST_REPLACE_LIST } } else { //下一个歌单 @@ -2071,9 +2092,12 @@ func prepareNextMusic() error { // 切换时,歌单index需要清零 listIndex = 0 if USER_LISTS_COLLECT == curUserListsType { - srcType = USER_LISTS_CREATE log.Println(log.DebugLog, "loop list for get create user list") isRepeat = true + if CurPlayingMode == LIST_ORDER_PLAY { + break + } + srcType = USER_LISTS_CREATE } else { srcType = USER_LISTS_COLLECT } @@ -2110,6 +2134,9 @@ func prepareNextMusic() error { if srcType != curUserListsType { log.Println(log.DebugLog, "loop list for no collect user list") //没有收藏的歌单,开始重复播放 isRepeat = true + if CurPlayingMode == LIST_ORDER_PLAY { + break + } } NormalListMap[NORMAL_LIST_PAGE].Init() @@ -2129,11 +2156,11 @@ func prepareNextMusic() error { //第一次循环播放时,播放copyright tts var isFirstRepeat bool = false 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") - /*ttsNoMusic = true + ttsNoMusic = true ttsMusicUuid = curSongInfo.Id - ttsInfo = TTS_TEXT_RADIO_END*/ + ttsInfo = TTS_TEXT_ORDER_PLAY_END_FLAG return nil } if needPlayCopyrightTTs == true && len(tts) == 0 && len(ttsUrl) == 0 { @@ -2270,16 +2297,20 @@ func prevMusic(arg interface{}) (MusicChangeAction, error) { filterTts = false } case ACTION_PLAY_BACK: - if CurPlayingMode == LIST_ORDER_PLAY && PlayListSrcRec.BizType != BIZ_TYPE_MUSIC { + if CurPlayingMode == LIST_ORDER_PLAY { 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") - //push tts to server - http.InformMsgToServer(http.Type_Inform_TtsDelay, TTS_TEXT_FIRST_RADIO) + var noPreOne string + 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) { switch reason { case schedule.NoticeStart_Play: @@ -2292,11 +2323,15 @@ func prevMusic(arg interface{}) (MusicChangeAction, error) { ttsExecVuiStop() //schedule.SendSCmd(schedule.SCMD_MusicPlayer_Play, nil) - sendMusicCmd(CMD_PLAYER_PLAY) + sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY) 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 } else { tmpCurPos, err := LocalMusicList[curMusicList].GetLast() @@ -2312,18 +2347,32 @@ func prevMusic(arg interface{}) (MusicChangeAction, error) { LocalMusicList[curMusicList].GetValidPre() } } - case ACTION_NEXT_PAGE_REPLACE_LIST, ACTION_MISS_PAGE_REPLACE_LIST, ACTION_LAST_PAGE: - if ACTION_NEXT_PAGE_REPLACE_LIST == action { - if CurPlayingMode == LIST_ORDER_PLAY && PlayListSrcRec.BizType != BIZ_TYPE_MUSIC { + case ACTION_PRE_PAGE_REPLACE_LIST, ACTION_MISS_PAGE_REPLACE_LIST, ACTION_LAST_PAGE, ACTION_NEXT_PAGE_REPLACE_LIST: + if ACTION_PRE_PAGE_REPLACE_LIST == action { + // 还有前一个分页,拉取分页 + 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() { - sendMusicCmd(CMD_PLAYER_PAUSE) + sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PAUSE) } log.Println(log.DebugLog, "play list no back because list order play mode") - //push tts to server - http.InformMsgToServer(http.Type_Inform_TtsDelay, TTS_TEXT_FIRST_RADIO) + var noPreOne string + 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) { switch reason { case schedule.NoticeStart_Play: @@ -2336,24 +2385,48 @@ func prevMusic(arg interface{}) (MusicChangeAction, error) { ttsExecVuiStop() //schedule.SendSCmd(schedule.SCMD_MusicPlayer_Play, nil) - sendMusicCmd(CMD_PLAYER_PLAY) + sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY) default: } }) return ACTION_NULL, nil } - // 还有剩余分页,拉取分页 - if val, err := NormalListMap[NORMAL_LIST_PAGE].GetLast(); nil == err { - index = val.Value.(*PageNode).PageIndex * PAGE_SIZE + + var err error + 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) @@ -2482,6 +2555,7 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) { if (SINGLE_CYCLE == CurPlayingMode && false) || forcePlayCur { // 上/下一曲忽略单曲循环 // 单曲循环时,直接拿当前的音乐节点播放 songId = LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo) + log.Printf(log.WarningLog, "force play cur song:%+v\n", songId) forcePlayCur = false } else { pullNextListByIdAgain: @@ -2538,9 +2612,7 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) { var pageSize MusicLenType = PAGE_SIZE if ACTION_NEXT_PAGE_REPLACE_LIST == action { // 还有剩余分页,拉取分页,不重置分页信息 - if val, err := NormalListMap[NORMAL_LIST_PAGE].GetLast(); nil == err { - index = val.Value.(*PageNode).PageIndex * PAGE_SIZE - } + index = NormalListMap[NORMAL_LIST_PAGE].CurPos.Value.(*PageNode).PageIndex * PAGE_SIZE } else if ACTION_MISS_PAGE_REPLACE_LIST == action { // 有缺失的分页,拉取分页,不重置分页信息 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() if nil == back || 1 == back.Value.(*PageNode).PageIndex || MUSIC_LIST_NULL == PlayListSrcRec.MusicSrc { - tmpCurPos, err := LocalMusicList[curMusicList].GetFirst() - if nil != err { - log.Println(log.ErrorLog, err.Error()) - return ACTION_NULL, err - } - LocalMusicList[curMusicList].SetCurPos(tmpCurPos) + if CurPlayingMode != LIST_ORDER_PLAY { + tmpCurPos, err := LocalMusicList[curMusicList].GetFirst() + if nil != err { + log.Println(log.ErrorLog, err.Error()) + return ACTION_NULL, err + } + LocalMusicList[curMusicList].SetCurPos(tmpCurPos) - if LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo).CanPlay { + if LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo).CanPlay { - } else { - LocalMusicList[curMusicList].GetValidNext() + } else { + LocalMusicList[curMusicList].GetValidNext() + } + + songId = LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo) } log.Println(log.DebugLog, "loop list for only one list, one page") //开始重复播放,有且只有一个歌单,只有一页 isRepeat = true - - songId = LocalMusicList[curMusicList].GetCurPos().Value.(*SongInfo) } else { if CurPlayingMode != LIST_ORDER_PLAY { // 拉取第一页 @@ -2650,9 +2724,14 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) { if ACTION_NEXT_LIST_REPLACE_LIST == action { PlayListSrcRec.MusicListIdIndex += 1 } 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 + if CurPlayingMode == LIST_ORDER_PLAY { + break + } + + //开始重复播放,重新播放第一个歌单 + PlayListSrcRec.MusicListIdIndex = 0 } var listCnt MusicLenType = 0 @@ -2710,10 +2789,13 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) { // 当前播放的是我的歌单,在创建的歌单和收藏的歌单之间循环 action = ACTION_USER_LIST_CYCLE } else { - // 歌单播放完毕,且后续没有歌单,重新播放第一个歌单 - action = ACTION_CYCLY_TO_FRONT_LIST_REPLACE_LIST log.Println(log.DebugLog, "loop list for get front list") isRepeat = true + if CurPlayingMode == LIST_ORDER_PLAY { + break + } + // 歌单播放完毕,且后续没有歌单,重新播放第一个歌单 + action = ACTION_CYCLY_TO_FRONT_LIST_REPLACE_LIST } } else { //下一个歌单 @@ -2733,6 +2815,9 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) { srcType = USER_LISTS_CREATE log.Println(log.DebugLog, "loop list for get create user list") isRepeat = true + if CurPlayingMode == LIST_ORDER_PLAY { + break + } } else { srcType = USER_LISTS_COLLECT } @@ -2768,6 +2853,9 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) { if srcType != curUserListsType { log.Println(log.DebugLog, "loop list for no collect user list") //没有收藏的歌单,开始重复播放 isRepeat = true + if CurPlayingMode == LIST_ORDER_PLAY { + break + } } NormalListMap[NORMAL_LIST_PAGE].Init() @@ -2787,16 +2875,20 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) { //第一次循环播放时,播放copyright tts var isFirstRepeat bool = false if isRepeat { - if CurPlayingMode == LIST_ORDER_PLAY && PlayListSrcRec.BizType != BIZ_TYPE_MUSIC { + if CurPlayingMode == LIST_ORDER_PLAY { 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") - //push tts to server - http.InformMsgToServer(http.Type_Inform_TtsDelay, TTS_TEXT_LAST_RADIO) + var noNextOne string + 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) { switch reason { case schedule.NoticeStart_Play: @@ -2809,11 +2901,22 @@ func nextMusic(arg interface{}) (MusicChangeAction, error) { ttsExecVuiStop() //schedule.SendSCmd(schedule.SCMD_MusicPlayer_Play, nil) - sendMusicCmd(CMD_PLAYER_PLAY) + if !PlayListSrcRec.ListHasEnd { + sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY) + } 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 } if needPlayCopyrightTTs == true && len(tts) == 0 && len(ttsUrl) == 0 { @@ -2902,6 +3005,8 @@ func commonPlayApi(arg commonPlayApiArg) error { MusicActionSrcNew = &arg.actionSrc } + //log.Println(log.ErrorLog, "PlayListSrcRec.MusicListId:", *PlayListSrcRec.MusicListId) + var tts *string = nil var ttsR *string = &arg.tts var ttsAdSrcType AdSrcType //混音tts type @@ -2940,6 +3045,9 @@ func commonPlayApi(arg commonPlayApiArg) error { if arg.songId != nil { 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 { log.Println(log.DebugLog, "common Play:songId is nil") } @@ -2992,7 +3100,7 @@ func commonPlayApi(arg commonPlayApiArg) error { " musicListLen:", MusicLenType(LocalMusicList[curMusicList].List.Len())) if !found || musicCnt >= MusicLenType(LocalMusicList[curMusicList].List.Len()) { searchPage: - // case 1: 歌单中还有分页需要处理 + // case 1: 歌单中还有分页需要处理 if denyTimesCnt < DENY_MAX_TIMES && (NormalListMap[NORMAL_LIST_PAGE].HasMore || pageCnt < NormalListMap[NORMAL_LIST_PAGE].MaxPage) { denyTimesCnt++ @@ -3022,9 +3130,13 @@ func commonPlayApi(arg commonPlayApiArg) error { // 本地歌单列表中还有歌单待拉取 PlayListSrcRec.MusicListIdIndex += 1 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 + if CurPlayingMode == LIST_ORDER_PLAY { + goto out + } + //开始重复播放,重新播放第一个歌单 + PlayListSrcRec.MusicListIdIndex = 0 } list, err := GetMusicListNew(PlayerType_Wifi, false, http.MusicListServerType{ 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) listIndex = 0 if USER_LISTS_COLLECT == curUserListsType { - curUserListsType = USER_LISTS_CREATE log.Println(log.DebugLog, "loop list for get create user list") isRepeat = true + if CurPlayingMode == LIST_ORDER_PLAY { + goto out + } + curUserListsType = USER_LISTS_CREATE } else { curUserListsType = USER_LISTS_COLLECT } @@ -3114,11 +3229,14 @@ func commonPlayApi(arg commonPlayApiArg) error { if curUserListsType != UserListsType { log.Println(log.DebugLog, "loop list for no collect user list") //没有收藏的歌单,开始重复播放 isRepeat = true + if CurPlayingMode == LIST_ORDER_PLAY { + goto out + } } listCnt = 1 log.Println(log.ErrorLog, "list Cnt:", listCnt, ", listIdsLen:", PlayListSrcRec.MusicListIdsLen, - "GetCurPos:", LocalMusicList[GetMusicListIndex()].GetCurPos()) + ", GetCurPos:", LocalMusicList[GetMusicListIndex()].GetCurPos()) if nil != LocalMusicList[GetMusicListIndex()].GetCurPos() { arg.songId = LocalMusicList[GetMusicListIndex()].GetCurPos().Value.(*SongInfo) goto searchMusic @@ -3171,16 +3289,16 @@ func commonPlayApi(arg commonPlayApiArg) error { goto out } specialOut: - //// case 4: 错误信息播报 - // log.Printf(log.DebugLog, "\n can not play because of lists is invalid:%v srcType:%d\n", - // MusicErrTtsMap[string(arg.srcType)], arg.srcType) - // - // forcePausePlayer(PlayerType_Wifi) - // - // mscToastTts(MusicErrTtsMap[string(arg.srcType)], CONST_AUDIO_ID, true, false, nil) - // ResetWifiPlayer() - // return MusicList_ERR_MUSIC_NULL - // prd reverse 20180428 : 拉取特定的接口,如果失败,播放备用的tts + //// case 4: 错误信息播报 + // log.Printf(log.DebugLog, "\n can not play because of lists is invalid:%v srcType:%d\n", + // MusicErrTtsMap[string(arg.srcType)], arg.srcType) + // + // forcePausePlayer(PlayerType_Wifi) + // + // mscToastTts(MusicErrTtsMap[string(arg.srcType)], CONST_AUDIO_ID, true, false, nil) + // ResetWifiPlayer() + // return MusicList_ERR_MUSIC_NULL + // prd reverse 20180428 : 拉取特定的接口,如果失败,播放备用的tts log.Println(log.WarningLog, "get special music list from server...") // case 4: 拉取特定接口 PlayListSrcRec.CopyrightTts.TtsType = 0 //开始拉取特殊通道,清除版权的ttstype标记 @@ -3235,6 +3353,62 @@ func commonPlayApi(arg commonPlayApiArg) error { 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() if isNewHotDailyPlaying && arg.needChangeNHDIndex { _, 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 schedule.GetCurPlayer().IsPlaying() { //schedule.SendSCmd(schedule.SCMD_MusicPlayer_Pause, nil)//改为直接发送暂停,否则这个命令会比下面的PlayNoticeAsync调度的更晚,造成时序错误 - sendMusicCmd(CMD_PLAYER_PAUSE) + sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PAUSE) } var listOnlyOne string @@ -3295,14 +3469,6 @@ func commonPlayApi(arg commonPlayApiArg) error { //当前只有一首歌了,播报tts后,返回 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, func(id uint32, reason schedule.NoticeStopReason) { switch reason { @@ -3316,11 +3482,24 @@ func commonPlayApi(arg commonPlayApiArg) error { ttsExecVuiStop() //schedule.SendSCmd(schedule.SCMD_MusicPlayer_Play, nil) - sendMusicCmd(CMD_PLAYER_PLAY) + sendMusicCmd(PlayerType_Wifi, CMD_PLAYER_PLAY) 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 } 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, PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING,}) }*/ - http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_NEXT), Data: *ttsR, Tts: *ttsR, - PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING}) + if arg.rspId == CONST_AUDIO_ID { + 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 { http.PushInfoToServerForApp(http.InfoForApp{ResponseId: arg.rspId, Cmd: int(MSC_CMD_PRE), Data: *ttsR, Tts: *ttsR, PlayMode: CurPlayingMode, DataType: http.DATA_TYPE_STRING}) } } else { if arg.nextOrPreSong { - 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}) + if arg.rspId == CONST_AUDIO_ID { + 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 { 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}) @@ -3386,6 +3573,10 @@ func commonPlayApi(arg commonPlayApiArg) error { } curSongInfo = arg.songId + if PlayListSrcRec.MusicListId != nil { + //备份listId,由于版权问题,顺序播放的时候,如果版权有问题,list可能被覆盖,会造成同步listId不对,需要恢复listId + curSongInfo.MusicListId = *PlayListSrcRec.MusicListId + } if arg.prepare { /* 准备下一首是播放器自己调度的,播放器内部修改一下状态 */ status := PlayerHander[PlayerType_Wifi].GetPlayerStatus() @@ -3396,7 +3587,7 @@ func commonPlayApi(arg commonPlayApiArg) error { status.PlayerId = uint32(PlayerType_Wifi) 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 { if backGroundPlayerTest && nil == arg.songId.BGUrl && nil != tts && len(*tts) > 0 { // 有tts播报的音乐播放背景音测试 bgUrl := vui.SoundNotice_Volume.GetPath() @@ -3404,14 +3595,14 @@ func commonPlayApi(arg commonPlayApiArg) error { } 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 { if nil != tts && len(*tts) > 0 { if strings.Contains(*tts, "%s") && songDetail != nil { //判断服务器下发的tts里是否有%s字段 *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) @@ -3730,20 +3921,30 @@ func getNextPrevAction(needNextAction bool) MusicChangeAction { ret = ACTION_PLAY_BACK } else if MUSIC_SHARE_RCMD == PlayListSrcRec.MusicSrc { ret = ACTION_ADD_LIST_MUSIC_SHARE - } else if NormalListMap[NORMAL_LIST_PAGE].HasMore { - // 还有分页 - ret = ACTION_NEXT_PAGE_REPLACE_LIST + } else if NormalListMap[NORMAL_LIST_PAGE].CurPos.Value.(*PageNode).PageIndex >= 2 { + // 前一分页 + ret = ACTION_PRE_PAGE_REPLACE_LIST } else if MUSIC_LIST_WORD == PlayListSrcRec.MusicSrc || MUSIC_LIST_SERACH_WORD == PlayListSrcRec.MusicSrc { ret = ACTION_PLAY_BACK } else if nil != back && 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 } else { if 1 == MusicLenType(NormalListMap[NORMAL_LIST_PAGE].List.Len()) || MUSIC_LIST_NULL == PlayListSrcRec.MusicSrc { - // 如果只有1页 / 如果都是单曲插入,直接播放最后1首 - ret = ACTION_PLAY_BACK + if NormalListMap[NORMAL_LIST_PAGE].HasMore { + // 当前只有一页信息,而且还有下一页,只能拉取下一分页 + 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 { ret = ACTION_LAST_PAGE } @@ -3971,8 +4172,12 @@ func ResetWifiPlayer() { 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, - TaskField: FIELD_NULL, + TaskField: FIELD_NULL, SingleTaskSt: AUDIO_ST_IDLE} + status := PlayerHander[PlayerType_Wifi].GetPlayerStatus() + status.Status = MUSIC_ST_IDLE + PlayerHander[PlayerType_Wifi].SetPlayerStatus(status) + log.Println(log.DebugLog, "unlock") } diff --git a/app/netease_voice_common_module/src/yunxin.c b/app/netease_voice_common_module/src/yunxin.c old mode 100644 new mode 100755 index cdbf0cd..6a0c953 --- a/app/netease_voice_common_module/src/yunxin.c +++ b/app/netease_voice_common_module/src/yunxin.c @@ -373,13 +373,20 @@ static void Netease_yunxin_msgcb(const char *content, // n_toast("%s\n", json_dumps(js, 0)); char *body = NULL; char *talk_id = NULL; - json_unpack(js, "{s:{s:s, s:s}}", kNIMSessionListContent, - kNIMSessionMsgBody, &body, "talk_id", &talk_id); + long long ts = 0; + 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) { - n_toast("\nBody:%s\n body-len:%d\n Id:%s\n", body, strlen(body), - talk_id); + n_toast("\nBody:%s\n body-len:%d\n Id:%s " + "offline:%d\ntimeStamp:%llu curTs:%llu\n", + body, strlen(body), talk_id, offline, ts, cTs); + Netease_Dbus_Send_CMD(MODULE_VOICEENGINE, MODULE_CONTROLLER, - CMD_YUNXIN_RECVMSG, body, strlen(body)); + CMD_YUNXIN_RECVMSG, content, strlen(content)); } else { n_error("Decode error!!!!!\n"); }