wjc
2023-03-28 a9d1161b1df96e7ddad566335989a1444e433ef5
HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs
@@ -3,6 +3,8 @@
using com.hdl.on;
using System.Collections.Generic;
using System.Security;
using HDL_ON.UI.UI2.FuntionControlView.Music;
using HDL_ON.Entity;
namespace HDL_ON.UI.Music
{
@@ -36,17 +38,17 @@
        /// new布局界面
        /// </summary>
        View.PlayView playView = new View.PlayView();
        TopView topView;
        public void Show()
        {
            ///1秒定时更新状态
            timerUpdateStatus();
            TimerUpdateStatus();
            #region   ---界面布局---
            this.BackgroundColor = MusicColor.ViewColor;
            var topView = new TopView();
            topView = new TopView();
            topView.setBtn.Visible = true;
            this.AddChidren(topView.TopFLayoutView());
            topView.topNameBtn.Text = A31MusicModel.Current.Name;
            topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
            {
                RemoveFromParent();
@@ -67,112 +69,108 @@
            ///加载播放音乐界面的控件方法
            playView.viewFrameLayout(middLayout);
            #endregion
            #region   ---控件的点击事件---
            #region   ---界面点击事件---
            playView.collectIconBtn.Visible = false;//先暂时隐藏收藏功能
            //收藏图标事件
            playView.collectIconBtn.MouseUpEventHandler += (sender, e) =>
            {
                playView.collectIconBtn.IsSelected = !playView.collectIconBtn.IsSelected;
                if (playView.collectIconBtn.IsSelected)
                {
                    A31MusicModel.Current.collect = true;
                    A31MusicModel.Current.functionMusic.collect = true;
                }
                else
                {
                    A31MusicModel.Current.collect = false;
                    A31MusicModel.Current.functionMusic.collect = false;
                }
            };
            //快进滑动弹起事件;
            playView.diyArcSeekBar.OnStopTrackingTouchEvent+= (sender, e) =>
            {
                int totalSecond = (int)(playView.diyArcSeekBar.Progress * 1.0f / 100 * int.Parse(A31MusicModel.Current.A31PlayStatus.totlen) / 1000);
                //分钟
                int Minute = totalSecond / 60;
                //秒钟
                int Second = totalSecond % 60;
                string time = "00" + ":" + (Minute.ToString().Length < 2 ? "0" + Minute.ToString() : Minute.ToString()) + ":" + (Second.ToString().Length < 2 ? "0" + Second.ToString() : Second.ToString());
                SendMethod.Seek(time, A31MusicModel.Current);
                A31MusicModel.Current.A31PlayStatus.curpos = (DateTime.Parse(time) - DateTime.Parse("00:00:00")).TotalMilliseconds.ToString();
            };
            ///切换播放模式点击事件;
            playView.playOrderBtn.MouseUpEventHandler += (sender, e) =>
             {
                 string msg = Language.StringByID(StringId.switchTo);
                 switch (A31MusicModel.Current.A31PlayStatus.loop)
                 //获取当前播放模式
                 string currModeKeyValue = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode);
                 //获取音乐播放模式列表
                 var attributes = A31MusicModel.Current.functionMusic.GetAttribute(KeyProperty.mode);
                 if (attributes == null)
                 {
                     //0列表循环,1单曲循环,2随机播放;
                     case "0":
                         A31MusicModel.Current.A31PlayStatus.loop = "1";
                         playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png";
                         msg += Language.StringByID(StringId.singleMode);
                         break;
                     case "1":
                         A31MusicModel.Current.A31PlayStatus.loop = "2";
                         playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png";
                         msg += Language.StringByID(StringId.randomMode);
                         break;
                     case "2":
                         A31MusicModel.Current.A31PlayStatus.loop = "0";
                     attributes = new FunctionAttributes();
                 }
                 var attributesList = attributes.value;
                 //找到当前播放模式索引值
                 int currModeIndexe = attributesList.IndexOf(currModeKeyValue);
                 //记录选中的播放模式的索引值
                 int count = 0;
                 if (currModeIndexe >= attributesList.Count - 1)
                 {
                     //重置索引值
                     count = 0;
                 }
                 else
                 {
                     count = currModeIndexe + 1;
                 }
                 //通过索引值找到模式value值
                 string modeValueString = attributesList[count];
                 switch (modeValueString)
                 {
                     //list_cycle列表循环,single_cycle单曲循环,random随机播放;
                     case ValueProperty.list_cycle:
                         playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png";
                         msg += Language.StringByID(StringId.listMode);
                         break;
                     case ValueProperty.single_cycle:
                         playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single_cycle.png";
                         msg += Language.StringByID(StringId.singleCycleMode);
                         break;
                     case ValueProperty.random:
                         playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png";
                         msg += Language.StringByID(StringId.randomMode);
                         break;
                     case ValueProperty.single:
                         playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png";
                         msg += Language.StringByID(StringId.single);
                         break;
                     case ValueProperty.order:
                         playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/order.png";
                         msg += Language.StringByID(StringId.orderMode);
                         break;
                 }
                 new PublicAssmebly().TipMsgAutoClose(msg, false,1000);
                 string url = "http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setPlayerCmd:" + "loopmode:" + A31MusicModel.Current.A31PlayStatus.loop;
                 SendMethod.SendCommand(url);
                 //写入缓存
                 A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.mode, modeValueString);
                 new PublicAssmebly().TipMsgAutoClose(msg, false, 1000);
                 Dictionary<string, string> dic = new Dictionary<string, string>();
                 dic.Add(KeyProperty.mode, modeValueString);
                 //发送控制指令
                 SendMethod.Current.SendControlCommand(A31MusicModel.Current.functionMusic, dic);
             };
            ///添加喜爱点击事件;
            playView.loveBtn.MouseUpEventHandler += (sender, e) =>
            {
                var url = A31MusicModel.Current.A31PlayStatus.TrackURL;
                var album = A31MusicModel.Current.A31PlayStatus.Album;
                var artist = A31MusicModel.Current.A31PlayStatus.Artist;
                var song = A31MusicModel.Current.A31PlayStatus.Title;
                if (A31MusicModel.Current.A31PlayStatus.Source == "RADIO-NETWORK")
                var name = A31MusicModel.Current.functionMusic.GetAttribute("song_name").ToString();
                var songTime = A31MusicModel.Current.functionMusic.GetAttribute("song_time").ToString();
                playView.loveBtn.IsSelected = !playView.loveBtn.IsSelected;
                if (playView.loveBtn.IsSelected)
                {
                    playView.loveBtn.IsSelected = !playView.loveBtn.IsSelected;
                    if (playView.loveBtn.IsSelected)
                    if (null == A31MusicModel.Current.LoveMusicInfoList.Find((musicInfo) =>
                    {
                        if (null == A31MusicModel.Current.LoveRadioInfoList.Find((musicInfo) =>
                        {
                            return url == musicInfo.URL;
                        }))
                        {
                            A31MusicModel.Current.LoveRadioInfoList.Add(new MusicInfo { Title = song, URL = url, });
                        }
                    }
                    else
                        return name == musicInfo.name;
                    }))
                    {
                        A31MusicModel.Current.LoveRadioInfoList.RemoveAll((musicInfo) =>
                        {
                            return url == musicInfo.URL;
                        });
                        A31MusicModel.Current.LoveMusicInfoList.Add(new SongInfo { name = name, time = songTime });
                    }
                }
                else
                {
                    playView.loveBtn.IsSelected = !playView.loveBtn.IsSelected;
                    if (playView.loveBtn.IsSelected)
                    A31MusicModel.Current.LoveMusicInfoList.RemoveAll((musicInfo) =>
                    {
                        if (null == A31MusicModel.Current.LoveMusicInfoList.Find((musicInfo) =>
                        {
                            return url == musicInfo.URL;
                        }))
                        {
                            A31MusicModel.Current.LoveMusicInfoList.Add(new MusicInfo { Title = song, URL = url, Artist = artist, Album = album });
                        }
                    }
                    else
                    {
                        A31MusicModel.Current.LoveMusicInfoList.RemoveAll((musicInfo) =>
                        {
                            //也要加歌手名判断
                            return musicInfo.URL == url;
                        });
                    }
                        //也要加歌手名判断
                        return musicInfo.name == name;
                    });
                }
                A31MusicModel.Save();
            };
