| | |
| | | Refresh(); |
| | | } |
| | | |
| | | static List<System.Threading.Thread> updataMusicStatesListThread = new List<System.Threading.Thread>(); |
| | | /// <summary> |
| | | /// 读取音乐状态 |
| | | /// </summary> |
| | | public static void ReadMusicStates() |
| | | { |
| | | RemoveListThread(); |
| | | if (GetCollection) |
| | | { |
| | | for (int i = 0; i < A31MusicModelList.Count; i++) |
| | | { |
| | | var a31player = A31MusicModelList[i]; |
| | | var musicThread = new System.Threading.Thread(() => |
| | | { |
| | | while (true) |
| | | { |
| | | System.Threading.Thread.Sleep(1000); |
| | | if (!a31player.IsOnLine) |
| | | { |
| | | continue; |
| | | } |
| | | SendMethod.ReadStatus(a31player); |
| | | } |
| | | }) |
| | | { IsBackground = true, Name = "A31" }; |
| | | musicThread.Start(); |
| | | updataMusicStatesListThread.Add(musicThread); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 音乐功能 |
| | | /// </summary> |
| | | public Function functionMusic = new Function(); |
| | | /// <summary> |
| | | /// 移除之前的线程 |
| | | /// </summary> |
| | | public static void RemoveListThread() |
| | | { |
| | | for (int i = 0; i < updataMusicStatesListThread.Count;) |
| | | { |
| | | try |
| | | { |
| | | var thread = updataMusicStatesListThread[i]; |
| | | if (thread.IsAlive) |
| | | { |
| | | thread.Abort(); |
| | | } |
| | | updataMusicStatesListThread.Remove(thread); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | MainPage.Log("clearA31Threads error : " + e.Message); |
| | | } |
| | | finally |
| | | { |
| | | MainPage.Log("clearA31Threads over"); |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 音乐列表里是否有音乐被收藏过 |
| | | /// </summary> |
| | | static bool GetCollection |
| | | { |
| | | get |
| | | { |
| | | for (int i = 0; i < A31MusicModelList.Count; i++) |
| | | { |
| | | if (A31MusicModelList[i].functionMusic.collect) |
| | | { |
| | | return true; //查询是否有音乐被收藏过 |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | ///保存当前音乐列表 |
| | | /// </summary> |
| | |
| | | A31MusicModelList.RemoveAll((obj) => obj == null); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 音乐播放器名称 |
| | | /// </summary> |
| | | public string Name = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 上一次更新的时间 |
| | | /// 记录数据反馈的时间(因为有时间网络差数据不回复,导致刷新当前播放音乐时间不正确) |
| | | /// ((当前时间)DateTime.Now - (记录时间)LastDateTimeLastDateTime).TotalSeconds=误差时间(秒) |
| | | /// </summary> |
| | | public DateTime LastDateTime; |
| | | /// <summary> |
| | | /// IP地址 |
| | | /// </summary> |
| | | public string IPAddress = "192.168.1.100"; |
| | | |
| | | /// <summary> |
| | | /// 端口 |
| | | /// </summary> |
| | | public int Port = 49153; |
| | | |
| | | /// <summary> |
| | | /// 是否是播放器列表最后一个(true) |
| | | /// </summary> |
| | | public bool IsEnd = false; |
| | | |
| | | public int A31DeviceType; |
| | | |
| | | //public string a31Source = "wifi"; |
| | | //public string a31Source = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 音乐播放器ID |
| | | /// </summary> |
| | | public string UniqueDeviceName = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 当前播放状态 |
| | | /// </summary> |
| | | public A31PlayStatus A31PlayStatus = new A31PlayStatus(); |
| | | |
| | | |
| | | public MusicInfo CurrentMusic = new MusicInfo(); |
| | | |
| | |
| | | public List<Songs> dlnaMusicInfoLists = new List<Songs>(); |
| | | |
| | | /// <summary> |
| | | /// 电台所有列表 |
| | | /// </summary> |
| | | public List<Songs> CnRadioInfoList = new List<Songs>(); |
| | | |
| | | /// <summary> |
| | | /// vTuner电台所有列表 |
| | | /// </summary> |
| | | public List<Songs> vTunerList = new List<Songs>(); |
| | | |
| | | /// <summary> |
| | | /// 喜爱电台列表 |
| | | /// </summary> |
| | | public List<Songs> LoveRadioInfoList = new List<Songs>(); |
| | | |
| | | /// <summary> |
| | | /// Pandora电台所有列表 |
| | | /// </summary> |
| | | public List<Songs> PanRadioInfoList = new List<Songs>(); |
| | | /// <summary> |
| | | /// usb列表 |
| | | /// </summary> |
| | | public List<Songs> USBList = new List<Songs>(); |
| | | /// <summary> |
| | | /// Tidal喜爱列表 |
| | | /// </summary> |
| | | public List<Songs> TidalLikelist = new List<Songs>(); |
| | | /// <summary> |
| | | ///创建音乐文件列表 |
| | | /// </summary> |
| | | public List<FileListInfo> FileLists = new List<FileListInfo>(); |
| | |
| | | /// </summary> |
| | | public static A31MusicModel Current; |
| | | |
| | | public int _ServerClientType; |
| | | /// <summary> |
| | | /// -1表示从的0表示默认1表示主的 |
| | | /// </summary> |
| | | public int ServerClientType |
| | | { |
| | | get |
| | | { |
| | | return _ServerClientType; |
| | | } |
| | | set |
| | | { |
| | | _ServerClientType = value; |
| | | if (value == 0) |
| | | { |
| | | //name = Name; |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 记录主播放器IP |
| | | /// </summary> |
| | | public string MainPlayIP = string.Empty; |
| | | |
| | | |
| | | |
| | | public string _MainPlayName = string.Empty; |
| | | /// <summary> |
| | | /// 记录主播放器名称 |
| | | /// </summary> |
| | | public string MainPlayName |
| | | { |
| | | get |
| | | { |
| | | return _MainPlayName; |
| | | } |
| | | set |
| | | { |
| | | _MainPlayName = value; |
| | | //if(ServerClientType == 1) |
| | | //{ |
| | | // name = value; |
| | | //} |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 指定列表名获取音乐列表 |
| | | /// </summary> |
| | |
| | | /// </summary> |
| | | public static DateTime ProgressDateTime = DateTime.Now; |
| | | |
| | | /// <summary> |
| | | /// 判断是否是json数据 |
| | | /// </summary> |
| | | /// <param name="json"></param> |
| | | /// <returns></returns> |
| | | public static bool IsJson(string json) |
| | | { |
| | | try |