wjc
2023-03-28 a9d1161b1df96e7ddad566335989a1444e433ef5
HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicSourcePage.cs
@@ -1,17 +1,18 @@
using System;
using System.Collections.Generic;
using System.Security;
using HDL_ON.UI.UI2.FuntionControlView.Music;
using Shared;
namespace HDL_ON.UI.Music
{
    public class A31MusicSourcePage:FrameLayout
    public class A31MusicSourcePage : FrameLayout
    {
        public A31MusicSourcePage()
        {
            Tag = "Music";
        }
        public void Show()
        {
            #region   界面布局------
@@ -33,7 +34,7 @@
            #region 基础信息( 播放器 蓝牙 区域)
            FrameLayout fL1 = new FrameLayout
            {
                Height = Application.GetRealHeight(202),
                Height = Application.GetRealHeight(202 - 50),
                Width = Application.GetRealWidth(375),
            };
            middViewLayout.AddChidren(fL1);
@@ -50,17 +51,11 @@
            View.MusicSourceView playNameView = new View.MusicSourceView();
            playNameView.fLayout.Y = musicIfonView.fLayout.Bottom;
            playNameView.textBtn.TextID = StringId.playerName;
            playNameView.inputTextBtn.Text = A31MusicModel.Current.Name;
            playNameView.inputTextBtn.Text = A31MusicModel.Current.functionMusic.name;
            playNameView.FrameLayoutView(fL1, false);
            View.MusicSourceView bluetoothNameView = new View.MusicSourceView();
            bluetoothNameView.fLayout.Y = playNameView.fLayout.Bottom;
            bluetoothNameView.textBtn.TextID = StringId.bluetoothName;
            bluetoothNameView.inputTextBtn.Text = A31MusicModel.Current.Name;
            bluetoothNameView.FrameLayoutView(fL1, false);
            View.MusicSourceView areaText = new View.MusicSourceView();
            areaText.fLayout.Y = bluetoothNameView.fLayout.Bottom;
            areaText.fLayout.Y = playNameView.fLayout.Bottom;
            areaText.FrameLayoutView(fL1, false);
            areaText.nextLevelBtn.X = Application.GetRealWidth(339);
            areaText.nextLevelBtn.Y = Application.GetRealHeight(17);
@@ -80,7 +75,7 @@
                Height = Application.GetRealHeight(152),
                Width = Application.GetRealWidth(375),
            };
            middViewLayout.AddChidren(fL2);
            //middViewLayout.AddChidren(fL2);
            View.MusicSourceView playListView = new View.MusicSourceView();
            playListView.fLayout.Height = Application.GetRealHeight(44);
@@ -124,36 +119,20 @@
            View.MusicSourceView musicSourceView = new View.MusicSourceView();
            musicSourceView.fLayout.Y = selectedSourceView.fLayout.Bottom;
            musicSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/usb.png";
            musicSourceView.textBtn.TextID = StringId.usb;
            musicSourceView.FrameLayoutView(fL3);
            View.MusicSourceView localMusicSourceView = new View.MusicSourceView();
            localMusicSourceView.fLayout.Y = musicSourceView.fLayout.Bottom;
            localMusicSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/localMusic.png";
            localMusicSourceView.textBtn.TextID = StringId.localMusic;
            //localMusicSourceView.FrameLayoutView(fL3);
            musicSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/localMusic.png";
            musicSourceView.textBtn.TextID = StringId.localMusic;
            //musicSourceView.FrameLayoutView(fL3);
            View.MusicSourceView usbSourceView = new View.MusicSourceView();
            usbSourceView.fLayout.Y = localMusicSourceView.fLayout.Bottom;
            //usbSourceView.fLayout.Y = selectedSourceView.fLayout.Bottom;
            usbSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/usb.png";
            usbSourceView.textBtn.TextID = StringId.usb;
            //usbSourceView.FrameLayoutView(fL3);
            usbSourceView.FrameLayoutView(fL3);
            View.MusicSourceView radioSourceView = new View.MusicSourceView();
            radioSourceView.fLayout.Y = usbSourceView.fLayout.Bottom;
            radioSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/radio.png";
            radioSourceView.textBtn.TextID = StringId.radio;
            //radioSourceView.FrameLayoutView(fL3);暂时隐藏在线电台
            View.MusicSourceView qqMusicSourceView = new View.MusicSourceView();
            qqMusicSourceView.fLayout.Y = usbSourceView.fLayout.Bottom;
            qqMusicSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/qqMusic.png";
            qqMusicSourceView.textBtn.TextID = StringId.qqMusic;
            //qqMusicSourceView.FrameLayoutView(fL3);
            View.MusicSourceView bluetoothSourceView = new View.MusicSourceView();
            bluetoothSourceView.fLayout.Y = qqMusicSourceView.fLayout.Bottom;
            bluetoothSourceView.fLayout.Y = usbSourceView.fLayout.Bottom;
            bluetoothSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/bluetooth.png";
            bluetoothSourceView.textBtn.TextID = StringId.bluetooth;
            //bluetoothSourceView.FrameLayoutView(fL3);
@@ -170,24 +149,62 @@
            #endregion
            #region  所有点击事件
            ///事件
            ///本地音乐事件
            musicSourceView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                A31MusicFileList a31MusicFileList = new A31MusicFileList();
                MainPage.BasePageView.AddChidren(a31MusicFileList);
                a31MusicFileList.Show();
                //A31UsbMusicList a31UsbMusicList = new A31UsbMusicList();
                //MainPage.BasePageView.AddChidren(a31UsbMusicList);
                //a31UsbMusicList.Show();
                //MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                //Loading loading = new Loading();
                //a31UsbMusicList.AddChidren(loading);
                //loading.Start();
                //System.Threading.Tasks.Task.Run(() =>
                //{
                //    try
                //    {
                //        if (A31MusicModel.Current.UsbMusicLists.Count == 0)
                //        {
                //            SendMethod.Current.GetCurrentPalyList(A31MusicModel.Current.functionMusic);
                //        }
                //    }
                //    catch
                //    {
                //    }
                //    finally
                //    {
                //        Application.RunOnMainThread(() =>
                //        {
                //            loading.Hide();
                //            //a31UsbMusicList.FileView();
                //        });
                //    }
                //});
            };
            ///usb事件
            usbSourceView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                A31FlieList a31FlieList = new A31FlieList(KeyProperty.sdcard, usbSourceView.textBtn.Text);
                MainPage.BasePageView.AddChidren(a31FlieList);
                a31FlieList.Show();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                Loading loading = new Loading();
                a31MusicFileList.AddChidren(loading);
                a31FlieList.AddChidren(loading);
                loading.Start();
                var listNameList = CommonMethod.Current.GetListNameListMemory(KeyProperty.sdcard);
                System.Threading.Tasks.Task.Run(() =>
                {
                    try
                    {
                        if (A31MusicModel.Current.palyListInfos.Count == 0)
                        if (listNameList.Count == 0)
                        {
                           SendMethod.sendMethod.GetPalyList(A31MusicModel.Current.functionMusic);
                            var Group = SendMethod.Current.GetSingleSourceListNameList(A31MusicModel.Current.functionMusic, KeyProperty.sdcard);
                            CommonMethod.Current.AddSourceGroupListMemory(Group);//保存缓存
                            listNameList.AddRange(Group.groupList);//更新列表值
                        }
                    }
                    catch
@@ -198,35 +215,36 @@
                        Application.RunOnMainThread(() =>
                        {
                            loading.Hide();
                            a31MusicFileList.FileView();
                            a31FlieList.FileListView(listNameList);
                        });
                    }
                });
            };
            ///播放器修改名称事件
            playNameView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                new View.TipView().InputBox(StringId.modifyName, A31MusicModel.Current.Name, StringId.nameNull, (playerName) =>
                new View.TipView().InputBox(StringId.modifyName, A31MusicModel.Current.functionMusic.name, StringId.nameNull, (playerName) =>
                {
                    playNameView.inputTextBtn.Text = playerName;
                    A31MusicModel.Current.Name = playerName;
                    string url = "http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setDeviceName:" + A31MusicModel.Current.Name;
                    SendMethod.SendCommand(url);
                    A31MusicModel.Current.functionMusic.name = playerName;
                    //发送命令
                    System.Threading.Tasks.Task.Run(() =>
                    {
                        try
                        {
                            SendMethod.Current.EditDeviceName(A31MusicModel.Current.functionMusic.deviceId, playerName);
                        }
                        catch { }
                    });
                });
            };
            ///蓝牙修改名称事件
            bluetoothNameView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                new View.TipView().InputBox(StringId.modifyName, A31MusicModel.Current.Name, StringId.nameNull, (bluetoothName) =>
                {
                    bluetoothNameView.inputTextBtn.Text = bluetoothName;
                    SendMethod.ModifyBluetoothName("MCU+PAS+BT" + bluetoothName.Trim() + "*&");
                });
            };
            ///区域修改的事件
            areaText.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
