陈嘉乐
2020-06-10 a7d20263f28aa009ef8e064a7f9700d7cd642492
HDL_ON/UI/Music/View/DialogView.cs
@@ -402,7 +402,7 @@
                if (playList1.Count <= 1)
                {
                    new PublicAssmebly().TipMsgAutoClose("至少选中两个以上播放器", false);
                    new PublicAssmebly().TipMsgAutoClose(Language.StringByID(StringId.selectAtLeastTwoPlayers), false);
                    return;
                }
                int number = 0;
@@ -415,7 +415,7 @@
                }
                if (number >= 2)
                {
                    new PublicAssmebly().TipMsgAutoClose("不能选中两个或两个以上主播放器进行组合", false);
                    new PublicAssmebly().TipMsgAutoClose(Language.StringByID(StringId.cannotSelectTwoOrMoreMainPlayersToCombine), false);
                    //如果都是主播放我就不能组合;
                    return;
                }
@@ -663,7 +663,7 @@
            {
                if (selectedBtn.Name.ToString() == "No")
                {
                    new PublicAssmebly().TipMsgAutoClose("还没选中播放器", false);
                    new PublicAssmebly().TipMsgAutoClose(Language.StringByID(StringId.noSelectedPlay), false);
                    return;
                }
                dialogF.Close();
@@ -739,8 +739,8 @@
                TextColor = Color.TextColor,
                TextSize = TextSize.Text16,
                TextAlignment = TextAlignment.Center,
                //TextID = StringId.selectedMergence,
                Text = "选中解除播放器",
                TextID = StringId.checkTheReleasePlayer,
                //Text = "选中解除播放器",
                IsBold = true,
            };
            topFra.AddChidren(txetBtn);