@@ -187,8 +185,48 @@
                ///下拉刷新
                myListView.verticalScrolViewLayout.BeginHeaderRefreshingAction += () =>
                {
                    System.Threading.Tasks.Task.Run((() =>
                    {
                        try
                        {
                            A31MusicModel.Current.CurrentPlayMusicInfoList.Clear();
                            if (A31MusicModel.Current.CurrentPlayMusicInfoList.Count == 0)
                            {
                                SendMethod.Current.GetCurrentPalyList(A31MusicModel.Current.functionMusic, () =>
                                {
                                    Application.RunOnMainThread(() =>
                                    {
                                        //myListView.verticalScrolViewLayout.EndHeaderRefreshing();
                                        myListView.verticalScrolViewLayout.RemoveAll();
                                        var listName = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playlist_name);
                                        var source = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.source);
                                        var musicList = A31MusicModel.Current.GetSongList(listName);
                                        A31SongPlay.SongListView(myListView.verticalScrolViewLayout, musicList, listName, source, myListView.popFra);
                                    });
                                });
                            }
                        }
                        catch
                        {
                        }
                        finally
                        {
                            Application.RunOnMainThread(() =>
                            {
                                myListView.verticalScrolViewLayout.EndHeaderRefreshing();
                                //myListView.verticalScrolViewLayout.RemoveAll();
                                //var listName = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playlist_name);
                                //var source = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.source);
                                //var musicList = A31MusicModel.Current.GetSongList(listName);
                                //A31SongPlay.SongListView(myListView.verticalScrolViewLayout, musicList, listName, source, myListView.popFra);
                            });
                        }
                    }));
                    //结束刷新
                    myListView.verticalScrolViewLayout.EndHeaderRefreshing();
                };
                ///移除界面
                EventHandler<MouseEventArgs> removeFromParentView = (sen, e1) =>
