package player

import (
	"fmt"
	. "netease_control_center/globals"
	"netease_control_center/interfaces/http"
	"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/storage"
	"netease_control_center/nembd/controller/adau1761"
	"netease_control_center/test"
	"strconv"
	"time"
)

type KeyTestType uint8

const (
	DAILY_PUSH_TYPE KeyTestType = iota
	HOT_TOP_TYPE
	NEW_TOP_TYPE
	DENON_TOP_TYPE
	CLASSIC_TOP_TYPE
	ORIGINAL_TOP_TYPE
	BEATPORT_TOP_TYPE
	SOARING_TOP_TYPE
	ACG_TOP_TYPE
	CREATE_LISTS_TYPE
	SINGLE_TYPE
	PRIVATE_FM_TYPE

	CH_NEW_TYPE
	JP_NEW_TYPE
)

/**
获取终端控制台的输入
*/
func getInputCmd() {
	for {
		cmd, params, err := test.ReadInputCmd()
		if nil != err {
			continue
		}
		log.Printf(log.DebugLog, "cmd:0x%x\n", cmd)
		if nil != params && len(*params) > 0 {
			log.Println(log.DebugLog, "params:", *params)
		}
		switch cmd {
		case test.CMD_HELP:
			test.ShowHelp()
		case CMD_PLAYER_PLAY,
			CMD_PLAYER_PAUSE,
			CMD_PLAYER_STOP:
			sendCurPlayerMusicCmd(cmd)
		case CMD_PLAYER_NEXT:
			schedule.SendSCmd(schedule.SCMD_MusicPlayer_PlayNext, nil)
		case CMD_PLAYER_PRE:
			schedule.SendSCmd(schedule.SCMD_MusicPlayer_PlayPre, nil)
		case CMD_PLAYER_SEEKTO:
			if nil == params || 0 == len(*params) {
				return
			}
			seek, err := strconv.Atoi(*params)
			if nil != err {
				continue
			}
			sendCurPlayerMusicCmd(CMD_PLAYER_SEEKTO, uint32(seek*1000))
		case uint32(MUSIC_ST_FOR_NEXT):
			var playerSt schedule.PlayerDetail
			playerSt.Status = MUSIC_ST_FOR_NEXT
			WifiPlayerStatusChange(playerSt)

		case CMD_SHOW_LIST:
			LocalMusicList[CUR_MUSIC_LIST].Println()
			LocalMusicList[RANDOM_MUSIC_LIST].Println()
		case CMD_SHOW_HIS:
			LocalMusicList[HISTORY_MUSIC_LIST].Println()
		case CMD_REPLAY_TTS:
			for i := 0; i < 5; i++ {
				tts := fmt.Sprintf("tts测试%d\n", i)
				NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, tts, CONST_AUDIO_ID, AdSrcType_TTS,
					TTS_LEVEL_1, false, true)
			}
		case CMD_DAILY_PUSH:
			TestInterfaceForKey(DAILY_PUSH_TYPE)
		case CMD_NEW_TOP:
			TestInterfaceForKey(NEW_TOP_TYPE)
		case CMD_HOT_TOP:
			TestInterfaceForKey(HOT_TOP_TYPE)
		case CMD_DENON_TOP:
			TestInterfaceForKey(DENON_TOP_TYPE)
		case CMD_CLASSIC_TOP:
			TestInterfaceForKey(CLASSIC_TOP_TYPE)
		case CMD_ORIGINAL_TOP:
			TestInterfaceForKey(ORIGINAL_TOP_TYPE)
		case CMD_BEAPORT_TOP:
			TestInterfaceForKey(BEATPORT_TOP_TYPE)
		case CMD_SOARING_TOP:
			TestInterfaceForKey(SOARING_TOP_TYPE)
		case CMD_ACG_TOP:
			TestInterfaceForKey(ACG_TOP_TYPE)
		case CMD_CH_NEW:
			TestInterfaceForKey(CH_NEW_TYPE)
		case CMD_JP_NEW:
			TestInterfaceForKey(JP_NEW_TYPE)
		case CMD_CREALTE_LIST:
			TestInterfaceForKey(CREATE_LISTS_TYPE)
		case CMD_SINGLE:
			TestInterfaceForKey(SINGLE_TYPE)
		case CMD_PRIVATE_FM:
			TestInterfaceForKey(PRIVATE_FM_TYPE)
		case CMD_MODE_CHANGE:
			if nil != params && 0 < len(*params) {
				mode, err := strconv.Atoi(*params)
				if nil != err {
					log.Println(log.WarningLog, err.Error())
					break
				}
				switch MusicPlayMode(mode) {
				case LIST_ORDER_CYCLE:
					// 切换到顺序播放时，如果当前是单曲循环，不需要处理
					if LIST_RANDOM_CYCLE == CurPlayingMode {
						ResetUnPlayListCurNode()
					}
					CurPlayingMode = LIST_ORDER_CYCLE
					log.Println(log.DebugLog, "Change playmode:", CurPlayingMode)
				case LIST_RANDOM_CYCLE:
					if LIST_ORDER_CYCLE == CurPlayingMode || SINGLE_CYCLE == CurPlayingMode {
						ResetUnPlayListCurNode()
					}
					CurPlayingMode = LIST_RANDOM_CYCLE
					log.Println(log.DebugLog, "Change playmode:", CurPlayingMode)
				case SINGLE_CYCLE:
					if LIST_RANDOM_CYCLE == CurPlayingMode {
						ResetUnPlayListCurNode()
					}
					CurPlayingMode = SINGLE_CYCLE
					log.Println(log.DebugLog, "Change playmode:", CurPlayingMode)
				}
			}
		case CMD_TTS_LEVEL:
			if nil != params && 0 < len(*params) {
				level, err := strconv.Atoi(*params)
				if nil != err {
					log.Println(log.WarningLog, err.Error())
					break
				}
				tts := fmt.Sprintf("这是一个TTS等级测试:%d,我是为了尽量拖延时间\n", level)
				NoticePlayerSendSCmd(schedule.SCMD_SuperTask_Tts_Play, tts, CONST_AUDIO_ID, AdSrcType_TTS,
					TtsLevel(level), false, true)
			}
		case CMD_ALARM_S:
			// todo
			sendCurPlayerMusicCmd(CMD_SEARCH_PLAYER_REQ)
		case CMD_ALARM_L:
			// todo
		case CMD_OTA_TTS:
			ShowUpdateVersionInfo = true
		case CMD_SE_TEST:
			if nil != params && 0 < len(*params) {
				times, err := strconv.Atoi(*params)
				if nil != err {
					log.Println(log.WarningLog, err.Error())
					break
				}
				for i := 0; i < times; i++ {
					SoundEffectPlayCmd(CMD_SE_PLAY, SoundNotice_Shuanxing001.GetPath())
					time.Sleep(10 * time.Microsecond)
				}
			} else {
				SoundEffectPlayCmd(CMD_SE_PLAY, SoundNotice_Shuanxing001.GetPath())
			}

		case CMD_DLNA_CTRL:
			if nil != params && 0 < len(*params) {
				onoff, err := strconv.Atoi(*params)
				if nil != err {
					log.Println(log.WarningLog, err.Error())
					break
				}
				if 0 == onoff {
					DLNAOff()
				} else {
					DLNAOn()
				}
			}
		case CMD_CTRL_DLNA_ON_APP:
			if nil != params && 0 < len(*params) {
				dlnactrl, err := strconv.Atoi(*params)
				if nil != err {
					log.Println(log.WarningLog, err.Error())
					break
				}
				if 0 == dlnactrl {
					CtrlDlnaCmdToPhone(CTRL_DLNA_STOP)
				} else if 1 == dlnactrl {
					CtrlDlnaCmdToPhone(CTRL_DLNA_PLAY)
				} else {
					CtrlDlnaCmdToPhone(CTRL_DLNA_PAUSE)
				}
			}
		case CMD_AGENCY_TEST:
			// todo
		case CMD_SERVER_CHANGE:
			if nil != params && 0 < len(*params) {
				serverSel, err := strconv.Atoi(*params)
				if nil != err {
					log.Println(log.WarningLog, err.Error())
					break
				}
				if 1 == serverSel {
					http.ServerIp = http.ServerIp_ONLINE
					log.Println(log.DebugLog, "online server select")
				} else if 0 == serverSel {
					http.ServerIp = http.ServerIp_TEST
					log.Println(log.DebugLog, "test server select")
				}
			}
		case CMD_AUDIO_URL:
			if nil != params && 0 < len(*params) {
				adurl, err := strconv.Atoi(*params)
				if nil != err {
					log.Println(log.WarningLog, err.Error())
					break
				}
				if 0 == adurl {
					schedule.PlayNoticeAsync(AdSrcType_FILE, VoiceSrcUrlManager[WIFI_CON_PREPARE].Url, CONST_AUDIO_ID, false, nil, nil)
				} else if 1 == adurl {
					schedule.PlayNoticeAsync(AdSrcType_FILE_MIX, VoiceSrcUrlManager[WIFI_CON_PREPARE].Url, CONST_AUDIO_ID, false, nil, nil)
				}
			}
		case CMD_AIRPLAY_CTRL:
			if nil != params && 0 < len(*params) {
				airplay, err := strconv.Atoi(*params)
				if nil != err {
					log.Println(log.WarningLog, err.Error())
					break
				}
				if 0 == airplay {
					CtrlAirplayOnOff(CMD_SPLAYER_STOP)
				} else if 1 == airplay {
					CtrlAirplayOnOff(CMD_SPLAYER_START)
				}
			}
		case CMD_TTS_SEL:
			if nil != params && 0 < len(*params) {
				tmp, err := strconv.Atoi(*params)
				if nil != err {
					log.Println(log.WarningLog, err.Error())
					break
				}
				if tmp >= 3 {
					tmp = 0
				}
				TtsSel = uint8(tmp)
				switch TtsSel {
				case XUNFEI_TTS:
					log.Println(log.DebugLog, "选择了讯飞tts")
				case XIAOYA_TTS:
					log.Println(log.DebugLog, "选择了小雅tts")
				case ROKID_TTS_TEXT:
					log.Println(log.DebugLog, "选择了若琪tts")
				default:

				}
			}
		case CMD_TTS_LOOK:
			log.Println(log.DebugLog, "ttsSel is:", TtsSel)
		case APP_CMD_SINGLE:
			var tmp AppPlayReq
			tmp.Id = "BA6965923D2C8526BF34AD2C770B386F"
			tmp.Type = SINGLE_SONG
			tmp.Index = 0XFFFF
			appCtrlTest(tmp)
		case APP_CMD_CREATE_LIST:
			var tmp AppPlayReq
			tmp.Type = USER_LISTS_CREATE
			tmp.Index = 0XFFFF
			appCtrlTest(tmp)
		case APP_CMD_NEW:
			var tmp AppPlayReq
			tmp.Type = NEW_TOPLIST
			tmp.Index = 0XFFFF
			appCtrlTest(tmp)
		case APP_CMD_WORD:
			var tmp AppPlayReq
			tmp.Type = MUSIC_LIST_WORD
			tmp.Index = 0XFFFF
			tmp.Oftag = "快乐"
			appCtrlTest(tmp)
		case APP_CMD_LISTID:
			var tmp AppPlayReq
			tmp.Type = ALBUM_ID
			tmp.Index = 0XFFFF
			tmp.ListId = "18893"
			appCtrlTest(tmp)
		case CMD_BIRTHDAY_TEST:
			res, _, _, err := http.GetBirthdayInfo()
			if nil != err {
				log.Println(log.DebugLog, err.Error())
				break
			}
			log.Printf(log.DebugLog, "res:%+v\n", *res)

			var tmp ServerMusicList
			tmp.HasMore = false
			tmp.PlayMode = MODE_NULL
			tmp.MusicList.SongList = res.SongList
			tmp.InnerTts = res.Tts
			tmp.InnerTtsUrl = ""

			schedule.SetPlayerArgs(PlayerType_Other, &tmp, true)
			PlayerHander[PlayerType_Other].RequestPlay_Async(nil)
		case CMD_SET_UUUI:
			if nil != params && 0 < len(*params) {
				log.Println(log.DebugLog, "uuid:", *params)
				storage.Config_set(MODULE_CONTROLLER, SQL_KEY_UUID, *params)
			}
		case CMD_SET_KEY:
			if nil != params && 0 < len(*params) {
				log.Println(log.DebugLog, "key:", *params)
				storage.Config_set(MODULE_CONTROLLER, SQL_KEY_AESKEY, *params)
			}
		case CMD_SET_TOKEN:
			if nil != params && 0 < len(*params) {
				log.Println(log.DebugLog, "token:", *params)
				storage.Config_set(MODULE_CONTROLLER, SQL_KEY_YXTOKEN, *params)
			}
		case CMD_SET_BINDUSER:
			if nil != params && 0 < len(*params) {
				log.Println(log.DebugLog, "binduser:", *params)
				storage.Config_set(MODULE_CONTROLLER, SQL_KEY_BINDUSER, *params)
			}
		case CMD_SET_BIRTHDAY:
			var tmp BirthdaySQL = BirthdaySQL{HasCheck: false}
			storage.Config_set(MODULE_CONTROLLER, SQL_KEY_BIRTHDAY, tmp)
		case CMD_BT_RESET:
			ResetBt()
			log.Println(log.DebugLog, "reset bluetooth")
		case CMD_SCENE_TEST:
			//schedule.SceneRequestPlay("5a26441f0cf2692ba7001d97")
			hdCur.Finish(taskNoCur, true)
		case CMD_SONGID_SHIELD:
			if nil != params && 0 < len(*params) {
				LocalMusicFilter.Push(SONG_ID_FILTER, params)
			}
		case CMD_FILTER_TTS:
			tts := "为您过滤了这首歌,下面播放%s"
			FilterMusic(&tts)
		case CMD_LIKED_SEARCH:
			if LocalMusicList[GetMusicListIndex()].CurPosMusic.Value.(*SongInfo).IsLiked {
				log.Println(log.DebugLog, "is Liked")
			} else {
				log.Println(log.DebugLog, "is not Liked")
			}
		case CMD_PLAY_URL:
			if nil != params && 0 < len(*params) {
				log.Println(log.DebugLog, "url:", *params)
				SoundEffectPlayCmd(CMD_SE_PLAY, *params)
			}
		case CMD_BGPLAYER_TEST:
			if nil != params && 0 < len(*params) {
				tmp, err := strconv.Atoi(*params)
				if nil != err {
					log.Println(log.WarningLog, err.Error())
					break
				}
				if 0 == tmp {
					backGroundPlayerTest = false
					log.Println(log.DebugLog, "close backGround test")
				} else {
					backGroundPlayerTest = true
					log.Println(log.DebugLog, "open backGround test")
				}
			}
		case CMD_TOP3_INFORM_TEST:
			if nil != params && 0 < len(*params) {
				tmp, err := strconv.Atoi(*params)
				if nil != err {
					log.Println(log.WarningLog, err.Error())
					break
				}
				if 0 == tmp {
					informTop3Test = false
					log.Println(log.DebugLog, "close informTop3Test")
				} else {
					informTop3Test = true
					log.Println(log.DebugLog, "open informTop3Test")
				}
			}
		case CMD_TOP3_INSERT_TEST:
			var tmp ServerMusicList
			tmp.MusicList.SongList = make([]SongInfo, 1)
			tmp.MusicList.Id = "12345"
			tmp.MusicList.Type = 2
			tmp.Oftag = "推荐歌手歌曲"
			tts := "歌手信息推荐测试文本"

			tmp.MusicList.SongList[0].Id = "4B37537D40F577ADAB8F7C6BE0983CAC"
			tmp.MusicList.SongList[0].Tts = &tts
			tmp.MusicList.SongList[0].CanPlay = true
			tmp.MusicList.SongList[0].ArtistId = "89"
			tmp.MusicList.SongList[0].ArtistName = "wk"
			tmp.MusicList.SongList[0].AlbumId = "90"
			tmp.MusicList.SongList[0].ArtistName = "wk的专辑"
			tmp.MusicList.SongList[0].SongType = TOP3_RCMD_SONG

			InsertSongstoPlayList(&tmp, false)
		case CMD_VOL_SET:
			if nil != params && 0 < len(*params) {
				tmp, err := strconv.Atoi(*params)
				if nil != err {
					log.Println(log.WarningLog, err.Error())
					break
				}
				adau1761.SetVol(tmp)
			}
		case CMD_ENTER_SCENE:
			if nil != params && 0 < len(*params) {
				log.Println(log.WarningLog, "scene id:", *params)
				schedule.SceneRequestPlay(*params)
			} else {
				schedule.SceneRequestPlay("5a6aca720cf2b3414502fb30")
			}
		case CMD_PULL_CFG_LIST:
			http.UpdateCfgList()
		case CMD_KEY_VOL_TEST:
			if nil != params && 0 < len(*params) {
				tmp, err := strconv.Atoi(*params)
				if nil != err {
					log.Println(log.WarningLog, err.Error())
					break
				}
				if 0 == tmp {
					KeyVolTest = false
				} else {
					KeyVolTest = true
				}
				log.Printf(log.WarningLog, "KeyVolTest:%+v\n", KeyVolTest)
			}
		case CMD_DIRECT_LED_CLEAR_TEST:
			if nil != params && 0 < len(*params) {
				tmp, err := strconv.Atoi(*params)
				if nil != err {
					log.Println(log.WarningLog, err.Error())
					break
				}
				if 1 == tmp {
					led_mcu.DirectLedControl(atservice.GUIDE_EFFECT_ID_EXEC_CMD, atservice.GUIDE_ACTION_START, 0, []byte{})
				} else {
					led_mcu.DirectLedControl(atservice.GUIDE_EFFECT_ID_EXEC_CMD, atservice.GUIDE_ACTION_STOP, 0, []byte{})
				}
				log.Printf(log.WarningLog, "ledC:%+v\n", tmp)
			}
		case CMD_REPLAY_CUR:
			curMusic()
		case CMD_DIS_DEVICE:
			if nil != params && 0 < len(*params) {
				tmp, err := strconv.Atoi(*params)
				if nil != err {
					log.Println(log.WarningLog, err.Error())
					break
				}
				if 0 == tmp {
					BtDiscon()
				} else if 1 == tmp {
					AirplayDisCon()
				} else if 2 == tmp {
					DLNAOff()
				}

				log.Printf(log.WarningLog, "rm:%+v\n", tmp)
			}
		case CMD_INIT_PLAYER:
			InitPlayer()
		case CMD_FORCE_CFGCB:
			//ForceExecCfgListCb()
			DefaultVol.ForceCallCb()
		case CMD_CFG_SAVE_TEST:
			SaveReadListMapTest()
		default:

		}
	}
}