@@ -864,7 +864,7 @@
            {
                if (playList1.Count == 0)
                {
                    new PublicAssmebly().TipMsgAutoClose("还没有选择解除组播放器", false);
                    new PublicAssmebly().TipMsgAutoClose(Language.StringByID(StringId.noCheckTheReleasePlayer), false);
                    return;
                }
                dialog.Close();
@@ -878,7 +878,7 @@
        /// <param name="musicList1"></param>
        void MergeThreading(A31MusicModel serverMusic, List<A31MusicModel> musicList1)
        {
            MusicMain.loading.Start("配置中...");
            MusicMain.loading.Start(Language.StringByID(StringId.inConfiguration));
            bool _if = false;
            System.Threading.Tasks.Task.Run(() =>
            {
@@ -998,10 +998,10 @@
        /// <param name="playList1"></param>
        void RemoveThreading(A31MusicModel a31player, List<A31MusicModel> playList1)
        {
            MusicMain.loading.Start("解除中...");
            MusicMain.loading.Start(Language.StringByID(StringId.lifting));
            var slaveList = new List<Slave>();
            slaveList.AddRange(a31player.Slave.slave_list);
            bool host_If = false; //表示是否显示解除的播放
           // bool host_If = false; //表示是否显示解除的播放
            bool _if = false;
            System.Threading.Tasks.Task.Run(() =>
            {
@@ -1010,7 +1010,6 @@
                    var play_If = playList1.Find((obj) => obj.UniqueDeviceName == a31player.UniqueDeviceName);
                    if (play_If == null)
                    {
                        host_If = false;
                        //子音箱与主音箱断开的命令
                        for (int i = 0; i < playList1.Count; i++)
                        {
@@ -1028,7 +1027,6 @@
                    }
                    else
                    {
                        host_If = true;
                        //解散组的命令
                        if (null == SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:Ungroup"))
                        {
@@ -1050,7 +1048,7 @@
                                var tmepSlaves = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result);
                                if (tmepSlaves != null)
                                {
                                    if (host_If && tmepSlaves.slave_list.Count == 0)
                                    if (tmepSlaves.slave_list.Count == 0)
                                    {
                                        var host_music = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == a31player.UniqueDeviceName);
@@ -1073,9 +1071,9 @@
                                    }
                                    else
                                    {
                                        for (int a = 0; a < playList1.Count; a++)
                                        for (int b = 0; b < tmepSlaves.slave_list.Count; b++)
                                        {
                                            var uuid = playList1[a].UniqueDeviceName;
                                            var uuid = tmepSlaves.slave_list[b].uuid.Replace("uuid:", "");
                                            var music = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == uuid);
                                            if (music != null)
                                            {
@@ -1084,6 +1082,7 @@
                                                music.IsOnLine = false;//先不允许读取
                                            }
                                        }
                                    }
                                    var host_a31player = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == a31player.UniqueDeviceName);
@@ -1136,25 +1135,38 @@
                return a31player.Name;
            }
        }
        List<A31MusicModel> volumePlayList = new List<A31MusicModel>();
        A31MusicModel currVolumePlay = null;//当前的播放器
        int startVolume = 0;//之前的音量
        int endVolume = 0;//现在的音量
        /// <summary>
        /// 播放器音量的界面
        /// </summary>
        /// <param name="a31player">主播放器</param>
       public  void PlayerVolumeView(A31MusicModel a31player)
        public void PlayerVolumeView(A31MusicModel a31player)
        {
            #region
            //主控件
            Dialog dialog = new Dialog()
            {
                //BackgroundColor = Color.PopupBackgroundColor,
            };
            dialog.Show();
            Dialog volumedialog = new Dialog();
            volumedialog.Show();
            //父控件
            FrameLayout frame = new FrameLayout { };
            dialog.AddChidren(frame);
            volumedialog.AddChidren(frame);
            frame.MouseUpEventHandler += (sen, e) =>
            {
                dialog.Close();
                volumedialog.Close();
                if (updateVolumeThread != null)
                {
                    try
                    {
                        if (updateVolumeThread.IsAlive)
                        {
                            updateVolumeThread.Abort();
                        }
                    }
                    catch { }
                }
            };
            //白色快父控件
            FrameLayout dialogFra = new FrameLayout()
@@ -1189,7 +1201,18 @@
            topFra.AddChidren(cancelnBtn);
            cancelnBtn.MouseUpEventHandler += (sen, e) =>
            {
                dialog.Close();
                volumedialog.Close();
                if (updateVolumeThread != null)
                {
                    try
                    {
                        if (updateVolumeThread.IsAlive)
                        {
                            updateVolumeThread.Abort();
                        }
                    }
                    catch { }
                }
            };
            //标题控件
            Button txetBtn = new Button
@@ -1201,8 +1224,7 @@
                TextColor = Color.TextColor,
                TextSize = TextSize.Text16,
                TextAlignment = TextAlignment.Center,
                //TextID = StringId.readyPlay,
                Text="调节音量",
                TextID = StringId.volumeAdjustment,
                IsBold = true,
            };
            topFra.AddChidren(txetBtn);
@@ -1221,18 +1243,28 @@
            topFra.AddChidren(confirmBtn);
            confirmBtn.MouseUpEventHandler += (sen, e) =>
            {
                dialog.Close();
                volumedialog.Close();
                if (updateVolumeThread != null)
                {
                    try
                    {
                        if (updateVolumeThread.IsAlive)
                        {
                            updateVolumeThread.Abort();
                        }
                    }
                    catch { }
                }
            };
            VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout
            VerticalScrolViewLayout volumeViewLayout = new VerticalScrolViewLayout
            {
                Y = Application.GetRealHeight(58),
                Height = dialogFra.Height - Application.GetRealHeight(58),
                Width = Application.GetRealWidth(343),
            };
            dialogFra.AddChidren(verticalScrolViewLayout);
            var playList = new List<A31MusicModel>();
            dialogFra.AddChidren(volumeViewLayout);
            volumePlayList.Clear();
            for (int i = 0; i < a31player.Slave.slave_list.Count; i++)
            {
                var slave = a31player.Slave.slave_list[i];
@@ -1241,19 +1273,19 @@
                {
                    music_If.ServerClientType = -1;
                    music_If.A31PlayStatus.vol = slave.volume;
                    playList.Add(music_If);
                    volumePlayList.Add(music_If);
                }
            }
            playList.Add(a31player);
            volumePlayList.Add(a31player);
            for (int i = 0; i < playList.Count; i++)
            for (int i = 0; i < volumePlayList.Count; i++)
            {
                var player = playList[i];
                var player = volumePlayList[i];
                FrameLayout volumeFra = new FrameLayout
                {
                    Height = Application.GetRealHeight(64),
                };
                verticalScrolViewLayout.AddChidren(volumeFra);
                volumeViewLayout.AddChidren(volumeFra);
                Button volumeTextBtn = new Button
                {
                    X = Application.GetRealWidth(28),
@@ -1263,16 +1295,16 @@
                    TextColor = Color.MusicNoTxetColor,
                    TextSize = TextSize.Text10,
                    TextAlignment = TextAlignment.CenterLeft,
                };
                volumeFra.AddChidren(volumeTextBtn);
                if (player.ServerClientType == -1)
                {
                    volumeTextBtn.Text = player.Name + "音量";
                    volumeTextBtn.Text = player.Name + Language.StringByID(StringId.volumeMusic);
                }
                else if (player.ServerClientType == 1)
                {
                    volumeTextBtn.Text = "总音量";
                    volumeTextBtn.Text = Language.StringByID(StringId.totalVolume);
                }
                DiyImageSeekBar volSeekBar = new DiyImageSeekBar
@@ -1287,11 +1319,11 @@
                    ThumbImagePath = "MusicIcon/progressIcon.png",//进度条按钮图标
                    ThumbImageHeight = Application.GetMinRealAverage(54),//进度条按钮图标的高度(默认正方形:宽和高一样)
                    SeekBarViewHeight = Application.GetMinRealAverage(8),//进度条的高度
                    Progress=int.Parse(player.A31PlayStatus.vol),
                    Progress = int.Parse(player.A31PlayStatus.vol),
                    //ProgressChangeDelayTime=
                };
                volumeFra.AddChidren(volSeekBar);
                Button valueBtn = new Button
                {
                    X = Application.GetRealWidth(289),
@@ -1305,25 +1337,32 @@
                };
                volumeFra.AddChidren(valueBtn);
                ///音量进度条点击事件
                EventHandler<int> progressClick = (sender, e) =>
                {
                    if (currVolumePlay == null || (currVolumePlay != null && currVolumePlay.UniqueDeviceName != player.UniqueDeviceName))
                    {
                        currVolumePlay = player;
                    }
                    endVolume = e;
                    if (player.ServerClientType == -1)
                    {
                        valueBtn.Text = volSeekBar.Progress + "%";
                        SendMethod.ControlVolume(volSeekBar.Progress, player);
                        //SendMethod.ControlVolume(volSeekBar.Progress, player);
                    }
                    else if (player.ServerClientType == 1)
                    {
                        for (int j = 0; j < playList.Count; j++)
                        for (int j = 0; j < volumePlayList.Count; j++)
                        {
                            var music = playList[j];
                            var frameLayout = (FrameLayout)verticalScrolViewLayout.GetChildren(j);
                            var music = volumePlayList[j];
                            var frameLayout = (FrameLayout)volumeViewLayout.GetChildren(j);
                            var diyImageSeekBar = (DiyImageSeekBar)frameLayout.GetChildren(1);
                            var button = (Button)frameLayout.GetChildren(2);
                            diyImageSeekBar.Progress = volSeekBar.Progress;
                            button.Text = volSeekBar.Progress + "%";
                            SendMethod.ControlVolume(volSeekBar.Progress, music);
                            //SendMethod.ControlVolume(volSeekBar.Progress, music);
                        }
                    }
                };
@@ -1333,7 +1372,54 @@
            #endregion
        }
        /// <summary>
        /// 定时音量并且发送命令
        /// </summary>
        System.Threading.Thread updateVolumeThread;
        public void UpdateVolume()
        {
            if (updateVolumeThread != null) {
                try
                {
                    if (updateVolumeThread.IsAlive) {
                        updateVolumeThread.Abort();
                    }
                }
                catch { }
            }
            updateVolumeThread = new System.Threading.Thread(() =>
            {
                try
                {
                    while (true)
                    {
                        System.Threading.Thread.Sleep(500);
                        if (startVolume == endVolume || currVolumePlay == null)
                        {
                            continue;
                        }
                        startVolume = endVolume;
                        if (currVolumePlay.ServerClientType == -1)
                        {
                            SendMethod.ControlVolume(endVolume, currVolumePlay);
                        }
                        else if (currVolumePlay.ServerClientType == 1)
                        {
                            for (int j = 0; j < volumePlayList.Count; j++)
                            {
                                var music = volumePlayList[j];
                                SendMethod.ControlVolume(endVolume, music);
                            }
                        }
                    }
                }
                catch { }
            })
            { IsBackground = true };
            updateVolumeThread.Start();
        }
    }
    [System.Serializable]