@@ -198,37 +236,35 @@
                myListView.backIextBtn.MouseUpEventHandler += removeFromParentView;
                myListView.popFra.MouseUpEventHandler += removeFromParentView;
                #endregion
                loading.Start();
                GetMusicList((listName) =>
                {
                    loading.Hide();
                    PlayListView(myListView.popFra, myListView.verticalScrolViewLayout, listName);
                    UpdateSelectedMusic(myListView.popFra, myListView.verticalScrolViewLayout);
                });
                //var listName = A31MusicModel.Current.functionMusic.GetAttribute("playlist_name").ToString();
                //var musicList = A31MusicModel.Current.GetSongList(listName);
                //new A31SongPlay { }.SongListView(myListView.verticalScrolViewLayout, musicList, listName);
                this.PlayListView(myListView.popFra, myListView.verticalScrolViewLayout, loading);
                this.UpdateSelectedMusic(myListView.popFra, myListView.verticalScrolViewLayout);
            };
            ///音量图标点击事件
            playView.volIconBtn.MouseUpEventHandler += (sender, e) =>
            {
                if (A31MusicModel.Current.ServerClientType == 1 && A31MusicModel.Current.Slave.slave_list.Count != 0)
                { ///主播放器
                    var volumeView = new View.DialogView { };
                    volumeView.PlayerVolumeView(A31MusicModel.Current);
                    volumeView.UpdateVolume();
                }
            };
            ///音量进度条点击事件
            int startVolume =0;//之前的音量
            int startVolume = 0;//之前的音量
            //int endVolume = 0;//现在的音量
            EventHandler<int> progressClick = (sender, e) =>
            {
                playView.volValueBtn.Text = playView.volSeekBar.Progress + "%";
                if (startVolume != e)
                {
                    ///更新最新值
                    A31MusicModel.ProgressDateTime = DateTime.Now;
                    startVolume = e;
                    SendMethod.ControlVolume(e, A31MusicModel.Current);
                    A31MusicModel.Current.A31PlayStatus.vol = e.ToString();
                    A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.volume, startVolume);
                    Dictionary<string, string> dic = new Dictionary<string, string>();
                    dic.Add(KeyProperty.volume, startVolume.ToString());
                    SendMethod.Current.SendControlCommand(A31MusicModel.Current.functionMusic, dic);
                }
            };
            playView.volSeekBar.OnProgressChangedEvent += progressClick;