func appCtrlTest(app AppPlayReq) {
	schedule.SetPlayerArgs(PlayerType_Wifi, &app)
	PlayerHander[PlayerType_Wifi].RequestPlay_Async(nil)
}

func TestInterfaceForKey(testType KeyTestType) {
	log.Println(log.DebugLog, "TestInterfaceForKey:", testType)
	var srcType MusicSrcType
	switch testType {
	case DAILY_PUSH_TYPE, NEW_TOP_TYPE, HOT_TOP_TYPE,
		CLASSIC_TOP_TYPE, DENON_TOP_TYPE, ORIGINAL_TOP_TYPE,
		BEATPORT_TOP_TYPE, SOARING_TOP_TYPE, ACG_TOP_TYPE:
		switch testType {
		case HOT_TOP_TYPE:
			srcType = HOT_TOPLIST
		case NEW_TOP_TYPE:
			srcType = NEW_TOPLIST
		case DAILY_PUSH_TYPE:
			srcType = DAILY_PUSH
		case CLASSIC_TOP_TYPE:
			srcType = CLASSIC_TOPLIST
		case DENON_TOP_TYPE:
			srcType = DENON_TOPLIST
		case ORIGINAL_TOP_TYPE:
			srcType = ORIGINAL_TOPLIST
		case BEATPORT_TOP_TYPE:
			srcType = BEATPORT_TOPLIST
		case SOARING_TOP_TYPE:
			srcType = SORIGN_TOPLIST
		case ACG_TOP_TYPE:
			srcType = ACG_TOPLIST
		}

		list, err := GetMusicListNew(PlayerType_Wifi, true, http.MusicListServerType{
			Src:     srcType,
			Id:      getServiceId(srcType),
			Params:  getServiceParams(srcType),
			Start:   0,
			Size:    PAGE_SIZE,
			WantTts: true,

			Oftag:        PlayListSrcRec.TagName,
			OftagForShow: PlayListSrcRec.TagNameShow,
			Mode:         CurPlayingMode,
			CloudId:      PlayListSrcRec.CloudId,
			ModeId:       PlayListSrcRec.ModeId,
		})
		//list, err := getMusicList(PlayerType_Wifi, srcType, getServiceId(srcType), getServiceParams(srcType),
		//	0, 50, true, CurPlayingMode)
		if nil != err {
			log.Println(log.DebugLog, err.Error())
			return
		}
		list.InnerTts = "即将播放音乐"
		//list.MusicList.UpdateTime = uint64(time.Now().Unix())
		playNewHotDailyMusic(list, false)
	case CH_NEW_TYPE, JP_NEW_TYPE:
		switch testType {
		case CH_NEW_TYPE:
			srcType = CH_NEW_TOPLIST
		case JP_NEW_TYPE:
			srcType = JP_NEW_LIST
		}
		list, err := GetMusicListNew(PlayerType_Wifi, true, http.MusicListServerType{
			Src:     srcType,
			Id:      getServiceId(srcType),
			Params:  getServiceParams(srcType),
			Start:   0,
			Size:    PAGE_SIZE,
			WantTts: true,

			Oftag:        PlayListSrcRec.TagName,
			OftagForShow: PlayListSrcRec.TagNameShow,
			Mode:         CurPlayingMode,
			CloudId:      PlayListSrcRec.CloudId,
			ModeId:       PlayListSrcRec.ModeId,
		})
		//list, err := getMusicList(PlayerType_Wifi, srcType, getServiceId(srcType), getServiceParams(srcType),
		//	0, 50, true, CurPlayingMode)
		if nil != err {
			log.Println(log.DebugLog, err.Error())
			return
		}
		list.InnerTts = "即将播放音乐"
		//list.MusicList.UpdateTime = uint64(time.Now().Unix())
		playNormalListMusic(true, list)
	case CREATE_LISTS_TYPE:
		srcType = USER_LISTS_CREATE
		list, err := GetMusicListsNew(PlayerType_Wifi, false, http.MusicListServerType{
			Src:     srcType,
			Id:      getServiceId(srcType),
			Params:  getServiceParams(srcType),
			Start:   0,
			Size:    LIST_SIZE,
			WantTts: true,

			Oftag:        PlayListSrcRec.TagName,
			OftagForShow: PlayListSrcRec.TagNameShow,
			Mode:         CurPlayingMode,
			CloudId:      PlayListSrcRec.CloudId,
			ModeId:       PlayListSrcRec.ModeId,
		})
		//list, err := getMusicLists(PlayerType_Wifi, srcType, getServiceId(srcType),
		//	getServiceParams(srcType), 0, LIST_SIZE, false, CurPlayingMode)
		if nil != err {
			log.Println(log.DebugLog, err.Error())
			return
		}
		playNormalListMusic(true, list)
	case SINGLE_TYPE:

	case PRIVATE_FM_TYPE:
		list, err := GetMusicListNew(PlayerType_Wifi, true, http.MusicListServerType{
			Src:     PRIVATE_FM,
			Id:      getServiceId(PRIVATE_FM),
			Params:  getServiceParams(PRIVATE_FM),
			Start:   0,
			Size:    FM_SIZE,
			WantTts: true,

			Oftag:        PlayListSrcRec.TagName,
			OftagForShow: PlayListSrcRec.TagNameShow,
			Mode:         CurPlayingMode,
			CloudId:      PlayListSrcRec.CloudId,
			ModeId:       PlayListSrcRec.ModeId,
		})
		//list, err := getMusicList(PlayerType_Wifi, PRIVATE_FM, getServiceId(PRIVATE_FM), getServiceParams(PRIVATE_FM),
		//	0, 3, true, CurPlayingMode)
		if nil != err {
			log.Println(log.DebugLog, err.Error())
			return
		}
		list.InnerTts = "即将播放音乐"
		playPrivateFM(list)
	}

}

