| | |
| | | ///加载播放音乐界面的控件方法 |
| | | playView.viewFrameLayout(middLayout); |
| | | #endregion |
| | | #region ---控件的点击事件--- |
| | | |
| | | #region ---界面点击事件--- |
| | | playView.collectIconBtn.Visible = false;//先暂时隐藏收藏功能 |
| | | //收藏图标事件 |
| | | playView.collectIconBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | |
| | | { |
| | | string modeValueString = string.Empty; |
| | | string msg = Language.StringByID(StringId.switchTo); |
| | | switch (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode)) |
| | | string modeKeyValue = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode); |
| | | switch (modeKeyValue) |
| | | { |
| | | //list_cycle列表循环,single_cycle单曲循环,random随机播放; |
| | | case ValueProperty.list_cycle: |
| | |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; |
| | | msg += Language.StringByID(StringId.singleMode); |
| | | break; |
| | | |
| | | case ValueProperty.single_cycle: |
| | | modeValueString =ValueProperty.random; |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; |
| | |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; |
| | | msg += Language.StringByID(StringId.listMode); |
| | | break; |
| | | |
| | | } |
| | | A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.mode, modeValueString); |
| | | new PublicAssmebly().TipMsgAutoClose(msg, false,1000); |
| | |
| | | ///下拉刷新 |
| | | myListView.verticalScrolViewLayout.BeginHeaderRefreshingAction += () => |
| | | { |
| | | 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(() => |
| | | { |
| | | myListView.verticalScrolViewLayout.EndHeaderRefreshing(); |
| | | myListView.verticalScrolViewLayout.RemoveAll(); |
| | | var listName = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playlist_name); |
| | | var musicList = A31MusicModel.Current.GetSongList(listName); |
| | | A31SongPlay.SongListView(myListView.verticalScrolViewLayout, musicList, listName, myListView.popFra); |
| | | }); |
| | | } |
| | | }); |
| | | //结束刷新 |
| | | myListView.verticalScrolViewLayout.EndHeaderRefreshing(); |
| | | |
| | | }; |
| | | ///移除界面 |
| | | EventHandler<MouseEventArgs> removeFromParentView = (sen, e1) => |
| | |
| | | playView.volValueBtn.Text = playView.volSeekBar.Progress + "%"; |
| | | if (startVolume != e) |
| | | { |
| | | ///更新最新值 |
| | | A31MusicModel.ProgressDateTime = DateTime.Now; |
| | | startVolume = e; |
| | | A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.volume, startVolume); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | |
| | | |
| | | A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.song_step,ValueProperty.down); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add(KeyProperty.song_step, ValueProperty.down); |
| | | dic.Add(KeyProperty.song_step, ValueProperty.up); |
| | | SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | |
| | | }; |
| | |
| | | if (playView.playBtn.IsSelected) |
| | | { |
| | | playView.playBtn.IsSelected = false; |
| | | status = ValueProperty.off; |
| | | status = ValueProperty.off; |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | playView.nextBtn.IsSelected = false; |
| | | }; |
| | | ///物理按键的点击事件 |
| | | Volume.VolumeChange = (volume) => |
| | | { |
| | | if (Application.DeviceType == Device.Ios && A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.source) == "bluetooth") |
| | | { |
| | | return; |
| | | } |
| | | playView.volSeekBar.Progress = volume; |
| | | |
| | | if (startVolume != volume) |
| | | { |
| | | startVolume = volume; |
| | | A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.volume, startVolume); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add(KeyProperty.volume, startVolume.ToString()); |
| | | SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | } |
| | | |
| | | }; |
| | | /////物理按键的点击事件 |
| | | //Volume.VolumeChange = (volume) => |
| | | //{ |
| | | // if (Application.DeviceType == Device.Ios && A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.source) == "bluetooth") |
| | | // { |
| | | // return; |
| | | // } |
| | | // playView.volSeekBar.Progress = volume; |
| | | // if (startVolume != volume) |
| | | // { |
| | | // startVolume = volume; |
| | | // A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.volume, startVolume); |
| | | // Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | // dic.Add(KeyProperty.volume, startVolume.ToString()); |
| | | // SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | // } |
| | | //}; |
| | | #endregion |
| | | } |
| | | /// <summary> |
| | |
| | | { |
| | | //更新总时间 |
| | | //总共有多少秒 |
| | | int totalSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_time))/1000; |
| | | int totalSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_time)); |
| | | //分钟 |
| | | int totalMusicMinute = totalSecond / 60; |
| | | //秒钟 |
| | |
| | | // playView.volValueBtn.Text = A31MusicModel.Current.A31PlayStatus.vol + "%"; |
| | | // } |
| | | //} |
| | | |
| | | if (1000 < (DateTime.Now - A31MusicModel.ProgressDateTime).TotalMilliseconds) |
| | | //为了防止音量条跳动,延长更新时间(多加1s) |
| | | if (2000 < (DateTime.Now - A31MusicModel.ProgressDateTime).TotalMilliseconds || A31MusicModel.ProgressDateTime==DateTime.MinValue) |
| | | { |
| | | //音量进度条; |
| | | playView.volSeekBar.Progress = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.volume)); |
| | |
| | | playView.volValueBtn.Text = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.volume) + "%"; |
| | | } |
| | | //更新播放器音量给系统音量 |
| | | Volume.MusicVolume = playView.volSeekBar.Progress; |
| | | //Volume.MusicVolume = playView.volSeekBar.Progress; |
| | | //当前播放音乐时间 |
| | | //按道理不会为空,GetAttrState("playing_time")值可能为空,强制转换int.Parse()会出现异常,不过也做了异常处理了 |
| | | int playSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playing_time))+ (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; |
| | | |
| | | int playSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playing_time)); |
| | | //识别音乐状态是否在播放状态 |
| | | if (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on) |
| | | { |
| | | //音乐在播放时,再计算播放时间(现在时间=原来时间+1秒) |
| | | playSecond +=(int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; |
| | | playSecond += 1;//表示加上等待的时间1s |
| | | ///歌曲记录暂时时间写入缓存; |
| | | A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.playing_time, playSecond); |
| | | } |
| | | if (playSecond<=0) |
| | | { |
| | | ///播放时间不能小于0; |
| | | playSecond = 0; |
| | | } |
| | | if (playSecond >=totalSecond) |
| | | { |
| | | ///播放时间不能超过总时间; |
| | | playSecond = totalSecond; |
| | | } |
| | | int playMusicMinute = playSecond / 60; |
| | | //秒钟 |
| | | int playMusicSecond = playSecond % 60; |
| | | |
| | | string playTime = (playMusicMinute.ToString().Length < 2 ? "0" + playMusicMinute.ToString() : playMusicMinute.ToString()) + ":" + (playMusicSecond.ToString().Length < 2 ? "0" + playMusicSecond.ToString() : playMusicSecond.ToString()); |
| | | |
| | | if (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on) |
| | |
| | | playView.playBtn.IsSelected = false; |
| | | //停止播放 |
| | | playView.startTimeBtn.Text =playTime; |
| | | //playView.startTimeBtn.Text ="00:00"; |
| | | ///记录歌曲暂停时间;<LastDateTime 计算播放时间有用到> |
| | | A31MusicModel.Current.LastDateTime = DateTime.Now; |
| | | } |
| | | 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); |
| | |
| | | |
| | | switch (A31MusicModel.Current.functionMusic.GetAttrState("source")) |
| | | { |
| | | |
| | | case "QPLAY"://QQ音乐 |
| | | playView.loveBtn.Alpha = 0.5f; |
| | | playView.loveBtn.Enable = false; |
| | | break; |
| | | case "AIRPLAY"://酷狗音乐 |
| | | playView.loveBtn.Alpha = 0.5f; |
| | | playView.loveBtn.Enable = false; |
| | | playView.diyArcSeekBar.IsClickable = false; |
| | | break; |
| | | //sdcard/audio_in/ftp/radio/bluetooth |
| | | case "SONGLIST-NETWORK"://本地音乐 |
| | | break; |
| | | case "SONGLIST-LOCAL"://USB |