@@ -258,123 +276,52 @@
            ///我的列表事件
            myListView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                A31MyList a31MyList = new A31MyList();
                MainPage.BasePageView.AddChidren(a31MyList);
                a31MyList.Show();
                a31MyList.UpdateSelectedFile();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            ///本地音乐事件
            localMusicSourceView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                A31LocalMusicList a31LocalMusicList = new A31LocalMusicList();
                MainPage.BasePageView.AddChidren(a31LocalMusicList);
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                a31LocalMusicList.Show();
                a31LocalMusicList.UpdateSelectedMusic();
            };
            ///USB事件
            usbSourceView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                A31USBMusicList usbMusic = new A31USBMusicList();
                MainPage.BasePageView.AddChidren(usbMusic);
                usbMusic.UIView();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                Loading loading = new Loading();
                usbMusic.AddChidren(loading);
                loading.Start();
                //A31MyList a31MyList = new A31MyList();
                //MainPage.BasePageView.AddChidren(a31MyList);
                //a31MyList.Show();
                //a31MyList.UpdateSelectedFile();
                //MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                System.Threading.Tasks.Task.Run(() =>
                {
                    try
                    {
                        if (A31MusicModel.Current.USBList.Count == 0)
                        var palyList = Music.SendMethod.Current.GetSingleSongList(A31MusicModel.Current.functionMusic, "hdl_special", "");
                        List<string> musicNameList = new List<string>();
                        for (int i = 0; i < palyList.songs.Count; i++)
                        {
                            //进来读一次(注意:播放地址可能会改变,导致播放不了音乐;解决:进来都去去读取最新数据)
                            var list = SendMethod.GetUsbList(A31MusicModel.Current);
                            A31MusicModel.Current.USBList.AddRange(list);
                            var music = palyList.songs[i];
                            musicNameList.Add(music.name);
                        }
                    }
                    catch
                    {
                    }
                    finally
                    {
                        Application.RunOnMainThread(() =>
                        {
                            loading.Hide();
                            usbMusic.Show();
                            usbMusic.UpdateSelectedMusic();
                            UI2.Intelligence.Automation.PublicInterface publicInterface = new UI2.Intelligence.Automation.PublicInterface();
                            publicInterface.FrameOrVv(this, musicNameList, new List<string> { "123" }, palyList.group, (index) =>
                            {
                            }, false);
                        });
                    }
                });
            };
            ///在线电台事件
            radioSourceView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                Loading loading = new Loading();
                this.AddChidren(loading);
                loading.Start();
                System.Threading.Tasks.Task.Run(() =>
                {
                    var radioList = SendMethod.ReadRadioList("http://opml.radiotime.com/Browse.ashx?partnerId=yvcOjvJP");
                    Application.RunOnMainThread(() =>
                    {
                        loading.Hide();
                        A31Radio a31Radio = new A31Radio();
                        MainPage.BasePageView.AddChidren(a31Radio);
                        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                        a31Radio.Show(radioList);
                    });
                    catch { }
                });
            };
            ///QQ音乐事件
            qqMusicSourceView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                //string str = "com.tencent.qqmusic";
                //if (Application.DeviceType == Device.Ios)
                //{
                //    str = "qqmusic:";
                //}
                //CommonClass.OpenApp(str);
                bool bol = false;
                string url = "";
                try
                {
#if __IOS__
                    bol = HDLUtils.OpenApp("qqmusic://");
                    url = "https://apps.apple.com/cn/app/qq%E9%9F%B3%E4%B9%90-%E8%AE%A9%E7%94%9F%E6%B4%BB%E5%85%85%E6%BB%A1%E9%9F%B3%E4%B9%90/id414603431";
#else
                    bol = HDLUtils.OpenAppWithPackageName("com.tencent.qqmusic");
                    //url = "http://music.qq.com/";
                    url = "market://details?id=com.tencent.qqmusic";
#endif
                    if (!bol)
                    {
                        new View.TipView().TipBox1(StringId.tip, StringId.qqMsuicTip, () =>
                        {
                            HDLUtils.OpenUrl(url);
                        });
                    }
                }
                catch { }
            };
            ///蓝牙事件
            bluetoothSourceView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                this.RemoveFromParent();
                string url = "http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setPlayerCmd:switchmode:bluetooth";
                SendMethod.SendCommand(url);
            };
            ///线路输入事件
            lineSourceView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                this.RemoveFromParent();
                string url = "http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setPlayerCmd:switchmode:line-in";
                SendMethod.SendCommand(url);
            };