| | |
| | | /// </summary> |
| | | View.PlayView playView = new View.PlayView(); |
| | | TopView topView; |
| | | |
| | | |
| | | public void Show() |
| | | { |
| | | |
| | | ///1秒定时更新状态 |
| | | timerUpdateStatus(); |
| | | TimerUpdateStatus(); |
| | | #region ---界面布局--- |
| | | this.BackgroundColor = MusicColor.ViewColor; |
| | | topView = new TopView(); |
| | |
| | | #endregion |
| | | |
| | | #region ---界面点击事件--- |
| | | playView.collectIconBtn.Visible = false;//先暂时隐藏收藏功能 |
| | | //playView.collectIconBtn.Visible = false;//先暂时隐藏收藏功能 |
| | | //收藏图标事件 |
| | | playView.collectIconBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | |
| | | { |
| | | A31MusicModel.Current.functionMusic.collect = false; |
| | | } |
| | | |
| | | A31MusicModel.Current.functionMusic.CollectFunction(); |
| | | }; |
| | | ///切换播放模式点击事件; |
| | | playView.playOrderBtn.MouseUpEventHandler += (sender, e) => |
| | |
| | | string currModeKeyValue = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode); |
| | | //获取音乐播放模式列表 |
| | | var attributes = A31MusicModel.Current.functionMusic.GetAttribute(KeyProperty.mode); |
| | | if (attributes==null) { |
| | | attributes=new FunctionAttributes(); |
| | | if (attributes == null) |
| | | { |
| | | attributes = new FunctionAttributes(); |
| | | } |
| | | var attributesList = attributes.value; |
| | | //找到当前播放模式索引值 |
| | | int currModeIndexe = attributesList.IndexOf(currModeKeyValue); |
| | | //记录选中的播放模式的索引值 |
| | | int count = 0; |
| | | if (currModeIndexe >= attributesList.Count-1) |
| | | if (currModeIndexe >= attributesList.Count - 1) |
| | | { |
| | | //重置索引值 |
| | | count = 0; |
| | |
| | | { |
| | | //list_cycle列表循环,single_cycle单曲循环,random随机播放; |
| | | case ValueProperty.list_cycle: |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; |
| | | msg += Language.StringByID(StringId.listMode); |
| | | break; |
| | | case ValueProperty.single_cycle: |
| | |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add(KeyProperty.mode, modeValueString); |
| | | //发送控制指令 |
| | | SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | SendMethod.Current.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | }; |
| | | ///添加喜爱点击事件; |
| | | playView.loveBtn.MouseUpEventHandler += (sender, e) => |
| | |
| | | return name == musicInfo.name; |
| | | })) |
| | | { |
| | | A31MusicModel.Current.LoveMusicInfoList.Add(new Songs { name = name, time = songTime }); |
| | | A31MusicModel.Current.LoveMusicInfoList.Add(new SongInfo { name = name, time = songTime }); |
| | | } |
| | | } |
| | | else |
| | |
| | | UI2.FuntionControlView.Music.View.MyListView myListView = new UI2.FuntionControlView.Music.View.MyListView(); |
| | | myListView.frameLayout(this, A31MusicModel.Current); |
| | | myListView.dialogFra.AddChidren(loading);//dialogFra刷新图标父控件 |
| | | loading.Start(); |
| | | ///下拉刷新 |
| | | myListView.verticalScrolViewLayout.BeginHeaderRefreshingAction += () => |
| | | { |
| | | System.Threading.Tasks.Task.Run(() => |
| | | myListView.verticalScrolViewLayout.EndHeaderRefreshing(); //结束刷新 |
| | | loading.Start(); |
| | | System.Threading.Tasks.Task.Run((() => |
| | | { |
| | | try |
| | | { |
| | | A31MusicModel.Current.palyLists.Clear(); |
| | | if (A31MusicModel.Current.palyLists.Count == 0) |
| | | A31MusicModel.Current.CurrentPlayMusicInfoList.Clear(); |
| | | if (A31MusicModel.Current.CurrentPlayMusicInfoList.Count == 0) |
| | | { |
| | | SendMethod.mMethod.GetPalyList(A31MusicModel.Current.functionMusic); |
| | | SendMethod.Current.GetCurrentPalyList(A31MusicModel.Current.functionMusic, () => |
| | | { |
| | | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | myListView.verticalScrolViewLayout.RemoveAll(); |
| | | var listName = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playlist_name); |
| | | var source = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.source); |
| | | var musicList = A31MusicModel.Current.GetSongList(listName); |
| | | A31SongPlay.SongListView(myListView.verticalScrolViewLayout, musicList, listName, source, myListView.popFra); |
| | | }); |
| | | }); |
| | | |
| | | } |
| | | } |
| | |
| | | { |
| | | 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); |
| | | loading.Hide(); |
| | | //myListView.verticalScrolViewLayout.EndHeaderRefreshing(); |
| | | //myListView.verticalScrolViewLayout.RemoveAll(); |
| | | //var listName = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playlist_name); |
| | | //var source = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.source); |
| | | //var musicList = A31MusicModel.Current.GetSongList(listName); |
| | | |
| | | //A31SongPlay.SongListView(myListView.verticalScrolViewLayout, musicList, listName, source, myListView.popFra); |
| | | }); |
| | | } |
| | | }); |
| | | //结束刷新 |
| | | |
| | | })); |
| | | |
| | | }; |
| | | ///移除界面 |
| | | EventHandler<MouseEventArgs> removeFromParentView = (sen, e1) => |
| | |
| | | myListView.popFra.RemoveFromParent(); |
| | | }; |
| | | myListView.backIextBtn.MouseUpEventHandler += removeFromParentView; |
| | | myListView.popFra.MouseUpEventHandler += removeFromParentView; |
| | | //myListView.popFra.MouseUpEventHandler += removeFromParentView; |
| | | #endregion |
| | | //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); |
| | | this.PlayListView(myListView.popFra, myListView.verticalScrolViewLayout, loading); |
| | | this.UpdateSelectedMusic(myListView.popFra, myListView.verticalScrolViewLayout); |
| | | |
| | | }; |
| | | ///音量图标点击事件 |
| | | playView.volIconBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | |
| | | |
| | | }; |
| | | ///音量进度条点击事件 |
| | | int startVolume =0;//之前的音量 |
| | | int startVolume = 0;//之前的音量 |
| | | //int endVolume = 0;//现在的音量 |
| | | EventHandler<int> progressClick = (sender, e) => |
| | | { |
| | |
| | | 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); |
| | | SendMethod.Current.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | |
| | | } |
| | | }; |
| | |
| | | { |
| | | playView.prevBtn.IsSelected = true; |
| | | |
| | | A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.song_step,ValueProperty.down); |
| | | A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.song_step, ValueProperty.down); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add(KeyProperty.song_step, ValueProperty.up); |
| | | SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | SendMethod.Current.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | |
| | | }; |
| | | playView.prevBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | playView.prevBtn.IsSelected = false; |
| | | }; |
| | | }; |
| | | ///暂停/播放点击事件 |
| | | playView.playBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | |
| | | { |
| | | playView.playBtn.IsSelected = false; |
| | | status = ValueProperty.off; |
| | | |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.on_off, status); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add(KeyProperty.on_off, status); |
| | | SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | SendMethod.Current.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | }; |
| | | ///下一曲点击事件 |
| | | playView.nextBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | playView.nextBtn.IsSelected = true; |
| | | A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.song_step,ValueProperty.down); |
| | | A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.song_step, ValueProperty.down); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add(KeyProperty.song_step, ValueProperty.down); |
| | | SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | SendMethod.Current.SendControlCommand(A31MusicModel.Current.functionMusic, dic); |
| | | }; |
| | | playView.nextBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | |
| | | /// <summary> |
| | | /// 定时更新状态 |
| | | /// </summary> |
| | | void timerUpdateStatus() |
| | | void TimerUpdateStatus() |
| | | { |
| | | timerThread = new System.Threading.Thread((obj) => |
| | | { |
| | | while (true) |
| | | try |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | while (true) |
| | | { |
| | | try |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | //更新总时间 |
| | | //总共有多少秒 |
| | | int totalSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_time)); |
| | | //分钟 |
| | | int totalMusicMinute = totalSecond / 60; |
| | | //秒钟 |
| | | int totalMusicSecond = 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.functionMusic.name; |
| | | //显示播放模式图标 |
| | | switch (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode)) |
| | | try |
| | | { |
| | | case ValueProperty.list_cycle://列表循环 |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; |
| | | break; |
| | | case ValueProperty.single_cycle://单曲循环 |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single_cycle.png"; |
| | | break; |
| | | case ValueProperty.random://随机播放 |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; |
| | | break; |
| | | case ValueProperty.single:// 单曲<single> |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; |
| | | break; |
| | | case ValueProperty.order://循序循环 |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/order.png"; |
| | | break; |
| | | } |
| | | //更新总时间 |
| | | //总共有多少秒 |
| | | int totalSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_time)); |
| | | //分钟 |
| | | int totalMusicMinute = totalSecond / 60; |
| | | //秒钟 |
| | | int totalMusicSecond = 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.functionMusic.name; |
| | | //显示播放模式图标 |
| | | switch (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode)) |
| | | { |
| | | case ValueProperty.list_cycle://列表循环 |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; |
| | | break; |
| | | case ValueProperty.single_cycle://单曲循环 |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single_cycle.png"; |
| | | break; |
| | | case ValueProperty.random://随机播放 |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; |
| | | break; |
| | | case ValueProperty.single:// 单曲<single> |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; |
| | | break; |
| | | case ValueProperty.order://循序循环 |
| | | playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/order.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.functionMusic.GetRoomListName(); |
| | | //显示播放器收藏状态图标 |
| | | if (A31MusicModel.Current.functionMusic.collect) |
| | | { |
| | | playView.collectIconBtn.IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | playView.collectIconBtn.IsSelected = false; |
| | | } |
| | | //if (A31MusicModel.Current.A31PlayStatus.IsMute) |
| | | //{ |
| | | // // btnMute.IsSelected = true;//静音图标 |
| | | // playView.volSeekBar.Progress = 0; |
| | | //} |
| | | //else |
| | | //{ |
| | | // // btnMute.IsSelected = false;//静音图标 |
| | | // if (1000 < (DateTime.Now - A31MusicModel.ProgressDateTime).TotalMilliseconds) |
| | | // { |
| | | // //声音进度条; |
| | | // playView.volSeekBar.Progress = int.Parse(A31MusicModel.Current.A31PlayStatus.vol); |
| | | // //显示当前音量值; |
| | | // playView.volValueBtn.Text = A31MusicModel.Current.A31PlayStatus.vol + "%"; |
| | | // } |
| | | //} |
| | | //为了防止音量条跳动,延长更新时间(多加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; |
| | | //当前播放音乐时间 |
| | | //按道理不会为空,GetAttrState("playing_time")值可能为空,强制转换int.Parse()会出现异常,不过也做了异常处理了 |
| | | 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 = true; |
| | | //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; |
| | | } |
| | | else |
| | | { |
| | | //不收藏 |
| | | playView.collectIconBtn.IsSelected = false; |
| | | } |
| | | //if (A31MusicModel.Current.A31PlayStatus.IsMute) |
| | | //{ |
| | | // // btnMute.IsSelected = true;//静音图标 |
| | | // playView.volSeekBar.Progress = 0; |
| | | //} |
| | | //else |
| | | //{ |
| | | // // btnMute.IsSelected = false;//静音图标 |
| | | // if (1000 < (DateTime.Now - A31MusicModel.ProgressDateTime).TotalMilliseconds) |
| | | // { |
| | | // //声音进度条; |
| | | // playView.volSeekBar.Progress = int.Parse(A31MusicModel.Current.A31PlayStatus.vol); |
| | | // //显示当前音量值; |
| | | // playView.volValueBtn.Text = A31MusicModel.Current.A31PlayStatus.vol + "%"; |
| | | // } |
| | | //} |
| | | //为了防止音量条跳动,延长更新时间(多加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; |
| | | //当前播放音乐时间 |
| | | //按道理不会为空,GetAttrState("playing_time")值可能为空,强制转换int.Parse()会出现异常,不过也做了异常处理了 |
| | | 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()); |
| | | //显示播放时间 |
| | | playView.startTimeBtn.Text = playTime; |
| | | //显示播放状态 |
| | | if (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on) |
| | | { |
| | | //播放 |
| | | playView.playBtn.IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | //暂停 |
| | | playView.playBtn.IsSelected = false; |
| | | ///记录歌曲暂停时间;<LastDateTime 计算播放时间有用到> |
| | | A31MusicModel.Current.LastDateTime = DateTime.Now; |
| | | } |
| | | //显示进度条值 |
| | | if (totalSecond == 0) |
| | | { |
| | | //显示歌曲进度条 |
| | | //歌曲播放进度 |
| | | playView.diyArcSeekBar.Progress = 0; |
| | | } |
| | | else |
| | | { |
| | | //显示歌曲进度条 |
| | | //歌曲播放进度 |
| | | playView.diyArcSeekBar.Progress = (int)(playSecond * 100.0 / totalSecond);//+1 |
| | | } |
| | | |
| | | |
| | | //显示歌曲名称 |
| | | 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(); |
| | | } |
| | | else |
| | | catch (Exception e) |
| | | { |
| | | //显示播放状态图标 |
| | | playView.playBtn.IsSelected = false; |
| | | //停止播放 |
| | | playView.startTimeBtn.Text =playTime; |
| | | //playView.startTimeBtn.Text ="00:00"; |
| | | ///记录歌曲暂停时间;<LastDateTime 计算播放时间有用到> |
| | | A31MusicModel.Current.LastDateTime = DateTime.Now; |
| | | var ee = e.Message; |
| | | } |
| | | //显示歌曲名称 |
| | | 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(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | var ee = e.Message; |
| | | } |
| | | }); |
| | | System.Threading.Thread.Sleep(1000 * 1); |
| | | }); |
| | | System.Threading.Thread.Sleep(1000 * 1); |
| | | } |
| | | } |
| | | catch (Exception e) { } |
| | | }) |
| | | { IsBackground = true }; |
| | | timerThread.Start(); |
| | |
| | | /// 加载播放音乐列表View |
| | | /// </summary> |
| | | /// <param name="verticalScrolViewLayout"></param> |
| | | void PlayListView(FrameLayout frameLayout, VerticalRefreshLayout verticalScrolViewLayout) |
| | | private void PlayListView(FrameLayout frameLayout, VerticalRefreshLayout verticalScrolViewLayout, Loading loading) |
| | | { |
| | | verticalScrolViewLayout.RemoveAll(); |
| | | var listName = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playlist_name); |
| | | var source = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.source); |
| | | //获取缓存歌曲列表 |
| | | var musicList = A31MusicModel.Current.GetSongList(listName); |
| | | loading.Start(); |
| | | if (musicList.Count == 0) |
| | | { |
| | | System.Threading.Tasks.Task.Run(() => |
| | | System.Threading.Tasks.Task.Run((() => |
| | | { |
| | | try |
| | | { |
| | | A31MusicModel.Current.palyLists.Clear(); |
| | | if (A31MusicModel.Current.palyLists.Count == 0) |
| | | A31MusicModel.Current.CurrentPlayMusicInfoList.Clear(); |
| | | if (A31MusicModel.Current.CurrentPlayMusicInfoList.Count == 0) |
| | | { |
| | | SendMethod.mMethod.GetPalyList(A31MusicModel.Current.functionMusic); |
| | | //获取歌曲列表 |
| | | SendMethod.Current.GetCurrentPalyList(A31MusicModel.Current.functionMusic, () => |
| | | { |
| | | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | musicList = A31MusicModel.Current.GetSongList(listName); |
| | | A31SongPlay.SongListView(verticalScrolViewLayout, musicList, listName, source, frameLayout); |
| | | |
| | | }); |
| | | }); |
| | | |
| | | } |
| | | } |
| | |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | musicList = A31MusicModel.Current.GetSongList(listName); |
| | | A31SongPlay.SongListView(verticalScrolViewLayout, musicList, listName, frameLayout); |
| | | loading.Hide(); |
| | | //musicList = A31MusicModel.Current.GetSongList(listName); |
| | | //A31SongPlay.SongListView(verticalScrolViewLayout, musicList, listName, source, frameLayout); |
| | | }); |
| | | } |
| | | }); |
| | | })); |
| | | } |
| | | else |
| | | { |
| | | A31SongPlay.SongListView(verticalScrolViewLayout, musicList, listName, frameLayout); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | A31SongPlay.SongListView(verticalScrolViewLayout, musicList, listName, source, frameLayout); |
| | | }); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 定时更新当前播放音乐 |
| | | /// </summary> |
| | | void UpdateSelectedMusic(FrameLayout frameLayout, VerticalRefreshLayout middViewLayout) |
| | | private void UpdateSelectedMusic(FrameLayout frameLayout, VerticalRefreshLayout middViewLayout) |
| | | { |
| | | UpdateThread.updateCurrMusicThread(frameLayout, middViewLayout, A31MusicModel.Current); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |