| | |
| | | using com.hdl.on; |
| | | using System.Collections.Generic; |
| | | using System.Security; |
| | | using HDL_ON.UI.UI2.FuntionControlView.Music; |
| | | |
| | | namespace HDL_ON.UI.Music |
| | | { |
| | |
| | | /// new布局界面 |
| | | /// </summary> |
| | | View.PlayView playView = new View.PlayView(); |
| | | TopView topView; |
| | | |
| | | |
| | | public void Show() |
| | | { |
| | |
| | | timerUpdateStatus(); |
| | | #region ---界面布局--- |
| | | this.BackgroundColor = MusicColor.ViewColor; |
| | | var topView = new TopView(); |
| | | topView = new TopView(); |
| | | topView.setBtn.Visible = true; |
| | | this.AddChidren(topView.TopFLayoutView()); |
| | | topView.topNameBtn.Text = A31MusicModel.Current.Name; |
| | | topView.clickBackBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | RemoveFromParent(); |
| | |
| | | } |
| | | |
| | | }; |
| | | //快进滑动弹起事件; |
| | | playView.diyArcSeekBar.OnStopTrackingTouchEvent+= (sender, e) => |
| | | { |
| | | //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); |
| | | |
| | | //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) |
| | | switch (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode)) |
| | | { |
| | | //list_cycle列表循环,single_cycle单曲循环,random随机播放; |
| | | case "list_cycle": |
| | | modeValueString="single_cycle"; |
| | | case ValueProperty.list_cycle: |
| | | modeValueString=ValueProperty.single_cycle; |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; |
| | | msg += Language.StringByID(StringId.singleMode); |
| | | break; |
| | | |
| | | case "single_cycle": |
| | | modeValueString = "random"; |
| | | case ValueProperty.single_cycle: |
| | | modeValueString =ValueProperty.random; |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; |
| | | msg += Language.StringByID(StringId.randomMode); |
| | | break; |
| | | case "random": |
| | | modeValueString = "list_cycle"; |
| | | case ValueProperty.random: |
| | | modeValueString = ValueProperty.list_cycle; |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; |
| | | msg += Language.StringByID(StringId.listMode); |
| | | break; |
| | | } |
| | | A31MusicModel.Current.functionMusic.SetAttrState("mode", modeValueString); |
| | | A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.mode, modeValueString); |
| | | new PublicAssmebly().TipMsgAutoClose(msg, false,1000); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("mode",modeValueString); |
| | | SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic,dic); |
| | | dic.Add(KeyProperty.mode,modeValueString); |
| | | SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic,dic); |
| | | }; |
| | | ///添加喜爱点击事件; |
| | | playView.loveBtn.MouseUpEventHandler += (sender, e) => |
| | |
| | | |
| | | 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 (playView.loveBtn.IsSelected) |
| | | { |
| | | if (null == A31MusicModel.Current.LoveRadioInfoList.Find((musicInfo) => |
| | | { |
| | | return name == musicInfo.name; |
| | | })) |
| | | { |
| | | A31MusicModel.Current.LoveRadioInfoList.Add(new Songs { name = name, time = songTime}); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | A31MusicModel.Current.LoveRadioInfoList.RemoveAll((musicInfo) => |
| | | { |
| | | return name == musicInfo.name; |
| | | }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | playView.loveBtn.IsSelected = !playView.loveBtn.IsSelected; |
| | | if (playView.loveBtn.IsSelected) |
| | | { |
| | |
| | | //也要加歌手名判断 |
| | | return musicInfo.name == name; |
| | | }); |
| | | } |
| | | |
| | | } |
| | | A31MusicModel.Save(); |
| | | }; |
| | |
| | | ///音量图标点击事件 |
| | | playView.volIconBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | if (A31MusicModel.Current.ServerClientType == 1 && A31MusicModel.Current.Slave.slave_list.Count != 0) |
| | | { ///主播放器 |
| | | var volumeView = new View.DialogView { }; |
| | | volumeView.PlayerVolumeView(A31MusicModel.Current); |
| | | volumeView.UpdateVolume(); |
| | | |
| | | } |
| | | }; |
| | | ///音量进度条点击事件 |
| | | int startVolume =0;//之前的音量 |
| | |
| | | if (startVolume != e) |
| | | { |
| | | startVolume = e; |
| | | A31MusicModel.Current.functionMusic.SetAttrState("volume", startVolume); |
| | | A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.volume, startVolume); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("volume", startVolume.ToString()); |
| | | SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | dic.Add(KeyProperty.volume, startVolume.ToString()); |
| | | SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | |
| | | } |
| | | }; |
| | |
| | | { |
| | | playView.prevBtn.IsSelected = true; |
| | | |
| | | A31MusicModel.Current.functionMusic.SetAttrState("song_step", "down"); |
| | | A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.song_step,ValueProperty.down); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("song_step", "down"); |
| | | SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | dic.Add(KeyProperty.song_step, ValueProperty.down); |
| | | SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | |
| | | }; |
| | | playView.prevBtn.MouseUpEventHandler += (sender, e) => |
| | |
| | | if (playView.playBtn.IsSelected) |
| | | { |
| | | playView.playBtn.IsSelected = false; |
| | | status = "off"; |
| | | status = ValueProperty.off; |
| | | } |
| | | else |
| | | { |
| | | playView.playBtn.IsSelected = true; |
| | | status = "on"; |
| | | status = ValueProperty.on; |
| | | } |
| | | A31MusicModel.Current.functionMusic.SetAttrState("on_off", status); |
| | | A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.on_off, status); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("on_off", status); |
| | | SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | dic.Add(KeyProperty.on_off, status); |
| | | SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | }; |
| | | ///下一曲点击事件 |
| | | playView.nextBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | playView.nextBtn.IsSelected = true; |
| | | A31MusicModel.Current.functionMusic.SetAttrState("song_step", "down"); |
| | | A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.song_step,ValueProperty.down); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("song_step", "down"); |
| | | SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | dic.Add(KeyProperty.song_step, ValueProperty.down); |
| | | SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | }; |
| | | playView.nextBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | |
| | | ///物理按键的点击事件 |
| | | Volume.VolumeChange = (volume) => |
| | | { |
| | | if (Application.DeviceType == Device.Ios && A31MusicModel.Current.A31PlayStatus.Source == "BLUETOOTH") |
| | | if (Application.DeviceType == Device.Ios && A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.source) == "bluetooth") |
| | | { |
| | | return; |
| | | } |
| | |
| | | if (startVolume != volume) |
| | | { |
| | | startVolume = volume; |
| | | A31MusicModel.Current.functionMusic.SetAttrState("volume", startVolume); |
| | | A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.volume, startVolume); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("volume", startVolume.ToString()); |
| | | SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | dic.Add(KeyProperty.volume, startVolume.ToString()); |
| | | SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | } |
| | | |
| | | }; |
| | |
| | | { |
| | | try |
| | | { |
| | | |
| | | //更新总时间 |
| | | //总共有多少秒 |
| | | int totalSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState("song_time")); |
| | | int totalSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_time))/1000; |
| | | //分钟 |
| | | int totalMusicMinute = totalSecond / 60; |
| | | //秒钟 |
| | |
| | | string totalTime = (totalMusicMinute.ToString().Length < 2 ? "0" + totalMusicMinute.ToString() : totalMusicMinute.ToString()) + ":" + (totalMusicSecond.ToString().Length < 2 ? "0" + totalMusicSecond.ToString() : totalMusicSecond.ToString()); |
| | | playView.endTimeBtn.Text = totalTime; |
| | | |
| | | //topView.topNameBtn.Text = A31MusicModel.Current.Name; |
| | | topView.topNameBtn.Text = A31MusicModel.Current.functionMusic.name; |
| | | |
| | | switch (A31MusicModel.Current.functionMusic.GetAttrState("mode")) |
| | | switch (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode)) |
| | | { |
| | | case "list_cycle"://列表循环 |
| | | case ValueProperty.list_cycle://列表循环 |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; |
| | | break; |
| | | case "single_cycle"://单曲循环 |
| | | case ValueProperty.single_cycle://单曲循环 |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; |
| | | break; |
| | | case "random"://随机播放 |
| | | case ValueProperty.random://随机播放 |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; |
| | | break; |
| | | } |
| | |
| | | if (1000 < (DateTime.Now - A31MusicModel.ProgressDateTime).TotalMilliseconds) |
| | | { |
| | | //音量进度条; |
| | | playView.volSeekBar.Progress = int.Parse(A31MusicModel.Current.A31PlayStatus.vol); |
| | | playView.volSeekBar.Progress = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.volume)); |
| | | //显示当前音量值; |
| | | playView.volValueBtn.Text = A31MusicModel.Current.A31PlayStatus.vol + "%"; |
| | | playView.volValueBtn.Text = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.volume) + "%"; |
| | | } |
| | | //更新播放器音量给系统音量 |
| | | Volume.MusicVolume = playView.volSeekBar.Progress; |
| | | //当前播放音乐时间 |
| | | //按道理不会为空,GetAttrState("playing_time")值可能为空,强制转换int.Parse()会出现异常,不过也做了异常处理了 |
| | | int playSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState("playing_time"))+ (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; |
| | | int playSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playing_time))/1000+ (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.functionMusic.GetAttrState("on_off") == "on") |
| | | if (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on) |
| | | { |
| | | playView.playBtn.IsSelected = true; |
| | | //如果在播放,时间就不断变化 |
| | |
| | | playView.diyArcSeekBar.Progress = (int)(playSecond * 100.0 / totalSecond);//+1 |
| | | } |
| | | |
| | | Console.WriteLine("打印时间======"+playTime); |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | //停止播放 |
| | | playView.startTimeBtn.Text =playTime; |
| | | } |
| | | 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"); |
| | | playView.songNameTextView.Text = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name) == null ? "Unkown" : A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name); |
| | | playView.singerBtn.Text = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name) == null ? "Unkown" : A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name); |
| | | //更新源的界面 |
| | | // showSourcePage(); |
| | | } |
| | |
| | | void PlayListView(FrameLayout frameLayout, VerticalRefreshLayout verticalScrolViewLayout) |
| | | { |
| | | verticalScrolViewLayout.RemoveAll(); |
| | | var listName = A31MusicModel.Current.functionMusic.GetAttribute("playlist_name").ToString(); |
| | | var listName = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playlist_name); |
| | | var musicList = A31MusicModel.Current.GetSongList(listName); |
| | | UI2.FuntionControlView.Music.UpdateThread.PlayMusicClick(verticalScrolViewLayout,"播放列表", listName, musicList, frameLayout); |
| | | if (musicList.Count == 0) |
| | | { |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | try |
| | | { |
| | | A31MusicModel.Current.palyLists.Clear(); |
| | | if (A31MusicModel.Current.palyLists.Count == 0) |
| | | { |
| | | SendMethod.mMethod.GetPalyList(A31MusicModel.Current.functionMusic); |
| | | |
| | | } |
| | | } |
| | | catch |
| | | { |
| | | } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | musicList = A31MusicModel.Current.GetSongList(listName); |
| | | A31SongPlay.SongListView(verticalScrolViewLayout, musicList, listName, frameLayout); |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | A31SongPlay.SongListView(verticalScrolViewLayout, musicList, listName, frameLayout); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 定时更新当前播放音乐 |
| | | /// </summary> |
| | | void UpdateSelectedMusic(FrameLayout frameLayout, VerticalRefreshLayout middViewLayout) |
| | | { |
| | | UI2.FuntionControlView.Music.UpdateThread.updateCurrMusicThread(frameLayout, middViewLayout, A31MusicModel.Current); |
| | | UpdateThread.updateCurrMusicThread(frameLayout, middViewLayout, A31MusicModel.Current); |
| | | } |
| | | |
| | | } |