@@ -237,55 +273,67 @@
            playView.prevBtn.MouseDownEventHandler += (sender, e) =>
            {
                playView.prevBtn.IsSelected = true;
                SendMethod.Previous(A31MusicModel.Current);
                A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.song_step, ValueProperty.down);
                Dictionary<string, string> dic = new Dictionary<string, string>();
                dic.Add(KeyProperty.song_step, ValueProperty.up);
                SendMethod.Current.SendControlCommand(A31MusicModel.Current.functionMusic, dic);
            };
            playView.prevBtn.MouseUpEventHandler += (sender, e) =>
            {
                playView.prevBtn.IsSelected = false;
            };
            };
            ///暂停/播放点击事件
            playView.playBtn.MouseDownEventHandler += (sender, e) =>
            {
                string status = string.Empty;
                if (playView.playBtn.IsSelected)
                {
                    playView.playBtn.IsSelected = false;
                    SendMethod.Pause(A31MusicModel.Current);
                    A31MusicModel.Current.A31PlayStatus.status = "pause";
                    status = ValueProperty.off;
                }
                else
                {
                    playView.playBtn.IsSelected = true;
                    SendMethod.Play(A31MusicModel.Current);
                    A31MusicModel.Current.A31PlayStatus.status = "play";
                    status = ValueProperty.on;
                }
                A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.on_off, status);
                Dictionary<string, string> dic = new Dictionary<string, string>();
                dic.Add(KeyProperty.on_off, status);
                SendMethod.Current.SendControlCommand(A31MusicModel.Current.functionMusic, dic);
            };
            ///下一曲点击事件
            playView.nextBtn.MouseDownEventHandler += (sender, e) =>
            {
                playView.nextBtn.IsSelected = true;
                SendMethod.Next(A31MusicModel.Current);
                A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.song_step, ValueProperty.down);
                Dictionary<string, string> dic = new Dictionary<string, string>();
                dic.Add(KeyProperty.song_step, ValueProperty.down);
                SendMethod.Current.SendControlCommand(A31MusicModel.Current.functionMusic, dic);
            };
            playView.nextBtn.MouseUpEventHandler += (sender, e) =>
            {
                playView.nextBtn.IsSelected = false;
            };
            ///物理按键的点击事件
            Volume.VolumeChange = (volume) =>
            {
                if (Application.DeviceType == Device.Ios && A31MusicModel.Current.A31PlayStatus.Source == "BLUETOOTH")
                {
                    return;
                }
                playView.volSeekBar.Progress = volume;
                if (startVolume != volume)
                {
                    startVolume = volume;
                    SendMethod.ControlVolume(volume, A31MusicModel.Current);
                    A31MusicModel.Current.A31PlayStatus.vol = volume.ToString();
                }
            };
            /////物理按键的点击事件
            //Volume.VolumeChange = (volume) =>
            //{
            //    if (Application.DeviceType == Device.Ios && A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.source) == "bluetooth")
            //    {
            //        return;
            //    }
            //    playView.volSeekBar.Progress = volume;
            //    if (startVolume != volume)
            //    {
            //        startVolume = volume;
            //        A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.volume, startVolume);
            //        Dictionary<string, string> dic = new Dictionary<string, string>();
            //        dic.Add(KeyProperty.volume, startVolume.ToString());
            //        SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic);
            //    }
            //};
            #endregion
        }
        /// <summary>