/**
 ****************************************************** 单元测试api *************************************************
 */

func unitTestchangePlayStatus(st PlayerStatuses, id *string) {
	var playerSt schedule.PlayerDetail
	playerSt.Status = st
	if nil != id && len(*id) > 0 {
		playerSt.Uuid = *id
		log.Println(log.DebugLog, "***********************PlayUuid:", *id)
	}
	WifiPlayerStatusChange(playerSt)
}

func unitTestGetPlayInfo() (*ServerSongPlay, error) {
	var tmp ServerSongPlay
	tmp.SongPlay.Url = "unitTest songPlay url"
	return &tmp, nil
}

func unitTestGetSongDetail(id *string) (*ServerSongDetail, error) {
	var tmp ServerSongDetail
	tmp.Song.Url = "uintTest songDetail url"
	tmp.Song.Id = *id
	tmp.Song.CanPlay = true
	return &tmp, nil
}

func unitTestGetList(src MusicSrcType) (*ServerMusicList, error) {
	log.Println(log.DebugLog, "*********************get lists from http:", src)

	var tmp ServerMusicList
	tmp.HasMore = true
	tmp.MusicList.Id = "unitTest list id"
	tmp.MusicList.Url = "uintTest list url"
	tmp.MusicList.Index = 0
	tmp.MusicList.Type = src
	tmp.MusicList.UpdateTime = 0

	tmp.MusicList.SongList = make([]SongInfo, 2)
	for k, _ := range tmp.MusicList.SongList {
		tmp.MusicList.SongList[k].Id = "unitTest list id"
		tmp.MusicList.SongList[k].CanPlay = true
	}

	return &tmp, nil
}

func unitTestGetLists(src MusicSrcType) (*ServerMusicLists, error) {
	log.Println(log.DebugLog, "*********************get lists from http:", src)

	var tmp ServerMusicLists
	tmp.HasMore = true
	tmp.MusicLists = make([]MusicListInfo, 2)

	tmp.MusicLists[0].Id = "unitTest lists id 0"
	tmp.MusicLists[0].Url = "unitTest lists url"
	tmp.MusicLists[0].Index = 0
	tmp.MusicLists[0].Type = src
	tmp.MusicLists[0].UpdateTime = 1
	tmp.MusicLists[0].SongList = make([]SongInfo, 2)
	for k, _ := range tmp.MusicLists[0].SongList {
		tmp.MusicLists[0].SongList[k].Id = "unitTest list id"
		tmp.MusicLists[0].SongList[k].CanPlay = true
	}

	tmp.MusicLists[1].Id = "unitTest lists id 1"
	tmp.MusicLists[1].Type = src
	tmp.MusicLists[1].UpdateTime = 1

	return &tmp, nil
}
