From 3f6685c77beeb12baf840733fb890860f4c26e7c Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期四, 25 七月 2024 17:25:59 +0800 Subject: [PATCH] 2024年07月25日17:24:45 --- HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs | 530 +++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 323 insertions(+), 207 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs index 90a7991..477877c 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Security; using HDL_ON.UI.UI2.FuntionControlView.Music; +using HDL_ON.Entity; namespace HDL_ON.UI.Music { @@ -38,13 +39,11 @@ /// </summary> View.PlayView playView = new View.PlayView(); TopView topView; - - public void Show() { ///1绉掑畾鏃舵洿鏂扮姸鎬� - timerUpdateStatus(); + TimerUpdateStatus(); #region ---鐣岄潰甯冨眬--- this.BackgroundColor = MusicColor.ViewColor; topView = new TopView(); @@ -70,7 +69,9 @@ ///鍔犺浇鎾斁闊充箰鐣岄潰鐨勬帶浠舵柟娉� playView.viewFrameLayout(middLayout); #endregion - #region ---鎺т欢鐨勭偣鍑讳簨浠�--- + + #region ---鐣岄潰鐐瑰嚮浜嬩欢--- + //playView.collectIconBtn.Visible = false;//鍏堟殏鏃堕殣钘忔敹钘忓姛鑳� //鏀惰棌鍥炬爣浜嬩欢 playView.collectIconBtn.MouseUpEventHandler += (sender, e) => { @@ -83,38 +84,68 @@ { A31MusicModel.Current.functionMusic.collect = false; } - + A31MusicModel.Current.functionMusic.CollectFunction(); }; ///鍒囨崲鎾斁妯″紡鐐瑰嚮浜嬩欢; playView.playOrderBtn.MouseUpEventHandler += (sender, e) => { - string modeValueString = string.Empty; string msg = Language.StringByID(StringId.switchTo); - switch (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode)) + //鑾峰彇褰撳墠鎾斁妯″紡 + string currModeKeyValue = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode); + //鑾峰彇闊充箰鎾斁妯″紡鍒楄〃 + var attributes = A31MusicModel.Current.functionMusic.GetAttribute(KeyProperty.mode); + if (attributes == null) + { + attributes = new FunctionAttributes(); + } + var attributesList = attributes.value; + //鎵惧埌褰撳墠鎾斁妯″紡绱㈠紩鍊� + int currModeIndexe = attributesList.IndexOf(currModeKeyValue); + //璁板綍閫変腑鐨勬挱鏀炬ā寮忕殑绱㈠紩鍊� + int count = 0; + if (currModeIndexe >= attributesList.Count - 1) + { + //閲嶇疆绱㈠紩鍊� + count = 0; + } + else + { + count = currModeIndexe + 1; + } + //閫氳繃绱㈠紩鍊兼壘鍒版ā寮弙alue鍊� + string modeValueString = attributesList[count]; + switch (modeValueString) { //list_cycle鍒楄〃寰幆锛宻ingle_cycle鍗曟洸寰幆锛宺andom闅忔満鎾斁; case ValueProperty.list_cycle: - modeValueString=ValueProperty.single_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"; - msg += Language.StringByID(StringId.randomMode); - break; - case ValueProperty.random: - modeValueString = ValueProperty.list_cycle; playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; msg += Language.StringByID(StringId.listMode); break; + case ValueProperty.single_cycle: + playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single_cycle.png"; + msg += Language.StringByID(StringId.singleCycleMode); + break; + case ValueProperty.random: + playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; + msg += Language.StringByID(StringId.randomMode); + break; + case ValueProperty.single: + playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; + msg += Language.StringByID(StringId.single); + break; + case ValueProperty.order: + playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/order.png"; + msg += Language.StringByID(StringId.orderMode); + break; + } + //鍐欏叆缂撳瓨 A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.mode, modeValueString); - new PublicAssmebly().TipMsgAutoClose(msg, false,1000); + new PublicAssmebly().TipMsgAutoClose(msg, false, 1000); Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add(KeyProperty.mode,modeValueString); - SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic,dic); + dic.Add(KeyProperty.mode, modeValueString); + //鍙戦�佹帶鍒舵寚浠� + SendMethod.Current.SendControlCommand(A31MusicModel.Current.functionMusic, dic); }; ///娣诲姞鍠滅埍鐐瑰嚮浜嬩欢; playView.loveBtn.MouseUpEventHandler += (sender, e) => @@ -130,7 +161,7 @@ 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 @@ -151,11 +182,53 @@ 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 += () => { - //缁撴潫鍒锋柊 - myListView.verticalScrolViewLayout.EndHeaderRefreshing(); + myListView.verticalScrolViewLayout.EndHeaderRefreshing(); //缁撴潫鍒锋柊 + loading.Start(); + System.Threading.Tasks.Task.Run((() => + { + try + { + A31MusicModel.Current.CurrentPlayMusicInfoList.Clear(); + if (A31MusicModel.Current.CurrentPlayMusicInfoList.Count == 0) + { + 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); + }); + }); + + } + } + catch + { + } + finally + { + Application.RunOnMainThread(() => + { + 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) => @@ -163,34 +236,36 @@ 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) => { 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>(); dic.Add(KeyProperty.volume, startVolume.ToString()); - SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + SendMethod.Current.SendControlCommand(A31MusicModel.Current.functionMusic, dic); } }; @@ -201,16 +276,16 @@ { 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.down); - SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + dic.Add(KeyProperty.song_step, ValueProperty.up); + SendMethod.Current.SendControlCommand(A31MusicModel.Current.functionMusic, dic); }; playView.prevBtn.MouseUpEventHandler += (sender, e) => { playView.prevBtn.IsSelected = false; - }; + }; ///鏆傚仠/鎾斁鐐瑰嚮浜嬩欢 playView.playBtn.MouseDownEventHandler += (sender, e) => { @@ -218,7 +293,8 @@ if (playView.playBtn.IsSelected) { playView.playBtn.IsSelected = false; - status = ValueProperty.off; + status = ValueProperty.off; + } else { @@ -228,40 +304,38 @@ 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) => { 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> @@ -271,154 +345,190 @@ /// <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))/1000; - //鍒嗛挓 - 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; - string s = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode); - 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.png"; - break; - case ValueProperty.random://闅忔満鎾斁 - playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.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 + "%"; - // } - //} - - if (1000 < (DateTime.Now - A31MusicModel.ProgressDateTime).TotalMilliseconds) - { - //闊抽噺杩涘害鏉�; - 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))+ (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; - - 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; + 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(); @@ -448,16 +558,7 @@ 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 @@ -516,21 +617,34 @@ /// 鍔犺浇鎾斁闊充箰鍒楄〃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); + + }); + }); } } @@ -541,26 +655,28 @@ { 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); } - - - } } -- Gitblit v1.8.0