| | |
| | | /// </summary> |
| | | public const string Api_Post_BindSourcePanel = "/home-wisdom/source/screen/home/bind"; |
| | | |
| | | #region ■ -- 音乐相关接口_______________________________ |
| | | /// <summary> |
| | | /// 获取音乐列表 |
| | | /// </summary> |
| | | public const string Api_Post_PlayerList = "/home-wisdom/app/wise/music/playerList"; |
| | | #endregion |
| | | |
| | | } |
| | | |
| | |
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\ArmSensor\SensorSmokePage.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\ArmSensor\SensorPirPage.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\ArmSensor\ArmSensorHistroyPaging.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\MusicMain.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31Radio.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\UpdateThread.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31RadioList.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MusicModel.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MusicSourcePage.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31PlayMusicPage.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31LoveRadioList.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31LoveList.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31USBMusicList.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31PlayStatus.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MyList.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\SendMethod.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31LocalMusicList.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31LoveMusicList.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MyListMusic.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\DialogView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\TopView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\MusicView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\PlayView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\SizeClass.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\TipView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\MusicSourceView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\SongView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\MyListView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Electrical\TuyaFanPage.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Electrical\ClothesHangerPage.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Electrical\FanPage.cs" />
|
| | |
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\2-Classification\SceneControlZone.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\3-Intelligence\Automation\CalculatedDistance.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\ArmCenter\PushConfigPage.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\MusicMain.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31Radio.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\UpdateThread.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31RadioList.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MusicModel.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MusicSourcePage.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31PlayMusicPage.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31LoveRadioList.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31LoveList.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31USBMusicList.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31PlayStatus.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MyList.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\SendMethod.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31LocalMusicList.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31LoveMusicList.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MyListMusic.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\DialogView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\TopView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\MusicView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\PlayView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\SizeClass.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\TipView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\MusicSourceView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\SongView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\MyListView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MusicFileList.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31SongPlay.cs" />
|
| | | </ItemGroup>
|
| | | <ItemGroup>
|
| | | <Folder Include="$(MSBuildThisFileDirectory)Entity\Device\" />
|
| | |
| | | break; |
| | | case SPK.MusicStandard: |
| | | case SPK.AvMusic: |
| | | Music.A31MusicModel.Current = (function as Music.A31MusicModel);//当前播放器 |
| | | Music.A31MusicModel.Current.functionMusic =function;//当前播放器 |
| | | var a31PlayMusicPage = new Music.A31PlayMusicPage(); |
| | | MainPage.BasePageView.AddChidren(a31PlayMusicPage); |
| | | a31PlayMusicPage.Show(); |
| | |
| | | if (SPK.MusicSpkList().Contains( function.spk)) |
| | | { |
| | | //var music = function as Music.A31MusicModel; |
| | | var music = Music.A31MusicModel.A31MusicModelList.Find((obj) => obj.sid == function.sid); |
| | | if (music == null) |
| | | { |
| | | continue; |
| | | } |
| | | if (music.ServerClientType == -1) |
| | | { |
| | | continue; |
| | | } |
| | | else if (music.ServerClientType == 1) |
| | | { |
| | | if (!music.MainPlayCollection) |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (!music.collect) |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | //var music = Music.A31MusicModel.A31MusicModelList.Find((obj) => obj.sid == function.sid); |
| | | //if (music == null) |
| | | //{ |
| | | // continue; |
| | | //} |
| | | //if (music.ServerClientType == -1) |
| | | //{ |
| | | // continue; |
| | | //} |
| | | //else if (music.ServerClientType == 1) |
| | | //{ |
| | | // if (!music.MainPlayCollection) |
| | | // { |
| | | // continue; |
| | | // } |
| | | //} |
| | | //else |
| | | //{ |
| | | // if (!music.collect) |
| | | // { |
| | | // continue; |
| | | // } |
| | | //} |
| | | } |
| | | else |
| | | { |
| | |
| | | SelectedImagePath = "FunctionIcon/Music/MusicPlayOnIcon.png", |
| | | }; |
| | | view.AddChidren(btnPower); |
| | | var a31player = (function as UI.Music.A31MusicModel); |
| | | btnState.Text = a31player.A31PlayStatus.Title; |
| | | |
| | | btnState.Text = function.GetAttrState("song_name"); |
| | | |
| | | btnState.SelectedTextColor = CSS_Color.MainBackgroundColor; |
| | | btnState.TextColor = CSS_Color.MainBackgroundColor;//PromptingColor1 |
| | |
| | | |
| | | btnPower.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | |
| | | string status = "off"; |
| | | if (btnPower.IsSelected) |
| | | { |
| | | btnPower.IsSelected = false; |
| | | Music.SendMethod.Pause(a31player); |
| | | a31player.A31PlayStatus.status = "pause"; |
| | | a31player.trait_on_off.curValue = "off"; |
| | | status = "off"; |
| | | } |
| | | else |
| | | { |
| | | btnPower.IsSelected = true; |
| | | Music.SendMethod.Play(a31player); |
| | | a31player.A31PlayStatus.status = "play"; |
| | | a31player.trait_on_off.curValue = "on"; |
| | | status = "on"; |
| | | } |
| | | UpdataFunctionStates(a31player); |
| | | function.SetAttrState("on_off", status); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("on_off", status); |
| | | Music.SendMethod.sendMethod.SendControlCommand(function, dic); |
| | | }; |
| | | } |
| | | |
| | |
| | | //取消收藏事件 |
| | | Action cannelCollect = () => { |
| | | function.collect = false; |
| | | if (SPK.MusicSpkList().Contains(function.spk))//处理音乐主从关系 |
| | | { |
| | | if ((function as Music.A31MusicModel).ServerClientType == 1) |
| | | { |
| | | (function as Music.A31MusicModel).MainPlayCollection = false; |
| | | Music.A31MusicModel.Save(); |
| | | } |
| | | } |
| | | //if (SPK.MusicSpkList().Contains(function.spk))//处理音乐主从关系 |
| | | //{ |
| | | // if ((function as Music.A31MusicModel).ServerClientType == 1) |
| | | // { |
| | | // (function as Music.A31MusicModel).MainPlayCollection = false; |
| | | // Music.A31MusicModel.Save(); |
| | | // } |
| | | //} |
| | | string msg = function.name + Language.StringByID(StringId.CollectionCancelled); |
| | | LoadDeviceFunctionControlZone(); |
| | | function.CollectFunction(); |
| | |
| | | function.collect = false; |
| | | if (SPK.MusicSpkList().Contains(function.spk))//处理音乐主从关系 |
| | | { |
| | | if ((function as Music.A31MusicModel).ServerClientType == 1) |
| | | { |
| | | (function as Music.A31MusicModel).MainPlayCollection = false; |
| | | Music.A31MusicModel.Save(); |
| | | } |
| | | //if ((function as Music.A31MusicModel).ServerClientType == 1) |
| | | //{ |
| | | // (function as Music.A31MusicModel).MainPlayCollection = false; |
| | | // Music.A31MusicModel.Save(); |
| | | //} |
| | | } |
| | | string msg = function.name + Language.StringByID(StringId.CollectionCancelled); |
| | | LoadDeviceFunctionControlZone(); |
| | |
| | | { |
| | | if (SPK.MusicSpkList().Contains(function.spk)) |
| | | { |
| | | btn.Text = (function as Music.A31MusicModel).A31PlayStatus.Title; |
| | | btn.Text =function.GetAttrState("song_name"); |
| | | } |
| | | else |
| | | { |
| | |
| | | else if (SPK.MusicSpkList().Contains(updataFunction.spk)) |
| | | { |
| | | #region 音乐更新 |
| | | var uMusic = updataFunction as Music.A31MusicModel; |
| | | var uMusic = updataFunction; |
| | | if (cTag == updataFunction.spk + "_State_" + updataFunction.sid) |
| | | { |
| | | try |
| | | { |
| | | (fcView.GetChildren(j) as Button).IsSelected = uMusic.A31PlayStatus.status == "play"; |
| | | (fcView.GetChildren(j) as Button).IsSelected = uMusic.GetAttrState("on_off") == "on"; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | |
| | | foreach (var m in Music.A31MusicModel.A31MusicModelList) |
| | | { |
| | | if (m.roomIds.Contains(room.roomId)) |
| | | if (m.functionMusic.roomIds.Contains(room.roomId)) |
| | | { |
| | | Music.SendMethod.Pause(m); |
| | | m.functionMusic.SetAttrState("on_off", "off"); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("on_off", "off"); |
| | | Music.SendMethod.sendMethod.SendControlCommand(m.functionMusic, dic); |
| | | } |
| | | } |
| | | }) |
| | |
| | | SelectedImagePath = "MusicIcon/nextSelected.png", |
| | | }; |
| | | bodyDiv.AddChidren(btnNext); |
| | | LoadEvent_ControlMusic(btnPlay, btnNext, btnPrev, function as A31MusicModel); |
| | | LoadEvent_ControlMusic(btnPlay, btnNext, btnPrev, function); |
| | | #endregion |
| | | } |
| | | |
| | |
| | | /// <param name="btnOpen"></param> |
| | | /// <param name="btnClose"></param> |
| | | /// <param name="curtain"></param> |
| | | void LoadEvent_ControlMusic(Button btnPlay,Button btnNext,Button btnPrev, A31MusicModel a31player) |
| | | void LoadEvent_ControlMusic(Button btnPlay,Button btnNext,Button btnPrev, Function a31player) |
| | | { |
| | | if (a31player == null) |
| | | return; |
| | |
| | | btnPrev.MouseDownEventHandler = (sender, e) => |
| | | { |
| | | btnPrev.IsSelected = true; |
| | | SendMethod.Previous(a31player); |
| | | a31player.SetAttrState("song_step", "up"); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("song_step", "up"); |
| | | SendMethod.sendMethod.SendControlCommand(a31player, dic); |
| | | }; |
| | | btnPrev.MouseUpEventHandler = (sender, e) => |
| | | { |
| | |
| | | ///暂停/播放点击事件 |
| | | btnPlay.MouseDownEventHandler = (sender, e) => |
| | | { |
| | | string status = "off"; |
| | | if (btnPlay.IsSelected) |
| | | { |
| | | btnPlay.IsSelected = false; |
| | | SendMethod.Pause(a31player); |
| | | a31player.A31PlayStatus.status = "pause"; |
| | | status = "off"; |
| | | } |
| | | else |
| | | { |
| | | btnPlay.IsSelected = true; |
| | | SendMethod.Play(a31player); |
| | | a31player.A31PlayStatus.status = "play"; |
| | | status = "on"; |
| | | } |
| | | a31player.SetAttrState("on_off", status); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("on_off", status); |
| | | SendMethod.sendMethod.SendControlCommand(a31player, dic); |
| | | }; |
| | | ///下一曲点击事件 |
| | | btnNext.MouseDownEventHandler = (sender, e) => |
| | | { |
| | | btnNext.IsSelected = true; |
| | | SendMethod.Next(a31player); |
| | | a31player.SetAttrState("song_step", "down"); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("song_step", "down"); |
| | | SendMethod.sendMethod.SendControlCommand(a31player, dic); |
| | | }; |
| | | btnNext.MouseUpEventHandler = (sender, e) => |
| | | { |
| | |
| | | public void MusicView() |
| | | { |
| | | middViewLayout.RemoveAll(); |
| | | UI2.FuntionControlView.Music.UpdateThread.playMusuc(middViewLayout, "本地音乐", Language.StringByID(StringId.localMusic), MusicInfo.MusicInfoList, A31MusicModel.Current); |
| | | // UI2.FuntionControlView.Music.UpdateThread.playMusuc(middViewLayout, "本地音乐", Language.StringByID(StringId.localMusic), MusicInfo.MusicIxnfoList, A31MusicModel.Current); |
| | | } |
| | | /// <summary> |
| | | /// 定时更新当前播放音乐 |
| | | /// </summary> |
| | | public void UpdateSelectedMusic() |
| | | { |
| | | UI2.FuntionControlView.Music.UpdateThread.updateThread(this, middViewLayout,A31MusicModel.Current); |
| | | UI2.FuntionControlView.Music.UpdateThread.updateCurrMusicThread(this, middViewLayout,A31MusicModel.Current); |
| | | } |
| | | |
| | | } |
| | |
| | | if (fileNameBtn.Text == Language.StringByID(StringId.a31Music)) |
| | | { |
| | | ///喜爱音乐列表 |
| | | SelectedPaly(fileNameBtn.Text, A31MusicModel.Current.LoveMusicInfoList, playIconBtn); |
| | | //SelectedPaly(fileNameBtn.Text, A31MusicModel.Current.LoveMusicInfoList, playIconBtn); |
| | | } |
| | | else |
| | | { |
| | | ///喜爱电台列表 |
| | | SelectedPaly(fileNameBtn.Text, A31MusicModel.Current.LoveRadioInfoList, playIconBtn); |
| | | //SelectedPaly(fileNameBtn.Text, A31MusicModel.Current.LoveRadioInfoList, playIconBtn); |
| | | } |
| | | |
| | | }; |
| | |
| | | public void MusicView(string listName) |
| | | { |
| | | middViewLayout.RemoveAll(); |
| | | UI2.FuntionControlView.Music.UpdateThread.playMusuc(middViewLayout, "我的最爱", listName, A31MusicModel.Current.LoveMusicInfoList, A31MusicModel.Current); |
| | | UI2.FuntionControlView.Music.UpdateThread.PlayMusicClick(middViewLayout, "我的最爱", listName, A31MusicModel.Current.LoveMusicInfoList); |
| | | } |
| | | /// <summary> |
| | | /// 定时更新当前播放音乐 |
| | | /// </summary> |
| | | public void UpdateSelectedMusic() |
| | | { |
| | | UI2.FuntionControlView.Music.UpdateThread.updateThread(this, middViewLayout,A31MusicModel.Current); |
| | | UI2.FuntionControlView.Music.UpdateThread.updateCurrMusicThread(this, middViewLayout,A31MusicModel.Current); |
| | | } |
| | | |
| | | |
New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using Shared; |
| | | namespace HDL_ON.UI.Music |
| | | { |
| | | public class A31MusicFileList : FrameLayout |
| | | { |
| | | public A31MusicFileList() |
| | | { |
| | | Tag = "Music"; |
| | | } |
| | | VerticalRefreshLayout middViewLayout; |
| | | public void Show() |
| | | { |
| | | #region 界面布局------ |
| | | |
| | | this.BackgroundColor = MusicColor.ViewColor; |
| | | var topView = new TopView(); |
| | | this.AddChidren(topView.TopFLayoutView()); |
| | | topView.topNameBtn.TextID = StringId.usb; |
| | | topView.clickBackBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | this.RemoveFromParent(); |
| | | }; |
| | | middViewLayout = new VerticalRefreshLayout |
| | | { |
| | | BackgroundColor = MusicColor.WhiteColor, |
| | | Y = topView.fLayout.Bottom, |
| | | Height = Application.GetRealHeight(H_W.H - H_W.T_Height), |
| | | }; |
| | | this.AddChidren(middViewLayout); |
| | | #endregion |
| | | |
| | | middViewLayout.BeginHeaderRefreshingAction += () => |
| | | { |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | try |
| | | { |
| | | SendMethod.sendMethod.GetPalyList(A31MusicModel.Current.functionMusic); |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | FileView(); |
| | | middViewLayout.EndHeaderRefreshing(); |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | }; |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 加载文件夹View的方法 |
| | | /// </summary> |
| | | public void FileView() |
| | | { |
| | | middViewLayout.RemoveAll(); |
| | | for (int i = 0; i < A31MusicModel.Current.palyListInfos.Count; i++) |
| | | { |
| | | var list = A31MusicModel.Current.palyListInfos[i]; |
| | | RowLayout addFlieRow = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(104), |
| | | LineColor = MusicColor.WhiteColor, |
| | | SubViewWidth = Application.GetRealWidth(90),//改变编辑控件宽度多少; |
| | | }; |
| | | middViewLayout.AddChidren(addFlieRow); |
| | | //文件图标 |
| | | Button fileIconBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Y = Application.GetRealHeight(8), |
| | | Width = Application.GetRealWidth(88), |
| | | Height = Application.GetRealWidth(88), |
| | | UnSelectedImagePath = "MusicIcon/fileList.png", |
| | | }; |
| | | addFlieRow.AddChidren(fileIconBtn); |
| | | |
| | | //文件名控件 |
| | | Button fileNameBtn = new Button |
| | | { |
| | | X = fileIconBtn.Right + Application.GetRealWidth(16), |
| | | Y = Application.GetRealHeight(42), |
| | | Width = Application.GetRealWidth(217), |
| | | Height = Application.GetRealHeight(20), |
| | | TextColor = MusicColor.TextColor, |
| | | TextSize = TextSize.Text14, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Text = list.group, |
| | | }; |
| | | addFlieRow.AddChidren(fileNameBtn); |
| | | |
| | | Button clickBtn = new Button |
| | | { |
| | | X = fileIconBtn.Right + Application.GetRealWidth(16), |
| | | Width = Application.GetRealWidth(375 - 138), |
| | | Height = Application.GetRealHeight(104), |
| | | }; |
| | | addFlieRow.AddChidren(clickBtn); |
| | | clickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | A31SongPlay a31Song = new A31SongPlay(); |
| | | MainPage.BasePageView.AddChidren(a31Song); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | a31Song.Show(list.songs, list.group); |
| | | }; |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | |
| | | [System.Serializable] |
| | | public class A31MusicModel : Function |
| | | public class A31MusicModel |
| | | { |
| | | public static List<A31MusicModel> A31MusicModelList = new List<A31MusicModel> { }; |
| | | static readonly string a31MusiceModeListFilePath = "A31MusiceModeListFilePath"; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 音乐功能 |
| | | /// </summary> |
| | | public Function functionMusic = new Function(); |
| | | /// <summary> |
| | | /// 移除之前的线程 |
| | | /// </summary> |
| | | public static void RemoveListThread() { |
| | | public static void RemoveListThread() |
| | | { |
| | | for (int i = 0; i < updataMusicStatesListThread.Count;) |
| | | { |
| | | try |
| | | { |
| | | { |
| | | var thread = updataMusicStatesListThread[i]; |
| | | if (thread.IsAlive) |
| | | { |
| | |
| | | { |
| | | for (int i = 0; i < A31MusicModelList.Count; i++) |
| | | { |
| | | if (A31MusicModelList[i].collect) |
| | | if (A31MusicModelList[i].functionMusic.collect) |
| | | { |
| | | return true; //查询是否有音乐被收藏过 |
| | | } |
| | |
| | | /// <summary> |
| | | ///当前播放的列表信息 |
| | | /// </summary> |
| | | public List<MusicInfo> CurrentPlayMusicInfoList = new List<MusicInfo>(); |
| | | public List<Songs> CurrentPlayMusicInfoList = new List<Songs>(); |
| | | |
| | | /// <summary> |
| | | /// 是否允许显示 |
| | |
| | | /// </summary> |
| | | public bool IsOnLine = true; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 列表 |
| | | /// </summary> |
| | | public List<PalyListInfo> palyListInfos = new List<PalyListInfo>(); |
| | | |
| | | /// <summary> |
| | | /// 喜爱音乐列表 |
| | | /// </summary> |
| | | public List<MusicInfo> LoveMusicInfoList = new List<MusicInfo>(); |
| | | public List<Songs> LoveMusicInfoList = new List<Songs>(); |
| | | |
| | | /// <summary> |
| | | /// DLNA所有列表 |
| | | /// </summary> |
| | | public List<MusicInfo> dlnaMusicInfoLists = new List<MusicInfo>(); |
| | | public List<Songs> dlnaMusicInfoLists = new List<Songs>(); |
| | | |
| | | /// <summary> |
| | | /// 电台所有列表 |
| | | /// </summary> |
| | | public List<MusicInfo> CnRadioInfoList = new List<MusicInfo>(); |
| | | public List<Songs> CnRadioInfoList = new List<Songs>(); |
| | | |
| | | /// <summary> |
| | | /// vTuner电台所有列表 |
| | | /// </summary> |
| | | public List<MusicInfo> vTunerList = new List<MusicInfo>(); |
| | | public List<Songs> vTunerList = new List<Songs>(); |
| | | |
| | | /// <summary> |
| | | /// 喜爱电台列表 |
| | | /// </summary> |
| | | public List<MusicInfo> LoveRadioInfoList = new List<MusicInfo>(); |
| | | public List<Songs> LoveRadioInfoList = new List<Songs>(); |
| | | |
| | | /// <summary> |
| | | /// Pandora电台所有列表 |
| | | /// </summary> |
| | | public List<MusicInfo> PanRadioInfoList = new List<MusicInfo>(); |
| | | public List<Songs> PanRadioInfoList = new List<Songs>(); |
| | | /// <summary> |
| | | /// usb列表 |
| | | /// </summary> |
| | | public List<MusicInfo> USBList = new List<MusicInfo>(); |
| | | public List<Songs> USBList = new List<Songs>(); |
| | | /// <summary> |
| | | /// Tidal喜爱列表 |
| | | /// </summary> |
| | | public List<MusicInfo> TidalLikelist = new List<MusicInfo>(); |
| | | public List<Songs> TidalLikelist = new List<Songs>(); |
| | | /// <summary> |
| | | ///创建音乐文件列表 |
| | | /// </summary> |
| | |
| | | set |
| | | { |
| | | _ServerClientType = value; |
| | | if(value == 0) |
| | | if (value == 0) |
| | | { |
| | | name = Name; |
| | | //name = Name; |
| | | } |
| | | } |
| | | } |
| | |
| | | set |
| | | { |
| | | _MainPlayName = value; |
| | | if(ServerClientType == 1) |
| | | { |
| | | name = value; |
| | | } |
| | | //if(ServerClientType == 1) |
| | | //{ |
| | | // name = value; |
| | | //} |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 指定列表名获取音乐列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<Songs> GetSongList(string listName) |
| | | { |
| | | var list = palyListInfos.Find((o)=>o.group==listName); |
| | | if (list==null) { |
| | | return new List<Songs>(); |
| | | } |
| | | return list.songs; |
| | | } |
| | | /// <summary> |
| | | /// 记录主播放器是否被收藏(秀桡定义的) |
| | |
| | | /// <summary> |
| | | /// 列表歌曲信息 |
| | | /// </summary> |
| | | public List<MusicInfo> MusicInfoList = new List<MusicInfo>(); |
| | | public List<Songs> MusicInfoList = new List<Songs>(); |
| | | } |
| | | [System.Serializable] |
| | | public class TidalMusicInfo : MusicInfo |
| | |
| | | public string version = string.Empty; |
| | | public string uuid = string.Empty; |
| | | } |
| | | [System.Serializable] |
| | | /// <summary> |
| | | /// 列表信息 |
| | | /// </summary> |
| | | public class PalyListInfo |
| | | { |
| | | /// <summary> |
| | | /// 列表名 |
| | | /// </summary> |
| | | public string group = string.Empty; |
| | | /// <summary> |
| | | /// 列表歌曲信息 |
| | | /// </summary> |
| | | public List<Songs> songs = new List<Songs>(); |
| | | } |
| | | [System.Serializable] |
| | | public class Songs:MusicInfo |
| | | { |
| | | /// <summary> |
| | | /// 歌曲名称 |
| | | /// </summary> |
| | | public string name = string.Empty; |
| | | /// <summary> |
| | | /// 大小 |
| | | /// </summary> |
| | | public string size = string.Empty; |
| | | /// <summary> |
| | | /// 时长 |
| | | /// </summary> |
| | | public string time = string.Empty; |
| | | /// <summary> |
| | | /// 类型<自己用> |
| | | /// </summary> |
| | | public string type = string.Empty; |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | areaText.lineBtn.BackgroundColor = MusicColor.WhiteColor; |
| | | areaText.textBtn.X = Application.GetRealWidth(16); |
| | | areaText.textBtn.TextID = StringId.region; |
| | | areaText.inputTextBtn.Text = A31MusicModel.Current.GetRoomListName(); |
| | | areaText.inputTextBtn.Text = A31MusicModel.Current.functionMusic.GetRoomListName(); |
| | | |
| | | #endregion |
| | | |
| | |
| | | selectedSourceView.nextLevelBtn.Visible = false; |
| | | selectedSourceView.FrameLayoutView(fL3, false); |
| | | |
| | | 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 = selectedSourceView.fLayout.Bottom; |
| | | localMusicSourceView.fLayout.Y = musicSourceView.fLayout.Bottom; |
| | | localMusicSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/localMusic.png"; |
| | | localMusicSourceView.textBtn.TextID = StringId.localMusic; |
| | | localMusicSourceView.FrameLayoutView(fL3); |
| | | //localMusicSourceView.FrameLayoutView(fL3); |
| | | |
| | | View.MusicSourceView usbSourceView = new View.MusicSourceView(); |
| | | usbSourceView.fLayout.Y = localMusicSourceView.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; |
| | |
| | | qqMusicSourceView.fLayout.Y = usbSourceView.fLayout.Bottom; |
| | | qqMusicSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/qqMusic.png"; |
| | | qqMusicSourceView.textBtn.TextID = StringId.qqMusic; |
| | | qqMusicSourceView.FrameLayoutView(fL3); |
| | | //qqMusicSourceView.FrameLayoutView(fL3); |
| | | |
| | | View.MusicSourceView bluetoothSourceView = new View.MusicSourceView(); |
| | | bluetoothSourceView.fLayout.Y = qqMusicSourceView.fLayout.Bottom; |
| | | bluetoothSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/bluetooth.png"; |
| | | bluetoothSourceView.textBtn.TextID = StringId.bluetooth; |
| | | bluetoothSourceView.FrameLayoutView(fL3); |
| | | //bluetoothSourceView.FrameLayoutView(fL3); |
| | | |
| | | View.MusicSourceView lineSourceView = new View.MusicSourceView(); |
| | | lineSourceView.fLayout.Y = bluetoothSourceView.fLayout.Bottom; |
| | | lineSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/line.png"; |
| | | lineSourceView.textBtn.TextID = StringId.line; |
| | | lineSourceView.FrameLayoutView(fL3); |
| | | //lineSourceView.FrameLayoutView(fL3); |
| | | |
| | | |
| | | #endregion |
| | |
| | | #endregion |
| | | |
| | | #region 所有点击事件 |
| | | ///事件 |
| | | musicSourceView.clickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | A31MusicFileList a31MusicFileList = new A31MusicFileList(); |
| | | MainPage.BasePageView.AddChidren(a31MusicFileList); |
| | | a31MusicFileList.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | Loading loading = new Loading(); |
| | | a31MusicFileList.AddChidren(loading); |
| | | loading.Start(); |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | try |
| | | { |
| | | if (A31MusicModel.Current.palyListInfos.Count == 0) |
| | | { |
| | | SendMethod.sendMethod.GetPalyList(A31MusicModel.Current.functionMusic); |
| | | |
| | | } |
| | | } |
| | | catch |
| | | { |
| | | } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | a31MusicFileList.FileView(); |
| | | }); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | |
| | | ///播放器修改名称事件 |
| | | playNameView.clickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | |
| | | ///区域修改的事件 |
| | | areaText.clickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | ChooseRoomPage chooseRoomPage = new ChooseRoomPage(A31MusicModel.Current, () => |
| | | ChooseRoomPage chooseRoomPage = new ChooseRoomPage(A31MusicModel.Current.functionMusic, () => |
| | | { |
| | | areaText.inputTextBtn.Text = A31MusicModel.Current.GetRoomListName(); |
| | | areaText.inputTextBtn.Text = A31MusicModel.Current.functionMusic.GetRoomListName(); |
| | | A31MusicModel.Save(); |
| | | }); |
| | | MainPage.BasePageView.AddChidren(chooseRoomPage); |
| | |
| | | //移除界面 |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | SendMethod.PushList(songs, list.ListName, list.MusicInfoList,A31MusicModel.Current, "我的列表"); |
| | | // SendMethod.PushList(songs, list.ListName, list.MusicInfoList,A31MusicModel.Current, "我的列表"); |
| | | }); |
| | | }); |
| | | }); |
| | |
| | | public void MusicView(FileListInfo fileListInfo) |
| | | { |
| | | middViewLayout.RemoveAll(); |
| | | UI2.FuntionControlView.Music.UpdateThread.playMusuc(middViewLayout,"我的列表", fileListInfo.ListName, fileListInfo.MusicInfoList, A31MusicModel.Current); |
| | | UI2.FuntionControlView.Music.UpdateThread.PlayMusicClick(middViewLayout,"我的列表", fileListInfo.ListName, fileListInfo.MusicInfoList); |
| | | } |
| | | /// <summary> |
| | | /// 定时更新当前播放音乐 |
| | | /// </summary> |
| | | public void UpdateSelectedMusic() |
| | | { |
| | | UI2.FuntionControlView.Music.UpdateThread.updateThread(this, middViewLayout, A31MusicModel.Current); |
| | | UI2.FuntionControlView.Music.UpdateThread.updateCurrMusicThread(this, middViewLayout, A31MusicModel.Current); |
| | | } |
| | | |
| | | |
| | |
| | | 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 totalSecond = (int)(playView.diyArcSeekBar.Progress * 1.0f / 100 * int.Parse(A31MusicModel.Current.functionMusic.GetAttrState("song_time"))); |
| | | //分钟 |
| | | 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); |
| | | //SendMethod.Seek(time, A31MusicModel.Current); |
| | | |
| | | //Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | //dic.Add("mode", modeValueString); |
| | | //SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | A31MusicModel.Current.A31PlayStatus.curpos = (DateTime.Parse(time) - DateTime.Parse("00:00:00")).TotalMilliseconds.ToString(); |
| | | }; |
| | | ///切换播放模式点击事件; |
| | | playView.playOrderBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | string modeValueString = string.Empty; |
| | | string msg = Language.StringByID(StringId.switchTo); |
| | | switch (A31MusicModel.Current.A31PlayStatus.loop) |
| | | { |
| | | //0列表循环,1单曲循环,2随机播放; |
| | | case "0": |
| | | A31MusicModel.Current.A31PlayStatus.loop = "1"; |
| | | //list_cycle列表循环,single_cycle单曲循环,random随机播放; |
| | | case "list_cycle": |
| | | modeValueString="single_cycle"; |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; |
| | | msg += Language.StringByID(StringId.singleMode); |
| | | break; |
| | | |
| | | case "1": |
| | | A31MusicModel.Current.A31PlayStatus.loop = "2"; |
| | | case "single_cycle": |
| | | modeValueString = "random"; |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; |
| | | msg += Language.StringByID(StringId.randomMode); |
| | | break; |
| | | case "2": |
| | | A31MusicModel.Current.A31PlayStatus.loop = "0"; |
| | | case "random": |
| | | modeValueString = "list_cycle"; |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; |
| | | msg += Language.StringByID(StringId.listMode); |
| | | break; |
| | | } |
| | | A31MusicModel.Current.functionMusic.SetAttrState("mode", modeValueString); |
| | | new PublicAssmebly().TipMsgAutoClose(msg, false,1000); |
| | | string url = "http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setPlayerCmd:" + "loopmode:" + A31MusicModel.Current.A31PlayStatus.loop; |
| | | SendMethod.SendCommand(url); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("mode",modeValueString); |
| | | SendMethod.sendMethod.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; |
| | | var name = A31MusicModel.Current.functionMusic.GetAttribute("song_name").ToString(); |
| | | var songTime = A31MusicModel.Current.functionMusic.GetAttribute("song_time").ToString(); |
| | | if (A31MusicModel.Current.A31PlayStatus.Source == "RADIO-NETWORK") |
| | | { |
| | | playView.loveBtn.IsSelected = !playView.loveBtn.IsSelected; |
| | |
| | | { |
| | | if (null == A31MusicModel.Current.LoveRadioInfoList.Find((musicInfo) => |
| | | { |
| | | return url == musicInfo.URL; |
| | | return name == musicInfo.name; |
| | | })) |
| | | { |
| | | A31MusicModel.Current.LoveRadioInfoList.Add(new MusicInfo { Title = song, URL = url, }); |
| | | A31MusicModel.Current.LoveRadioInfoList.Add(new Songs { name = name, time = songTime}); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | A31MusicModel.Current.LoveRadioInfoList.RemoveAll((musicInfo) => |
| | | { |
| | | return url == musicInfo.URL; |
| | | return name == musicInfo.name; |
| | | }); |
| | | } |
| | | } |
| | |
| | | { |
| | | if (null == A31MusicModel.Current.LoveMusicInfoList.Find((musicInfo) => |
| | | { |
| | | return url == musicInfo.URL; |
| | | return name == musicInfo.name; |
| | | })) |
| | | { |
| | | A31MusicModel.Current.LoveMusicInfoList.Add(new MusicInfo { Title = song, URL = url, Artist = artist, Album = album }); |
| | | A31MusicModel.Current.LoveMusicInfoList.Add(new Songs { name = name, time = songTime}); |
| | | } |
| | | } |
| | | else |
| | |
| | | A31MusicModel.Current.LoveMusicInfoList.RemoveAll((musicInfo) => |
| | | { |
| | | //也要加歌手名判断 |
| | | return musicInfo.URL == url; |
| | | return musicInfo.name == name; |
| | | }); |
| | | } |
| | | |
| | |
| | | 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); |
| | | |
| | | PlayListView(myListView.popFra, myListView.verticalScrolViewLayout); |
| | | UpdateSelectedMusic(myListView.popFra, myListView.verticalScrolViewLayout); |
| | | |
| | | }; |
| | | ///音量图标点击事件 |
| | | playView.volIconBtn.MouseUpEventHandler += (sender, e) => |
| | |
| | | if (startVolume != e) |
| | | { |
| | | startVolume = e; |
| | | SendMethod.ControlVolume(e, A31MusicModel.Current); |
| | | A31MusicModel.Current.A31PlayStatus.vol = e.ToString(); |
| | | A31MusicModel.Current.functionMusic.SetAttrState("volume", startVolume); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("volume", startVolume.ToString()); |
| | | SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | |
| | | } |
| | | }; |
| | | playView.volSeekBar.OnProgressChangedEvent += progressClick; |
| | |
| | | playView.prevBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | playView.prevBtn.IsSelected = true; |
| | | SendMethod.Previous(A31MusicModel.Current); |
| | | |
| | | A31MusicModel.Current.functionMusic.SetAttrState("song_step", "down"); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("song_step", "down"); |
| | | SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | |
| | | }; |
| | | playView.prevBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | |
| | | ///暂停/播放点击事件 |
| | | 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 = "off"; |
| | | } |
| | | else |
| | | { |
| | | playView.playBtn.IsSelected = true; |
| | | SendMethod.Play(A31MusicModel.Current); |
| | | A31MusicModel.Current.A31PlayStatus.status = "play"; |
| | | status = "on"; |
| | | } |
| | | A31MusicModel.Current.functionMusic.SetAttrState("on_off", status); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("on_off", status); |
| | | SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | }; |
| | | ///下一曲点击事件 |
| | | playView.nextBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | playView.nextBtn.IsSelected = true; |
| | | SendMethod.Next(A31MusicModel.Current); |
| | | A31MusicModel.Current.functionMusic.SetAttrState("song_step", "down"); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("song_step", "down"); |
| | | SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | }; |
| | | playView.nextBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | |
| | | if (startVolume != volume) |
| | | { |
| | | startVolume = volume; |
| | | SendMethod.ControlVolume(volume, A31MusicModel.Current); |
| | | A31MusicModel.Current.A31PlayStatus.vol = volume.ToString(); |
| | | A31MusicModel.Current.functionMusic.SetAttrState("volume", startVolume); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("volume", startVolume.ToString()); |
| | | SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | } |
| | | |
| | | }; |
| | |
| | | |
| | | //更新总时间 |
| | | //总共有多少秒 |
| | | int totalSecond = int.Parse(A31MusicModel.Current.A31PlayStatus.totlen) / 1000; |
| | | int totalSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState("song_time")); |
| | | //分钟 |
| | | int totalMusicMinute = totalSecond / 60; |
| | | //秒钟 |
| | |
| | | |
| | | //topView.topNameBtn.Text = A31MusicModel.Current.Name; |
| | | |
| | | switch (A31MusicModel.Current.A31PlayStatus.loop) |
| | | switch (A31MusicModel.Current.functionMusic.GetAttrState("mode")) |
| | | { |
| | | case "0"://列表循环 |
| | | case "list_cycle"://列表循环 |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; |
| | | break; |
| | | case "1"://单曲顺环 |
| | | case "single_cycle"://单曲循环 |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; |
| | | break; |
| | | case "2"://随机播放 |
| | | case "random"://随机播放 |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; |
| | | break; |
| | | } |
| | | |
| | | |
| | | 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.GetRoomListName(); |
| | | if (A31MusicModel.Current.collect) |
| | | //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) |
| | | { |
| | | playView.collectIconBtn.IsSelected = true; |
| | | } |
| | |
| | | //更新播放器音量给系统音量 |
| | | Volume.MusicVolume = playView.volSeekBar.Progress; |
| | | //当前播放音乐时间 |
| | | int playSecond = int.Parse(A31MusicModel.Current.A31PlayStatus.curpos) / 1000 + (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; |
| | | int playSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState("playing_time"))+ (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; |
| | | |
| | | int playMusicMinute = 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") |
| | | if (A31MusicModel.Current.functionMusic.GetAttrState("on_off") == "on") |
| | | { |
| | | playView.playBtn.IsSelected = true; |
| | | //如果在播放,时间就不断变化 |
| | |
| | | //停止播放 |
| | | playView.startTimeBtn.Text =playTime; |
| | | } |
| | | 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()); |
| | | playView.songNameTextView.Text = A31MusicModel.Current.functionMusic.GetAttrState("song_name") == null ? "Unkown" : A31MusicModel.Current.functionMusic.GetAttrState("song_name"); |
| | | playView.singerBtn.Text = A31MusicModel.Current.functionMusic.GetAttrState("song_name") == null ? "Unkown" : A31MusicModel.Current.functionMusic.GetAttrState("song_name"); |
| | | //更新源的界面 |
| | | showSourcePage(); |
| | | // showSourcePage(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | |
| | | playView.diyArcSeekBar.IsClickable = true; |
| | | |
| | | switch (A31MusicModel.Current.A31PlayStatus.Source) |
| | | switch (A31MusicModel.Current.functionMusic.GetAttrState("source")) |
| | | { |
| | | |
| | | case "QPLAY"://QQ音乐 |
| | |
| | | /// 加载播放音乐列表View |
| | | /// </summary> |
| | | /// <param name="verticalScrolViewLayout"></param> |
| | | void PlayListView(FrameLayout frameLayout, VerticalRefreshLayout verticalScrolViewLayout, string playListName) |
| | | void PlayListView(FrameLayout frameLayout, VerticalRefreshLayout verticalScrolViewLayout) |
| | | { |
| | | verticalScrolViewLayout.RemoveAll(); |
| | | UI2.FuntionControlView.Music.UpdateThread.playMusuc(verticalScrolViewLayout,"播放列表", playListName, A31MusicModel.Current.CurrentPlayMusicInfoList,A31MusicModel.Current,frameLayout); |
| | | var listName = A31MusicModel.Current.functionMusic.GetAttribute("playlist_name").ToString(); |
| | | var musicList = A31MusicModel.Current.GetSongList(listName); |
| | | UI2.FuntionControlView.Music.UpdateThread.PlayMusicClick(verticalScrolViewLayout,"播放列表", listName, musicList, frameLayout); |
| | | } |
| | | /// <summary> |
| | | /// 定时更新当前播放音乐 |
| | | /// </summary> |
| | | void UpdateSelectedMusic(FrameLayout frameLayout, VerticalRefreshLayout middViewLayout) |
| | | { |
| | | UI2.FuntionControlView.Music.UpdateThread.updateThread(frameLayout, middViewLayout, A31MusicModel.Current); |
| | | UI2.FuntionControlView.Music.UpdateThread.updateCurrMusicThread(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;"); |
| | | 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;"); |
| | | 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); |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | { |
| | | if (childNodes.Name == "outline" && childNodes.Attributes["URL"] != null) |
| | | { |
| | | MusicInfo musicInfoCN = new MusicInfo(); |
| | | Songs musicInfoCN = new Songs(); |
| | | musicInfoCN.URL = childNodes.Attributes["URL"] == null ? "" : childNodes.Attributes["URL"].Value; |
| | | musicInfoCN.Title = childNodes.Attributes["text"] == null ? "" : childNodes.Attributes["text"].Value; |
| | | musicInfoCN.Image = childNodes.Attributes["image"] == null ? "" : childNodes.Attributes["image"].Value; |
| | |
| | | { |
| | | if (a.Name == "outline") |
| | | { |
| | | MusicInfo musicInfoCN = new MusicInfo(); |
| | | Songs musicInfoCN = new Songs(); |
| | | musicInfoCN.URL = a.Attributes["URL"] == null ? "" : a.Attributes["URL"].Value; |
| | | musicInfoCN.Title = a.Attributes["text"] == null ? "" : a.Attributes["text"].Value; |
| | | |
| | |
| | | switch (v.Name) |
| | | { |
| | | case "outline": |
| | | MusicInfo musicInfo = new MusicInfo(); |
| | | musicInfo.Title = v.Attributes["text"].Value; |
| | | Songs musicInfo = new Songs(); |
| | | musicInfo.name = v.Attributes["text"].Value; |
| | | musicInfo.URL = v.Attributes["URL"].Value; |
| | | musicInfo.Cnkey = v.Attributes["key"].Value; |
| | | |
| | |
| | | { |
| | | if (childNodes.Name == "outline" && childNodes.Attributes["URL"] != null) |
| | | { |
| | | MusicInfo musicInfoCN = new MusicInfo(); |
| | | Songs musicInfoCN = new Songs(); |
| | | musicInfoCN.URL = childNodes.Attributes["URL"] == null ? "" : childNodes.Attributes["URL"].Value; |
| | | musicInfoCN.Title = childNodes.Attributes["text"] == null ? "" : childNodes.Attributes["text"].Value; |
| | | //musicInfoCN.Image = childNodes.Attributes["image"] == null ? "" : childNodes.Attributes["image"].Value; |
| | |
| | | { |
| | | if (a.Name == "outline") |
| | | { |
| | | MusicInfo musicInfoCN = new MusicInfo(); |
| | | Songs musicInfoCN = new Songs(); |
| | | musicInfoCN.URL = a.Attributes["URL"] == null ? "" : a.Attributes["URL"].Value; |
| | | musicInfoCN.Title = a.Attributes["text"] == null ? "" : a.Attributes["text"].Value; |
| | | if (a.Attributes["image"] != null) |
New file |
| | |
| | | using System; |
| | | using Shared; |
| | | using HDL_ON.UI.Music; |
| | | using System.Collections.Generic; |
| | | |
| | | namespace HDL_ON.UI.Music |
| | | { |
| | | |
| | | public class A31SongPlay : FrameLayout |
| | | { |
| | | public A31SongPlay() |
| | | { |
| | | Tag = "Music"; |
| | | } |
| | | |
| | | public void Show(List<Songs> musicList,string listName) |
| | | { |
| | | |
| | | this.BackgroundColor = MusicColor.ViewColor; |
| | | var topView = new TopView(); |
| | | this.AddChidren(topView.TopFLayoutView()); |
| | | topView.topNameBtn.TextID = StringId.usb; |
| | | topView.clickBackBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | this.RemoveFromParent(); |
| | | }; |
| | | var vv = new VerticalRefreshLayout |
| | | { |
| | | BackgroundColor = MusicColor.WhiteColor, |
| | | Y = topView.fLayout.Bottom, |
| | | Height = Application.GetRealHeight(H_W.H - H_W.T_Height), |
| | | }; |
| | | this.AddChidren(vv); |
| | | ///加载音乐列表 |
| | | SongListView(vv, musicList, listName); |
| | | |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 加载音乐列表 |
| | | /// </summary> |
| | | /// <param name="vv">父控件</param> |
| | | /// <param name="musicList">音乐列表</param> |
| | | /// <param name="listName">列表名</param> |
| | | public void SongListView(VerticalRefreshLayout vv,List<Songs> musicList,string listName) { |
| | | |
| | | for (int i = 0; i < musicList.Count; i++) |
| | | { |
| | | var songs = musicList[i]; |
| | | if (songs == null) |
| | | { |
| | | continue; |
| | | } |
| | | UI.Music.View.SongView songView = new UI.Music.View.SongView(); |
| | | songView.SongFrameLayout(vv, songs); |
| | | songView.singerBtn.Text = songs.name; |
| | | ///点击播放事件 |
| | | songView.clickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | System.Threading.Thread.Sleep(50); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | //移除界面 |
| | | A31MusicModel.Current.functionMusic.SetAttrState("song_name", songView.songBtn.Text); |
| | | A31MusicModel.Current.functionMusic.SetAttrState("playlist_name", listName); |
| | | MainPage.BasePageView.RemoveViewByTag("Music"); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("song_name", songView.songBtn.Text); |
| | | dic.Add("playlist_name", listName); |
| | | SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | }); |
| | | }); |
| | | }; |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | // }); |
| | | // } |
| | | //}); |
| | | var list = SendMethod.GetUsbList(A31MusicModel.Current); |
| | | |
| | | A31MusicModel.Current.USBList.Clear(); |
| | | A31MusicModel.Current.USBList.AddRange(list); |
| | | var list = SendMethod.GetUsbList(A31MusicModel.Current); |
| | | foreach (var song in list) { |
| | | Songs music = new Songs(); |
| | | music.name = song.Title; |
| | | music.size = song.Size; |
| | | music.time = song.Duration; |
| | | A31MusicModel.Current.USBList.Add(music); |
| | | } |
| | | Show(); |
| | | middViewLayout.EndHeaderRefreshing(); |
| | | }; |
| | |
| | | public void Show() |
| | | { |
| | | middViewLayout.RemoveAll(); |
| | | UI2.FuntionControlView.Music.UpdateThread.playMusuc(middViewLayout, "USB", "USBDiskQueue",A31MusicModel.Current.USBList, A31MusicModel.Current); |
| | | UI2.FuntionControlView.Music.UpdateThread.PlayMusicClick(middViewLayout, "USB", "USBDiskQueue",A31MusicModel.Current.USBList); |
| | | } |
| | | /// <summary> |
| | | /// 定时更新当前播放音乐 |
| | | /// </summary> |
| | | public void UpdateSelectedMusic() |
| | | { |
| | | UI2.FuntionControlView.Music.UpdateThread.updateThread(this, middViewLayout, A31MusicModel.Current); |
| | | UI2.FuntionControlView.Music.UpdateThread.updateCurrMusicThread(this, middViewLayout, A31MusicModel.Current); |
| | | } |
| | | |
| | | } |
| | |
| | | using Shared; |
| | | using Shared.IO; |
| | | using System.Net; |
| | | using HDL_ON.Entity; |
| | | |
| | | namespace HDL_ON.UI.Music |
| | | { |
| | | public class MusicMain : FrameLayout |
| | |
| | | /// <summary> |
| | | /// 显示加载界面 |
| | | /// </summary> |
| | | public static Loading loading = new Loading(); |
| | | public static Loading loading = new Loading(); |
| | | /// <summary> |
| | | /// 定义全局对象 |
| | | /// </summary> |
| | | VerticalRefreshLayout verticalRefresh; |
| | | /// <summary> |
| | | /// 为了音乐刷新状态定义全局对象 |
| | | /// </summary> |
| | | MusicView musicView = new MusicView(); |
| | | public void Show() |
| | | { |
| | | |
| | | #region 界面布局 |
| | | this.BackgroundColor = MusicColor.ViewColor; |
| | | var topView = new TopView(); |
| | | this.AddChidren(topView.TopFLayoutView()); |
| | | topView.topNameBtn.TextID =StringId.a31Music; |
| | | topView.topNameBtn.TextID = StringId.a31Music; |
| | | topView.clickBackBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | RemoveFromParent(); |
| | |
| | | |
| | | verticalRefresh.BeginHeaderRefreshingAction += () => |
| | | { |
| | | SeachMusic(false); |
| | | |
| | | SeachMusic(); |
| | | verticalRefresh.EndHeaderRefreshing(); |
| | | |
| | | }; |
| | | this.AddChidren(loading); |
| | | SeachMusic(); |
| | | |
| | | if (A31MusicModel.A31MusicModelList.Count == 0) |
| | | { |
| | | SeachMusic(true); |
| | | } |
| | | else |
| | | { |
| | | clearA31Threads(); |
| | | //verticalRefresh.RemoveAll(); |
| | | for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) |
| | | { |
| | | var a31player = A31MusicModel.A31MusicModelList[i]; |
| | | ///这个状态是之前保存的,加载完成后要标记为不在线,后面再读取正确的状态 |
| | | if (!a31player.IsCanShow) |
| | | { |
| | | continue; |
| | | } |
| | | if (A31MusicModel.A31MusicModelList.Count - 1 == i) |
| | | { |
| | | a31player.IsEnd = true; |
| | | } |
| | | else |
| | | { |
| | | a31player.IsEnd = false; |
| | | } |
| | | ///加载界面时默认不在线 |
| | | ///这里标记是为了不读取不在线播放器状态 |
| | | a31player.IsOnLine = false; |
| | | MusicListView(a31player); |
| | | } |
| | | ///读取正确的信息,包括IP和端口及名称 |
| | | SendMethod.Seach((obj) => |
| | | { |
| | | try |
| | | { |
| | | if (obj == null) |
| | | { |
| | | ///这里要读取主从关系 |
| | | readServerOrClientMode(); |
| | | A31MusicModel.Save(); |
| | | return; |
| | | } |
| | | var a31MusicModel = A31MusicModel.A31MusicModelList.Find((music) => music.UniqueDeviceName == obj.UniqueDeviceName); |
| | | if (a31MusicModel != null) |
| | | { |
| | | a31MusicModel.IPAddress = obj.IPAddress; |
| | | a31MusicModel.Port = obj.Port; |
| | | a31MusicModel.Name = obj.Name; |
| | | a31MusicModel.IsCanShow = true; |
| | | a31MusicModel.IsOnLine = true; |
| | | } |
| | | } |
| | | catch (Exception e) { MainPage.Log(e.Message); } |
| | | }); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 刷新播放器列表 |
| | | /// </summary> |
| | | /// <param name="Yes">是否显示刷新图标</param> |
| | | void SeachMusic(bool Yes = false) |
| | | void SeachMusic() |
| | | { |
| | | for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | var a31player = A31MusicModel.A31MusicModelList[i]; |
| | | a31player.IsCanShow = false; |
| | | a31player.IsOnLine = false; |
| | | } |
| | | if (Yes) |
| | | { |
| | | //为了第一次进来log一下; |
| | | loading.Start(); |
| | | } |
| | | SendMethod.Seach((obj) => |
| | | { |
| | | if (obj == null) |
| | | { |
| | | readServerOrClientMode(); |
| | | A31MusicModel.Save(); |
| | | if (!Yes) |
| | | { |
| | | ///等待跑完在关闭 |
| | | verticalRefresh.EndHeaderRefreshing(); |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (Yes) |
| | | { |
| | | //为了第一次进来log一下; |
| | | loading.Hide(); |
| | | } |
| | | verticalRefresh.RemoveAll(); |
| | | for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) |
| | | { |
| | | var a31player = A31MusicModel.A31MusicModelList[i]; |
| | | //这个状态是之前保存的,加载完成后要标记为不在线,后面再读取正确的状态 |
| | | if (!a31player.IsCanShow) |
| | | { |
| | | continue; |
| | | } |
| | | if (A31MusicModel.A31MusicModelList.Count - 1 == i) |
| | | { |
| | | a31player.IsEnd = true; |
| | | } |
| | | else |
| | | { |
| | | a31player.IsEnd = false; |
| | | } |
| | | MusicListView(a31player); |
| | | } |
| | | //A31MusicModel.ReadMusicStates(); |
| | | verticalRefresh.RemoveAll(); |
| | | |
| | | }); |
| | | return; |
| | | } |
| | | var a31MusicModel = A31MusicModel.A31MusicModelList.Find((music) => { return music.UniqueDeviceName == obj.UniqueDeviceName; }); |
| | | if (a31MusicModel == null) |
| | | var musicListFunction = SendMethod.sendMethod.GetMusicList; |
| | | for (int i = 0; i < musicListFunction.Count; i++) |
| | | { |
| | | //不是我们支持的品牌不支持 |
| | | if (obj.Name != null) |
| | | var function = musicListFunction[i]; |
| | | var music = A31MusicModel.A31MusicModelList.Find((music) => music.functionMusic.deviceId == function.deviceId); |
| | | if (music == null) |
| | | { |
| | | obj.sid = "030101123456780909020123AABB" + obj.UniqueDeviceName; |
| | | A31MusicModel.A31MusicModelList.Add(obj); |
| | | A31MusicModel.A31MusicModelList.Add(new A31MusicModel { functionMusic = function }); |
| | | } |
| | | else |
| | | { |
| | | music.functionMusic = function; |
| | | } |
| | | } |
| | | else |
| | | |
| | | |
| | | for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) |
| | | { |
| | | a31MusicModel.IPAddress = obj.IPAddress; |
| | | a31MusicModel.Port = obj.Port; |
| | | a31MusicModel.Name = obj.Name; |
| | | a31MusicModel.IsCanShow = true; |
| | | a31MusicModel.IsOnLine = true; |
| | | var a31player = A31MusicModel.A31MusicModelList[i]; |
| | | MusicListView(a31player); |
| | | } |
| | | |
| | | }); |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 显示音乐列表的方法 |
| | | /// </summary> |
| | | void MusicListView(A31MusicModel a31player) |
| | | void MusicListView(A31MusicModel player) |
| | | { |
| | | MusicView musicView = new MusicView(); |
| | | musicView.View(verticalRefresh); |
| | | musicView.singerBtn.Text = a31player.A31PlayStatus.Artist; |
| | | musicView.songNameBtn.Text = a31player.A31PlayStatus.Title; |
| | | musicView.musicNameBtn.Text = new View.DialogView { }.NamePlayer(a31player); |
| | | if (a31player.IsEnd) |
| | | { |
| | | musicView.muiscFl.Height = Application.GetRealHeight(12 + 139 + 12); |
| | | } |
| | | musicView.singerBtn.Text = player.functionMusic.GetAttrState("song_name"); |
| | | musicView.songNameBtn.Text = player.functionMusic.GetAttrState("song_name"); |
| | | musicView.musicNameBtn.Text = player.functionMusic.name; |
| | | //if (player.IsEnd) |
| | | //{ |
| | | // musicView.muiscFl.Height = Application.GetRealHeight(12 + 139 + 12); |
| | | //} |
| | | |
| | | musicView.collectIconBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | musicView.collectIconBtn.IsSelected = !musicView.collectIconBtn.IsSelected; |
| | | if (a31player.ServerClientType == 1) |
| | | if (musicView.collectIconBtn.IsSelected) |
| | | { |
| | | if (musicView.collectIconBtn.IsSelected) |
| | | { |
| | | a31player.MainPlayCollection = true; |
| | | } |
| | | else |
| | | { |
| | | a31player.MainPlayCollection = false; |
| | | } |
| | | player.functionMusic.collect = true; |
| | | } |
| | | else |
| | | { |
| | | if (musicView.collectIconBtn.IsSelected) |
| | | { |
| | | a31player.collect = true; |
| | | } |
| | | else |
| | | { |
| | | a31player.collect = false; |
| | | } |
| | | player.functionMusic.collect = false; |
| | | } |
| | | A31MusicModel.Save(); |
| | | }; |
| | | |
| | | EventHandler<MouseEventArgs> clickMergence = (sender, e) => |
| | | { |
| | | if (a31player.ServerClientType == 0) |
| | | { |
| | | new View.DialogView { }.PlayMergence(a31player); |
| | | } |
| | | else if (a31player.ServerClientType == 1) |
| | | { |
| | | new View.DialogView { }.DetachPlayMergence(a31player); |
| | | |
| | | } |
| | | //if (player.ServerClientType == 0) |
| | | //{ |
| | | // new View.DialogView { }.PlayMergence(player); |
| | | //} |
| | | //else if (player.ServerClientType == 1) |
| | | //{ |
| | | // new View.DialogView { }.DetachPlayMergence(player); |
| | | //} |
| | | }; |
| | | musicView.mergeBjBtn.MouseUpEventHandler += clickMergence; |
| | | musicView.mergeBtn.MouseUpEventHandler += clickMergence; |
| | |
| | | |
| | | EventHandler<MouseEventArgs> clickPlayView = (sender, e) => |
| | | { |
| | | A31MusicModel.Current = a31player;//当前播放器 |
| | | |
| | | A31MusicModel.Current = player; |
| | | var a31PlayMusicPage = new A31PlayMusicPage(); |
| | | MainPage.BasePageView.AddChidren(a31PlayMusicPage); |
| | | a31PlayMusicPage.Show(); |
| | |
| | | musicView.prevBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | musicView.prevBtn.IsSelected = true; |
| | | SendMethod.Previous(a31player); |
| | | player.functionMusic.SetAttrState("song_step", "up"); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("song_step", "up"); |
| | | SendMethod.sendMethod.SendControlCommand(player.functionMusic, dic); |
| | | }; |
| | | musicView.prevBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | |
| | | ///暂停/播放点击事件 |
| | | musicView.playBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | string status = "off"; |
| | | if (musicView.playBtn.IsSelected) |
| | | { |
| | | musicView.playBtn.IsSelected = false; |
| | | SendMethod.Pause(a31player); |
| | | a31player.A31PlayStatus.status = "pause"; |
| | | status = "off"; |
| | | } |
| | | else |
| | | { |
| | | musicView.playBtn.IsSelected = true; |
| | | SendMethod.Play(a31player); |
| | | a31player.A31PlayStatus.status = "play"; |
| | | status = "on"; |
| | | } |
| | | player.functionMusic.SetAttrState("on_off", status); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("on_off", status); |
| | | SendMethod.sendMethod.SendControlCommand(player.functionMusic, dic); |
| | | }; |
| | | ///下一曲点击事件 |
| | | musicView.nextBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | musicView.nextBtn.IsSelected = true; |
| | | SendMethod.Next(a31player); |
| | | player.functionMusic.SetAttrState("song_step", "down"); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("song_step", "down"); |
| | | SendMethod.sendMethod.SendControlCommand(player.functionMusic, dic); |
| | | }; |
| | | musicView.nextBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | |
| | | while (true) |
| | | { |
| | | System.Threading.Thread.Sleep(1000); |
| | | if (!a31player.IsOnLine) |
| | | if (!player.functionMusic.online) |
| | | { |
| | | ///不在线不读状态 |
| | | continue; |
| | | } |
| | | SendMethod.ReadStatus(a31player); |
| | | //SendMethod.ReadStatus(player); |
| | | SendMethod.sendMethod.RefreshDeviceStatus(player.functionMusic,new List<string> { player.functionMusic.deviceId }); |
| | | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | musicView.singerBtn.Text = a31player.A31PlayStatus.Artist; |
| | | musicView.songNameBtn.Text = a31player.A31PlayStatus.Title; |
| | | musicView.musicNameBtn.Text = new View.DialogView { }.NamePlayer(a31player); |
| | | if (a31player.A31PlayStatus.status == "play") |
| | | musicView.singerBtn.Text = player.functionMusic.GetAttrState("song_name"); |
| | | musicView.songNameBtn.Text = player.functionMusic.GetAttrState("song_name"); |
| | | musicView.musicNameBtn.Text = player.functionMusic.name; |
| | | if (player.A31PlayStatus.status == "play") |
| | | { |
| | | musicView.playBtn.IsSelected = true; |
| | | } |
| | |
| | | { |
| | | musicView.playBtn.IsSelected = false; |
| | | } |
| | | musicView.regionBtn.Text = a31player.GetRoomListName(); |
| | | if (a31player.ServerClientType == 1) |
| | | musicView.regionBtn.Text = player.functionMusic.GetRoomListName(); |
| | | if (player.ServerClientType == 1) |
| | | { |
| | | if (a31player.MainPlayCollection) |
| | | if (player.MainPlayCollection) |
| | | { |
| | | musicView.collectIconBtn.IsSelected = true; |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | if (a31player.collect) |
| | | if (player.functionMusic.collect) |
| | | { |
| | | musicView.collectIconBtn.IsSelected = true; |
| | | } |
| | |
| | | musicThread.Start(); |
| | | threadLists.Add(musicThread); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 读取主从关系 |
| | | ///指定刷新界面 |
| | | /// </summary> |
| | | void readServerOrClientMode() |
| | | /// <param name="strView">判断字符</param> |
| | | public void RefreshView(string strView) |
| | | { |
| | | try |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) |
| | | try |
| | | { |
| | | var a31player = A31MusicModel.A31MusicModelList[i]; |
| | | if (!a31player.IsOnLine) |
| | | |
| | | for (int i = MainPage.BasePageView.ChildrenCount - 1; 0 <= i; i--) |
| | | { |
| | | continue; |
| | | } |
| | | try |
| | | { |
| | | a31player.ServerClientType = 0; |
| | | var result = SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList"); |
| | | if (result == null && result == "Failed") |
| | | var view = MainPage.BasePageView.GetChildren(i); |
| | | if (strView == view.Tag.ToString()) |
| | | { |
| | | result = SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList"); |
| | | } |
| | | if (result != null && result != "Failed") |
| | | { |
| | | a31player.Slave = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | var d = e.Message; |
| | | } |
| | | } |
| | | |
| | | //分析主从关系 |
| | | for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) |
| | | { |
| | | var a31player = A31MusicModel.A31MusicModelList[i]; |
| | | if (!a31player.IsOnLine) |
| | | { |
| | | continue; |
| | | } |
| | | try |
| | | { |
| | | if (a31player.Slave != null && "0" != a31player.Slave.slaves) |
| | | { |
| | | a31player.ServerClientType = 1;//主的 |
| | | string str = a31player.Name; |
| | | for (int j = 0; j < a31player.Slave.slave_list.Count; j++) |
| | | if (view.GetType() == typeof(MusicMain)) |
| | | { |
| | | |
| | | var slave = a31player.Slave.slave_list[j]; |
| | | str = str + "+" + slave.name; |
| | | var tempA31Player = A31MusicModel.A31MusicModelList.Find((obj) => slave.uuid.Replace("uuid:", "") == obj.UniqueDeviceName); |
| | | if (tempA31Player == null) |
| | | { |
| | | A31MusicModel.A31MusicModelList.Add(new A31MusicModel |
| | | { |
| | | sid = "030101123456780909020123AABB" + slave.uuid.Replace("uuid:", ""), |
| | | ServerClientType = -1,//从的 |
| | | IPAddress = slave.ip, |
| | | MainPlayIP = a31player.IPAddress, |
| | | UniqueDeviceName = slave.uuid.Replace("uuid:", ""), |
| | | Name = slave.name, |
| | | IsCanShow = false, |
| | | IsOnLine = false,//true作用为了读取从播放器的音量 |
| | | }); |
| | | } |
| | | //如果找到就更新为从的 |
| | | else |
| | | { |
| | | tempA31Player.ServerClientType = -1;//从的 |
| | | tempA31Player.IPAddress = slave.ip; |
| | | tempA31Player.MainPlayIP = a31player.IPAddress; |
| | | tempA31Player.Name = slave.name; |
| | | tempA31Player.UniqueDeviceName = slave.uuid.Replace("uuid:", ""); |
| | | tempA31Player.IsCanShow = false; |
| | | tempA31Player.IsOnLine = false;//true作用为了读取从播放器的音量 |
| | | |
| | | } |
| | | //musicView.singerBtn.Text = player.A31PlayStatus.Artist; |
| | | //musicView.songNameBtn.Text = player.A31PlayStatus.Title; |
| | | //musicView.musicNameBtn.Text = new View.DialogView { }.NamePlayer(player); |
| | | //if (player.A31PlayStatus.status == "play") |
| | | //{ |
| | | // musicView.playBtn.IsSelected = true; |
| | | //} |
| | | //else |
| | | //{ |
| | | // musicView.playBtn.IsSelected = false; |
| | | //} |
| | | //musicView.regionBtn.Text = player.GetRoomListName(); |
| | | //if (player.ServerClientType == 1) |
| | | //{ |
| | | // if (player.MainPlayCollection) |
| | | // { |
| | | // musicView.collectIconBtn.IsSelected = true; |
| | | // } |
| | | // else |
| | | // { |
| | | // musicView.collectIconBtn.IsSelected = false; |
| | | // } |
| | | //} |
| | | //else |
| | | //{ |
| | | // if (player.collect) |
| | | // { |
| | | // musicView.collectIconBtn.IsSelected = true; |
| | | // } |
| | | // else |
| | | // { |
| | | // musicView.collectIconBtn.IsSelected = false; |
| | | // } |
| | | //} |
| | | } |
| | | a31player.MainPlayName = str; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | var ss = e.Message; |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch { } |
| | | catch { } |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | using System.Net.Sockets; |
| | | using System.Security; |
| | | using System.Text; |
| | | using HDL_ON.DAL.Server; |
| | | using HDL_ON.Entity; |
| | | using Shared; |
| | | |
| | | namespace HDL_ON.UI.Music |
| | | { |
| | | public class SendMethod |
| | | { |
| | | private static SendMethod m_sendMethod=null; |
| | | public static SendMethod sendMethod |
| | | { |
| | | get |
| | | { |
| | | if (m_sendMethod == null) |
| | | { |
| | | m_sendMethod = new SendMethod(); |
| | | } |
| | | return m_sendMethod; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | ///搜索A31音乐播放器 |
| | | /// </summary> |
| | |
| | | a31MusicModel.A31PlayStatus.loop = se.SearchForTextOfTag("LoopMode"); |
| | | a31MusicModel.A31PlayStatus.Source = se.SearchForTextOfTag("PlayMedium"); |
| | | a31MusicModel.A31PlayStatus.playSource = se.SearchForTextOfTag("TrackSource"); |
| | | a31MusicModel.A31PlayStatus.TrackURL = se.SearchForTextOfTag("TrackURI").Replace("&", "&amp;"); |
| | | a31MusicModel.A31PlayStatus.TrackURL = se.SearchForTextOfTag("TrackURI").Replace("&", "&amp;"); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | |
| | | #region 更新其他界面音乐状态 |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | a31MusicModel.trait_on_off.curValue = a31MusicModel.A31PlayStatus.status == "play" ? "on" : "off"; |
| | | //a31MusicModel.trait_on_off.curValue = a31MusicModel.A31PlayStatus.status == "play" ? "on" : "off"; |
| | | //Console.WriteLine($"music : {a31MusicModel.sid} : {a31MusicModel.on_off}"); |
| | | HomePage.UpdataFunctionStates(a31MusicModel); |
| | | HomePage.UpdataFunctionStates(a31MusicModel.functionMusic); |
| | | foreach (var e in A31MusicModel.A31MusicModelList) |
| | | { |
| | | RoomPage.UpdataStates(a31MusicModel); |
| | | RoomPage.UpdataStates(e.functionMusic); |
| | | } |
| | | }); |
| | | #endregion |
| | |
| | | /// <param name="volume">Volume.</param> |
| | | public static void ControlVolume(int volume, A31MusicModel a31player) |
| | | { |
| | | System.Threading.Tasks.Task.Run(() => { |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | A31MusicModel.ProgressDateTime = DateTime.Now; |
| | | try |
| | | { |
| | |
| | | /// <summary> |
| | | /// 获取USb的列表 |
| | | /// </summary> |
| | | public static List<MusicInfo> GetUsbList(A31MusicModel a31player) |
| | | public static List<Songs> GetUsbList(A31MusicModel a31player) |
| | | { |
| | | var musicInfoList = new List<MusicInfo>(); |
| | | var musicInfoList = new List<Songs>(); |
| | | musicInfoList.Clear(); |
| | | var usbString = GetUSBPlayList(a31player); |
| | | if (usbString == null) |
| | |
| | | |
| | | foreach (SecurityElement track in SecurityElement.FromString(se.Text).SearchForChildByTag("Tracks").Children) |
| | | { |
| | | MusicInfo musicInfo = new MusicInfo(); |
| | | Songs musicInfo = new Songs(); |
| | | musicInfo.URL = track.SearchForTextOfTag("URL").Replace("&", "&amp;"); |
| | | var metadata = track.SearchForTextOfTag("Metadata").Replace("&", "&"); |
| | | var item = SecurityElement.FromString(metadata).SearchForChildByTag("item"); |
| | | musicInfo.Title = item.SearchForTextOfTag("dc:title").Replace("&", "&amp;"); |
| | | musicInfo.Title = item.SearchForTextOfTag("dc:title").Replace("&", "&amp;"); |
| | | musicInfo.Artist = item.SearchForTextOfTag("upnp:artist").Replace("&", "&amp;"); |
| | | musicInfo.Album = item.SearchForTextOfTag("upnp:album").Replace("&", "&amp;"); |
| | | musicInfo.Duration = item.SearchForTextOfTag("res"); |
| | |
| | | /// <summary> |
| | | /// 获取当前播放的列表 |
| | | /// </summary> |
| | | public static string GetCurrentPlayList(A31MusicModel a31player) |
| | | public static string GetCurrentPlayList(A31MusicModel a31player) |
| | | { |
| | | System.Text.StringBuilder getPlayList = new System.Text.StringBuilder(); |
| | | getPlayList.AppendLine("<?xml version=\"1.0\"encoding=\"utf-8\"?>"); |
| | |
| | | /// <param name="musicInfo">播放音乐</param> |
| | | /// <param name="listName">列表名称</param> |
| | | /// <param name="musicList">推送列表(默认推50首)</param> |
| | | public static void PushList(MusicInfo musicInfo, string listName, List<MusicInfo> musicList, A31MusicModel a31player,string musicSource) |
| | | public static void PushList(MusicInfo musicInfo, string listName, List<MusicInfo> musicList, A31MusicModel a31player, string musicSource) |
| | | { |
| | | |
| | | //最大发送的条数 |
| | |
| | | |
| | | sb.AppendLine("&lt;dc:title&gt;" + tempMusicInfo.Title + "&lt;/dc:title&gt;"); |
| | | sb.AppendLine("&lt;dc:creator&gt;DJ Sanny J&lt;/dc:creator&gt;"); |
| | | if (musicSource== "我的列表") { |
| | | if (musicSource == "我的列表") |
| | | { |
| | | sb.AppendLine("&lt;upnp:artist&gt;" + listName + "&lt;/upnp:artist&gt;"); |
| | | } |
| | | else { |
| | | else |
| | | { |
| | | sb.AppendLine("&lt;upnp:artist&gt;" + tempMusicInfo.Artist + "&lt;/upnp:artist&gt;"); |
| | | } |
| | | sb.AppendLine("&lt;upnp:album&gt;" + tempMusicInfo.Album + "&lt;/upnp:album&gt;"); |
| | |
| | | Play(a31player.IPAddress, a31player.Port, playString.ToString()); |
| | | } |
| | | |
| | | static void SendMusicLists(string ip, int port, string soapAction, string listInfo) |
| | | static void SendMusicLists(string ip, int port, string soapAction, string listInfo) |
| | | { |
| | | System.Net.WebClient webClient = new System.Net.WebClient(); |
| | | webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#" + soapAction + "\""); |
| | |
| | | byte[] recevieBytes = webClient.UploadData(new Uri("http://" + ip + ":" + port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes(listInfo)); |
| | | var s = System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length); |
| | | } |
| | | catch(Exception e) |
| | | catch (Exception e) |
| | | { |
| | | var d = e.Message; |
| | | } |
| | | } |
| | | |
| | | static void Play(string ip, int port, string info) |
| | | static void Play(string ip, int port, string info) |
| | | { |
| | | System.Net.WebClient webClient = new System.Net.WebClient(); |
| | | webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#PlayQueueWithIndex\""); |
| | |
| | | public string creator = string.Empty; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取音乐列表 |
| | | /// </summary> |
| | | public List<Function> GetMusicList |
| | | { |
| | | get |
| | | { |
| | | return FunctionList.List.GetMusicList(); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 发送控制命令 |
| | | /// </summary> |
| | | /// <param name="function">当前设备</param> |
| | | /// <param name="dic">发送控制数据</param> |
| | | public void SendControlCommand(Function function, Dictionary<string, string> dic) |
| | | { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | DriverLayer.Control.Ins.SendWriteCommand(function, dic); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 刷新设备状态 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public void RefreshDeviceStatus(Function music, List<string> functionIds) |
| | | { |
| | | try |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); |
| | | d.Add("deviceIds", functionIds); |
| | | var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_RefreshDeviceStatus); |
| | | if (responsePackNew.Code != "0") |
| | | { |
| | | return; |
| | | } |
| | | //数据返序列化为Function对象 |
| | | var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data.ToString()); |
| | | var function = Newtonsoft.Json.JsonConvert.DeserializeObject<Function>(str); |
| | | if (function == null) |
| | | { |
| | | return; |
| | | } |
| | | music.name = function.name; |
| | | music.sid = function.sid; |
| | | music.spk = function.spk; |
| | | music.status = function.status; |
| | | music.roomIds = function.roomIds; |
| | | music.attributes = function.attributes; |
| | | } |
| | | catch { } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取音乐列表 |
| | | /// </summary> |
| | | /// <param name="music"></param> |
| | | /// <returns></returns> |
| | | public void GetPalyList(Function music) |
| | | { |
| | | try |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); |
| | | d.Add("deviceIds", new List<string> { music.deviceId }); |
| | | var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_PlayerList); |
| | | if (responsePackNew.Code != "0") |
| | | { |
| | | return; |
| | | } |
| | | //数据返序列化为Function对象 |
| | | var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data.ToString()); |
| | | var palyLists = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PalyListInfo>>(str); |
| | | if (palyLists == null) |
| | | { |
| | | palyLists =new List<PalyListInfo>(); |
| | | } |
| | | A31MusicModel.Current.palyListInfos = palyLists; |
| | | } |
| | | catch |
| | | { |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | ///请求服务器(与住宅有关:例如;homeId) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ResponsePackNew RequestServerhomeId(object o, string api_Url, int mTimeout = 5) |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(o); |
| | | return HttpUtil.RequestHttpsPostFroHome(api_Url, requestJson, mTimeout); |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | /// <param name="frame">当前界面</param> |
| | | /// <param name="middViewLayout">每一条音乐的主控件</param> |
| | | /// <param name="a31MusicModel">点前播放器</param> |
| | | public static void updateThread(FrameLayout frame, VerticalRefreshLayout middViewLayout, A31MusicModel a31MusicModel) |
| | | public static void updateCurrMusicThread(FrameLayout frame, VerticalRefreshLayout middViewLayout, A31MusicModel a31MusicModel) |
| | | { |
| | | System.Threading.Thread updateSelectedMusicThread = new System.Threading.Thread(() => |
| | | { |
| | |
| | | /// <param name="listName">播放列表名</param> |
| | | /// <param name="musicList">播放音乐列表</param> |
| | | /// <param name="a31MusicModel">音乐播放器</param> |
| | | public static void playMusuc(VerticalRefreshLayout middViewLayout, string musicSource, string listName,List<MusicInfo> musicList, A31MusicModel a31MusicModel, FrameLayout frame=null) |
| | | public static void PlayMusicClick(VerticalRefreshLayout middViewLayout, string musicSource, string listName,List<Songs> musicList, FrameLayout frame=null) |
| | | { |
| | | for (int i = 0; i < musicList.Count; i++) |
| | | { |
| | |
| | | if (songView.loveIcon.IsSelected) |
| | | { |
| | | ///查找音乐是否存在在列表 |
| | | var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL); |
| | | var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.name == songs.name); |
| | | if (music1 == null) |
| | | { |
| | | ///没有存在就添加 |
| | |
| | | else |
| | | { |
| | | ///查找音乐是否存在在列表 |
| | | var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL); |
| | | var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.name == songs.name); |
| | | if (music1 != null) |
| | | { |
| | | ///存在就删除 |
| | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | //移除界面 |
| | | A31MusicModel.Current.A31PlayStatus.Title = songView.songBtn.Text; |
| | | if (frame != null) |
| | | { |
| | | frame.RemoveFromParent(); |
| | | } |
| | | MainPage.BasePageView.RemoveViewByTag("Music"); |
| | | |
| | | A31MusicModel.Current.functionMusic.SetAttrState("song_name", songView.songBtn.Text); |
| | | A31MusicModel.Current.functionMusic.SetAttrState("playlist_name", listName); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("song_name", songView.songBtn.Text); |
| | | dic.Add("playlist_name", listName); |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | if (musicSource == "本地音乐"|| musicSource == "我的最爱"|| musicSource == "我的列表") |
| | | { |
| | | SendMethod.PushList(songs, listName, musicList, a31MusicModel,musicSource); |
| | | } |
| | | else if (musicSource == "USB"|| musicSource == "播放列表") |
| | | { |
| | | SendMethod.ListMusicPlay(listName, songView.clickBtn.Tag, A31MusicModel.Current); |
| | | } |
| | | SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | }); |
| | | }); |
| | | }); |
| | |
| | | ///弹窗文件夹列表界面 |
| | | /// </summary> |
| | | /// <param name="musicInfo"></param> |
| | | public void FieListView(MusicInfo musicInfo) |
| | | public void FieListView(Songs musicInfo) |
| | | { |
| | | #region |
| | | //主控件 |
| | |
| | | FileView(dialog, verticalScrolViewLayout, musicInfo); |
| | | |
| | | } |
| | | void FileView(Dialog dialog, VerticalScrolViewLayout verticalScrolViewLayout, MusicInfo musicInfo) |
| | | void FileView(Dialog dialog, VerticalScrolViewLayout verticalScrolViewLayout, Songs musicInfo) |
| | | { |
| | | verticalScrolViewLayout.RemoveAll(); |
| | | for (int i = 0; i < A31MusicModel.Current.FileLists.Count; i++) |
| | |
| | | EventHandler<MouseEventArgs> click = (sender, e) => |
| | | { |
| | | |
| | | if (null == list.MusicInfoList.Find((music) => music.URL == musicInfo.URL)) |
| | | if (null == list.MusicInfoList.Find((music) => music.name == musicInfo.name)) |
| | | { |
| | | list.MusicInfoList.Add(musicInfo); |
| | | A31MusicModel.Save(); |
| | |
| | | for (int j = 0; j < A31MusicModel.A31MusicModelList.Count; j++) |
| | | { |
| | | var music = A31MusicModel.A31MusicModelList[j]; |
| | | if(music.collect && !mainModelCollection) |
| | | if(music.functionMusic.collect && !mainModelCollection) |
| | | { |
| | | mainModelCollection = true; |
| | | } |
| | |
| | | }; |
| | | public void frameLayout(FrameLayout frame,A31MusicModel a31MusicModel) |
| | | { |
| | | switch (a31MusicModel.A31PlayStatus.loop) |
| | | var mode= a31MusicModel.functionMusic.GetAttrState("mode"); |
| | | switch (mode) |
| | | { |
| | | //0列表循环,1单曲循环,2随机播放; |
| | | case "0": |
| | | case "list_cycle": |
| | | orderIconBtn.UnSelectedImagePath = "MusicIcon/list.png"; |
| | | orderTxetBtn.Text = Language.StringByID(StringId.listMode); |
| | | break; |
| | | |
| | | case "1": |
| | | case "single_cycle/order": |
| | | orderIconBtn.UnSelectedImagePath = "MusicIcon/single.png"; |
| | | orderTxetBtn.Text = Language.StringByID(StringId.singleMode); |
| | | |
| | | break; |
| | | case "2": |
| | | case "random": |
| | | orderIconBtn.UnSelectedImagePath = "MusicIcon/random.png"; |
| | | orderTxetBtn.Text = Language.StringByID(StringId.randomMode); |
| | | break; |