@@ -295,7 +343,7 @@
        /// <summary>
        /// 定时更新状态
        /// </summary>       
        void timerUpdateStatus()
        void TimerUpdateStatus()
        {
            timerThread = new System.Threading.Thread((obj) =>
            {
@@ -305,71 +353,81 @@
                    {
                        try
                        {
                            //更新总时间                            
                            //总共有多少秒
                            int totalSecond = int.Parse(A31MusicModel.Current.A31PlayStatus.totlen) / 1000;
                            int totalSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_time));
                            //分钟
                            int totalMusicMinute = totalSecond / 60;
                            //秒钟
                            int totalMusicSecond = totalSecond % 60;
                            //转化歌曲总时间时间格式
                            string totalTime = (totalMusicMinute.ToString().Length < 2 ? "0" + totalMusicMinute.ToString() : totalMusicMinute.ToString()) + ":" + (totalMusicSecond.ToString().Length < 2 ? "0" + totalMusicSecond.ToString() : totalMusicSecond.ToString());
                            //显示总时间
                            playView.endTimeBtn.Text = totalTime;
                            //topView.topNameBtn.Text = A31MusicModel.Current.Name;
                            switch (A31MusicModel.Current.A31PlayStatus.loop)
                            //显示播放器名称
                            topView.topNameBtn.Text = A31MusicModel.Current.functionMusic.name;
                            //显示播放模式图标
                            switch (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode))
                            {
                                case "0"://列表循环
                                case ValueProperty.list_cycle://列表循环
                                    playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png";
                                    break;
                                case "1"://单曲顺环
                                    playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png";
                                case ValueProperty.single_cycle://单曲循环
                                    playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single_cycle.png";
                                    break;
                                case "2"://随机播放
                                case ValueProperty.random://随机播放
                                    playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png";
                                    break;
                                case ValueProperty.single:// 单曲<single>
                                    playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png";
                                    break;
                                case ValueProperty.order://循序循环
                                    playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/order.png";
                                    break;
                            }
                            if (A31MusicModel.Current.A31PlayStatus.Source == "RADIO-NETWORK")
                            //if (A31MusicModel.Current.A31PlayStatus.Source == "RADIO-NETWORK")
                            //{
                            //    var v = A31MusicModel.Current.LoveRadioInfoList.Find((like) =>
                            //    {
                            //        return like.URL == A31MusicModel.Current.A31PlayStatus.TrackURL;
                            //    });
                            //    if (v != null)
                            //    {
                            //        playView.loveBtn.IsSelected = true;
                            //    }
                            //    else
                            //    {
                            //        playView.loveBtn.IsSelected = false;
                            //    }
                            //}
                            //else
                            //{
                            //    var v = A31MusicModel.Current.LoveMusicInfoList.Find((like) =>
                            //    {
                            //        return like.URL == A31MusicModel.Current.A31PlayStatus.TrackURL;
                            //    });
                            //    if (v != null)
                            //    {
                            //        playView.loveBtn.IsSelected = true;
                            //    }
                            //    else
                            //    {
                            //        playView.loveBtn.IsSelected = false;
                            //    }
                            //}
                            //显示播放器区域
                            playView.regionBtn.Text = A31MusicModel.Current.functionMusic.GetRoomListName();
                            //显示播放器收藏状态
                            if (A31MusicModel.Current.functionMusic.collect)
                            {
                                var v = A31MusicModel.Current.LoveRadioInfoList.Find((like) =>
                                {
                                    return like.URL == A31MusicModel.Current.A31PlayStatus.TrackURL;
                                });
                                if (v != null)
                                {
                                    playView.loveBtn.IsSelected = true;
                                }
                                else
                                {
                                    playView.loveBtn.IsSelected = false;
                                }
                            }
                            else
                            {
                                var v = A31MusicModel.Current.LoveMusicInfoList.Find((like) =>
                                {
                                    return like.URL == A31MusicModel.Current.A31PlayStatus.TrackURL;
                                });
                                if (v != null)
                                {
                                    playView.loveBtn.IsSelected = true;
                                }
                                else
                                {
                                    playView.loveBtn.IsSelected = false;
                                }
                            }
                            playView.regionBtn.Text = A31MusicModel.Current.GetRoomListName();
                            if (A31MusicModel.Current.collect)
                            {
                                //收藏
                                playView.collectIconBtn.IsSelected = true;
                            }
                            else
                            {
                                //不收藏
                                playView.collectIconBtn.IsSelected = false;
                            }
                            //if (A31MusicModel.Current.A31PlayStatus.IsMute)
@@ -388,52 +446,75 @@
                            //        playView.volValueBtn.Text = A31MusicModel.Current.A31PlayStatus.vol + "%";
                            //    }
                            //}
                            if (1000 < (DateTime.Now - A31MusicModel.ProgressDateTime).TotalMilliseconds)
                            //为了防止音量条跳动,延长更新时间(多加1s)
                            if (2000 < (DateTime.Now - A31MusicModel.ProgressDateTime).TotalMilliseconds || A31MusicModel.ProgressDateTime == DateTime.MinValue)
                            {
                                //音量进度条;
                                playView.volSeekBar.Progress = int.Parse(A31MusicModel.Current.A31PlayStatus.vol);
                                //显示音量进度条值;
                                playView.volSeekBar.Progress = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.volume));
                                //显示当前音量值;
                                playView.volValueBtn.Text = A31MusicModel.Current.A31PlayStatus.vol + "%";
                                playView.volValueBtn.Text = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.volume) + "%";
                            }
                            //更新播放器音量给系统音量
                            Volume.MusicVolume = playView.volSeekBar.Progress;
                            //当前播放音乐时间
                            int playSecond = int.Parse(A31MusicModel.Current.A31PlayStatus.curpos) / 1000 + (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds;
                            //Volume.MusicVolume = playView.volSeekBar.Progress;
                            //当前播放音乐时间
                            //按道理不会为空,GetAttrState("playing_time")值可能为空,强制转换int.Parse()会出现异常,不过也做了异常处理了
                            int playSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playing_time));
                            //识别音乐状态是否在播放状态
                            if (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on)
                            {
                                //音乐在播放时,再计算播放时间(现在时间=原来时间+1秒)
                                playSecond += (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds;
                                playSecond += 1;//表示加上等待的时间1s
                                ///歌曲记录暂时时间写入缓存;
                                A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.playing_time, playSecond);
                            }
                            if (playSecond <= 0)
                            {
                                ///播放时间不能小于0;
                                playSecond = 0;
                            }
                            if (playSecond >= totalSecond)
                            {
                                ///播放时间不能超过总时间;
                                playSecond = totalSecond;
                            }
                            int playMusicMinute = playSecond / 60;
                            //秒钟
                            int playMusicSecond = playSecond % 60;
                            //转化播放时间时间格式
                            string playTime = (playMusicMinute.ToString().Length < 2 ? "0" + playMusicMinute.ToString() : playMusicMinute.ToString()) + ":" + (playMusicSecond.ToString().Length < 2 ? "0" + playMusicSecond.ToString() : playMusicSecond.ToString());
                            if (A31MusicModel.Current.A31PlayStatus.status == "play")
                            //显示播放时间
                            playView.startTimeBtn.Text = playTime;
                            //显示播放状态
                            if (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on)
                            {
                                //播放
                                playView.playBtn.IsSelected = true;
                                //如果在播放,时间就不断变化
                                playView.startTimeBtn.Text = playTime;
                                if (totalSecond == 0)
                                {
                                    //歌曲进度条
                                    playView.diyArcSeekBar.Progress = 0;
                                }
                                else
                                {
                                    //歌曲进度条
                                    playView.diyArcSeekBar.Progress = (int)(playSecond * 100.0 / totalSecond);//+1
                                }
                            }
                            else
                            {
                                //暂停
                                playView.playBtn.IsSelected = false;
                                //停止播放
                                playView.startTimeBtn.Text =playTime;
                                ///记录歌曲暂停时间;<LastDateTime 计算播放时间有用到>
                                A31MusicModel.Current.LastDateTime = DateTime.Now;
                            }
                            playView.songNameTextView.Text = (A31MusicModel.Current.A31PlayStatus.Title == null ? "Unkown" : A31MusicModel.Current.A31PlayStatus.Title);
                            playView.singerBtn.Text = (A31MusicModel.Current.A31PlayStatus.Artist == null ? "Unkown" : A31MusicModel.Current.A31PlayStatus.Artist.Trim());
                            //显示进度条值
                            if (totalSecond == 0)
                            {
                                //歌曲播放进度
                                playView.diyArcSeekBar.Progress = 0;
                            }
                            else
                            {
                                //歌曲播放进度
                                playView.diyArcSeekBar.Progress = (int)(playSecond * 100.0 / totalSecond);//+1
                            }
                            //显示歌曲名称
                            playView.songNameTextView.Text = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name) == null ? "Unkown" : A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name);
                            //显示歌手名称
                            playView.singerBtn.Text = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name) == null ? "Unkown" : A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name);
                            //更新源的界面
                            showSourcePage();
                            // showSourcePage();
                        }
                        catch (Exception e)
                        {
@@ -469,18 +550,9 @@
            playView.diyArcSeekBar.IsClickable = true;
            switch (A31MusicModel.Current.A31PlayStatus.Source)
            switch (A31MusicModel.Current.functionMusic.GetAttrState("source"))
            {
                case "QPLAY"://QQ音乐
                    playView.loveBtn.Alpha = 0.5f;
                    playView.loveBtn.Enable = false;
                    break;
                case "AIRPLAY"://酷狗音乐
                    playView.loveBtn.Alpha = 0.5f;
                    playView.loveBtn.Enable = false;
                    playView.diyArcSeekBar.IsClickable = false;
                    break;
                //sdcard/audio_in/ftp/radio/bluetooth
                case "SONGLIST-NETWORK"://本地音乐
                    break;
                case "SONGLIST-LOCAL"://USB
@@ -539,91 +611,62 @@
        /// 加载播放音乐列表View
        /// </summary>
        /// <param name="verticalScrolViewLayout"></param>
        void PlayListView(FrameLayout frameLayout, VerticalRefreshLayout verticalScrolViewLayout, string playListName)
        private void PlayListView(FrameLayout frameLayout, VerticalRefreshLayout verticalScrolViewLayout, Loading loading)
        {
            verticalScrolViewLayout.RemoveAll();
            UI2.FuntionControlView.Music.UpdateThread.playMusuc(verticalScrolViewLayout,"播放列表", playListName, A31MusicModel.Current.CurrentPlayMusicInfoList,A31MusicModel.Current,frameLayout);
            var listName = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playlist_name);
            var source = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.source);
            //获取缓存歌曲列表
            var musicList = A31MusicModel.Current.GetSongList(listName);
            loading.Start();
            if (musicList.Count == 0)
            {
                System.Threading.Tasks.Task.Run((() =>
                {
                    try
                    {
                        A31MusicModel.Current.CurrentPlayMusicInfoList.Clear();
                        if (A31MusicModel.Current.CurrentPlayMusicInfoList.Count == 0)
                        {
                            //获取歌曲列表
                            SendMethod.Current.GetCurrentPalyList(A31MusicModel.Current.functionMusic, () =>
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    musicList = A31MusicModel.Current.GetSongList(listName);
                                    A31SongPlay.SongListView(verticalScrolViewLayout, musicList, listName, source, frameLayout);
                                });
                            });
                        }
                    }
                    catch
                    {
                    }
                    finally
                    {
                        Application.RunOnMainThread(() =>
                        {
                            loading.Hide();
                            //musicList = A31MusicModel.Current.GetSongList(listName);
                            //A31SongPlay.SongListView(verticalScrolViewLayout, musicList, listName, source, frameLayout);
                        });
                    }
                }));
            }
            else
            {
                A31SongPlay.SongListView(verticalScrolViewLayout, musicList, listName, source, frameLayout);
            }
        }
        /// <summary>
        /// 定时更新当前播放音乐
        /// </summary>
        void UpdateSelectedMusic(FrameLayout frameLayout, VerticalRefreshLayout middViewLayout)
        private void UpdateSelectedMusic(FrameLayout frameLayout, VerticalRefreshLayout middViewLayout)
        {
            UI2.FuntionControlView.Music.UpdateThread.updateThread(frameLayout, middViewLayout, A31MusicModel.Current);
        }
        /// <summary>
        /// 读取播放音乐列表
        /// </summary>
        /// <param name="action"></param>
        void GetMusicList(Action<string> action) {
            System.Threading.Tasks.Task.Run(() =>
            {
                string playListName = "List";
                string sourceName = "SourceName";
                try
                {
                    if (A31MusicModel.Current.A31PlayStatus.Source == "STATION-NETWORK")
                    {
                        A31MusicModel.Current.CurrentPlayMusicInfoList = new List<MusicInfo>();
                        return;
                    }
                    if (A31MusicModel.Current.A31PlayStatus.Source == "AIRPLAY")
                    {
                        A31MusicModel.Current.CurrentPlayMusicInfoList = new List<MusicInfo>();
                        return;
                    }
                    var playString = SendMethod.GetCurrentPlayList(A31MusicModel.Current);
                    A31MusicModel.Current.CurrentPlayMusicInfoList = new List<MusicInfo>();
                    var se = System.Security.SecurityElement.FromString(playString);
                    while (se.Children != null)
                    {
                        se = se.Children[0] as System.Security.SecurityElement;
                    }
                    playListName = SecurityElement.FromString(se.Text).SearchForChildByTag("ListName").Text;
                    sourceName = SecurityElement.FromString(se.Text).SearchForChildByTag("ListInfo").SearchForTextOfTag("SourceName");
                    foreach (SecurityElement track in SecurityElement.FromString(se.Text).SearchForChildByTag("Tracks").Children)
                    {
                        MusicInfo musicInfo = new MusicInfo();
                        musicInfo.URL = track.SearchForTextOfTag("URL").Replace("&", "&amp;amp;");
                        var metadata = track.SearchForTextOfTag("Metadata");
                        musicInfo.SourceName = track.SearchForTextOfTag("Source");
                        if (string.IsNullOrEmpty(metadata))
                        {
                            continue;
                        }
                        if (A31MusicModel.IsJson(metadata))
                        {
                            var qqSong = Newtonsoft.Json.JsonConvert.DeserializeObject<SendMethod.A31QQSong>(metadata);
                            musicInfo.Album = qqSong.album;
                            musicInfo.Title = qqSong.title;
                            musicInfo.Artist = qqSong.creator;
                        }
                        else
                        {
                            metadata = metadata.Replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "").Replace("&", "&amp;amp;");
                            var item = SecurityElement.FromString(metadata).SearchForChildByTag("item");
                            musicInfo.Title = item.SearchForTextOfTag("dc:title");
                            musicInfo.Artist = item.SearchForTextOfTag("upnp:artist");
                            musicInfo.Album = item.SearchForTextOfTag("upnp:album");
                            musicInfo.Duration = item.SearchForTextOfTag("res");
                            musicInfo.AlbumId = item.SearchForTextOfTag("song:albumid");
                        }
                        A31MusicModel.Current.CurrentPlayMusicInfoList.Add(musicInfo);
                    }
                }
                catch { }
                finally
                {
                    Application.RunOnMainThread(() =>
                    {
                        action(playListName);
                        //loading.Hide();
                        //PlayListView(myListView.popFra, myListView.verticalScrolViewLayout, playListName);
                        //UpdateSelectedMusic(myListView.popFra, myListView.verticalScrolViewLayout);
                    });
                }
            });
            UpdateThread.updateCurrMusicThread(frameLayout, middViewLayout, A31MusicModel.Current);
        }
    }
}