using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using Shared;
|
using Shared.SimpleControl.Phone;
|
using Shared.SimpleControl;
|
using Shared.SimpleControl.R;
|
|
namespace Shared.SimpleControl.Phone.Music
|
{
|
/// <summary>
|
/// SD卡和Nas播放的界面
|
/// </summary>
|
class PlayPage : FrameLayout
|
{
|
void showSourcePage ()
|
{
|
switch (currentMusicModel.SourceID) {
|
//sd
|
case "1":
|
#region
|
sourceName.TextID = MyInternationalizationString.SDcard;
|
like.Alpha = 1;
|
like.Enable = true;
|
|
list.Alpha = 1;
|
list.Enable = true;
|
|
prve.Alpha = 1;
|
prve.Enable = true;
|
|
next.Alpha = 1;
|
next.Enable = true;
|
|
mode.Alpha = 1;
|
mode.Enable = true;
|
#endregion
|
break;
|
|
//ftp
|
case "2":
|
#region
|
sourceName.TextID = MyInternationalizationString.NAS;
|
like.Alpha = 1;
|
like.Enable = true;
|
|
list.Alpha = 1;
|
list.Enable = true;
|
|
prve.Alpha = 1;
|
prve.Enable = true;
|
|
next.Alpha = 1;
|
next.Enable = true;
|
|
mode.Alpha = 1;
|
mode.Enable = true;
|
#endregion
|
break;
|
|
//cd
|
case "6":
|
#region
|
sourceName.TextID = MyInternationalizationString.MusicCD;
|
like.Alpha = 0.5f;
|
like.Enable = false;
|
|
list.Alpha = 0.5f;
|
list.Enable = false;
|
|
prve.Alpha = 0.5f;
|
prve.Enable = false;
|
|
next.Alpha = 0.5f;
|
next.Enable = false;
|
|
mode.Alpha = 0.5f;
|
mode.Enable = false;
|
#endregion
|
break;
|
|
//蓝牙
|
case "8":
|
#region
|
sourceName.TextID = MyInternationalizationString.Musicbluetooth;
|
like.Alpha = 0.5f;
|
like.Enable = false;
|
|
list.Alpha = 0.5f;
|
list.Enable = false;
|
|
prve.Alpha = 1;
|
prve.Enable = true;
|
|
next.Alpha = 1;
|
next.Enable = true;
|
|
mode.Alpha = 0.5f;
|
mode.Enable = false;
|
#endregion
|
break;
|
|
//光纤
|
case "9":
|
#region
|
sourceName.TextID = MyInternationalizationString.MusicFD;
|
like.Alpha = 0.5f;
|
like.Enable = false;
|
|
list.Alpha = 0.5f;
|
list.Enable = false;
|
|
prve.Alpha = 0.5f;
|
prve.Enable = false;
|
|
next.Alpha = 0.5f;
|
next.Enable = false;
|
|
mode.Alpha = 0.5f;
|
mode.Enable = false;
|
#endregion
|
break;
|
}
|
}
|
|
/// <summary>
|
/// 1表示SD卡,2表示Nas
|
/// </summary>
|
public int SourceId {
|
set {
|
if (currentMusicModel.SourceID != value.ToString ()) {
|
currentMusicModel.SourceID = value.ToString ();
|
send ("*Z1SRC" + value);
|
}
|
}
|
}
|
|
/// <summary>
|
/// 当前源的名称
|
/// </summary>
|
Button sourceName = new Button {
|
Width = Application.GetRealWidth (200),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (230),
|
Y = Application.GetRealHeight (175 - 130),
|
};
|
/// <summary>
|
/// 停止/播放;
|
/// </summary>
|
Button btnPlay = new Button {
|
Width = Application.GetRealWidth (159),
|
Height = Application.GetRealHeight (127),
|
X = Application.GetRealWidth (260),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "MusicIcon/Playplay.png",
|
SelectedImagePath = "MusicIcon/playmusicplaySelected.png",
|
};
|
/// <summary>
|
///当前播放音乐时间
|
/// </summary>
|
Button btnMusicplayTime = new Button {
|
Width = Application.GetRealWidth (126),
|
Height = Application.GetRealHeight (126),
|
X = Application.GetRealWidth (10),
|
Y = Application.GetRealHeight (820 - 130),
|
};
|
/// <summary>
|
/// 音乐总时间
|
/// </summary>
|
Button btnTotalMusicTime = new Button {
|
Width = Application.GetRealWidth (126),
|
Height = Application.GetRealHeight (126),
|
X = Application.GetRealWidth (520),
|
Y = Application.GetRealHeight (820 - 130),
|
|
};
|
/// <summary>
|
/// 播放音乐时间进度条
|
/// </summary>
|
Button progressMaxButton = new Button {
|
Height = Application.GetRealHeight (4),
|
Radius = (uint)Application.GetRealHeight (2),
|
Gravity = Gravity.CenterVertical,
|
BackgroundColor = 0xff525252,
|
};
|
/// <summary>
|
/// 播放进度
|
/// </summary>
|
Button progressButton = new Button {
|
Width = 0,
|
Height = Application.GetRealHeight (4),
|
Radius = (uint)Application.GetRealHeight (2),
|
Gravity = Gravity.CenterVertical,
|
BackgroundColor = 0xffFE5E00,
|
};
|
|
/// <summary>
|
/// 当前播放的音乐名称
|
/// </summary>
|
Button title = new Button {
|
Width = Application.GetMinRealAverage (350),
|
Height = Application.GetMinRealAverage (60),
|
TextSize = 15,
|
X = Application.GetRealWidth (150),
|
Y = Application.GetRealHeight (747 - 130),
|
};
|
/// <summary>
|
/// 静音图标
|
/// </summary>
|
Button btnMute = new Button {
|
Width = Application.GetRealWidth (107),
|
Height = Application.GetRealHeight (127),
|
X = Application.GetRealWidth (15),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "MusicIcon/PlayMute.png",
|
SelectedImagePath = "MusicIcon/PlayMuteSelected.png",
|
};
|
|
|
/// <summary>
|
/// 音量进度条
|
/// </summary>
|
HorizontalSeekBar horizontalSeekBarVol = new HorizontalSeekBar {
|
Width = Application.GetRealWidth (490 - 26),
|
Height = Application.GetRealHeight (50),
|
Radius = (uint)Application.GetRealHeight (25),
|
X = Application.GetRealWidth (13),
|
Gravity = Gravity.CenterVertical,
|
BackgroundColor = 0xFF525252,
|
ProgressColor = 0xffFE5E00,
|
Max = 79,
|
};
|
|
/// <summary>
|
///模式图标,1单曲播放,2单曲循环,3连续播放,4连播循环
|
/// </summary>
|
Button mode = new Button {
|
Width = Application.GetRealWidth (94),
|
Height = Application.GetRealHeight (82),
|
X = Application.GetRealWidth (18),
|
Y = Application.GetRealHeight (732 - 130),
|
};
|
|
/// <summary>
|
/// 收藏图标
|
/// </summary>
|
Button like = new Button {
|
Width = Application.GetRealWidth (106),
|
Height = Application.GetRealHeight (103),
|
X = Application.GetRealWidth (10),
|
Y = Application.GetRealHeight (157 - 130),
|
UnSelectedImagePath = "MusicIcon/PlayLike.png",
|
SelectedImagePath = "MusicIcon/PlayLikeSelected.png",
|
};
|
/// <summary>
|
/// 显示播放列表
|
/// </summary>
|
Button list = new Button {
|
Width = Application.GetRealWidth (106),
|
Height = Application.GetRealHeight (103),
|
X = Application.GetRealWidth (540),
|
Y = Application.GetRealHeight (727 - 130),
|
UnSelectedImagePath = "MusicIcon/PlayList.png",
|
};
|
|
/// <summary>
|
/// 上一曲
|
/// </summary>
|
Button prve = new Button {
|
Width = Application.GetRealWidth (126),
|
Height = Application.GetRealHeight (126),
|
X = Application.GetRealWidth (127),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "MusicIcon/PlayPrve.png",
|
SelectedImagePath = "MusicIcon/PlayPrveSelected.png",
|
};
|
|
/// <summary>
|
/// 下一曲
|
/// </summary>
|
Button next = new Button {
|
Width = Application.GetRealWidth (126),
|
Height = Application.GetRealHeight (126),
|
X = Application.GetRealWidth (430),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "MusicIcon/PlayNext.png",
|
SelectedImagePath = "MusicIcon/PlayNextSelected.png",
|
};
|
|
/// <summary>
|
/// 当前界面对象
|
/// </summary>
|
static PlayPage currentPlayMusic;
|
|
/// <summary>
|
/// 当前音乐对象
|
/// </summary>
|
MusicModel currentMusicModel;
|
|
/// <summary>
|
/// 加载音乐播放界面
|
/// </summary>
|
/// <param name="musicModel">当前音乐播放对象</param>
|
/// <param name="playListmusic">当前播放的音乐列表</param>
|
/// <param name="sourceId">源ID,SD卡及Ftp源</param>
|
public void Show (MusicModel musicModel, List<KeyAndValue> playListmusic)
|
{
|
if (currentMusicModel != null) {
|
currentPlayMusic.RemoveFromParent ();
|
}
|
currentPlayMusic = this;
|
currentMusicModel = musicModel;
|
|
//读取当前的音乐状态
|
readStatus ();
|
|
AddChidren (new Button () {
|
Height = Application.GetRealHeight (36),
|
BackgroundColor =SkinStyle.Current.MusicTopFrameLayout,
|
});
|
|
var topFrameLayout = new FrameLayout () {
|
Height = Application.GetRealHeight (100),
|
Y = Application.GetRealHeight (36),
|
BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
|
};
|
AddChidren (topFrameLayout);
|
|
var back = new Button {
|
Width = Application.GetMinRealAverage (72),
|
Height = Application.GetMinRealAverage (89),
|
X = Application.GetRealWidth (10),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "MusicIcon/PlayBack.png",
|
};
|
topFrameLayout.AddChidren (back);
|
back.MouseDownEventHandler += (sender, o) => {
|
currentPlayMusic = null;
|
//退出界面的时候,从父控件里移除掉
|
RemoveFromParent ();
|
};
|
|
topFrameLayout.AddChidren (new Button {
|
Width = Application.GetMinRealAverage (300),
|
Height = Application.GetMinRealAverage (60),
|
Text = musicModel.Name,
|
TextSize = 15,
|
Gravity = Gravity.Center,
|
TextColor=SkinStyle.Current.MusicTextColor,
|
});
|
|
var set = new Button {
|
Width = Application.GetRealWidth (76),
|
Height = Application.GetRealHeight (66),
|
X = Application.GetRealWidth (550),
|
UnSelectedImagePath = "MusicIcon/PlayMusicset.png",
|
Gravity = Gravity.CenterVertical,
|
Tag = musicModel,
|
};
|
if (musicModel.MusicType == 1) {
|
topFrameLayout.AddChidren (set);
|
}
|
|
set.MouseDownEventHandler += (sender, e) => {
|
SourcePage sourcePage = new SourcePage { };
|
MainPage.MainFrameLayout.AddChidren (sourcePage);
|
sourcePage.Show ((MusicModel)set.Tag);
|
};
|
|
var middleFrameLayout = new FrameLayout () {
|
Height = Application.GetRealHeight (1000+ 100),
|
Y = topFrameLayout.Bottom,
|
BackgroundImagePath = "MusicIcon/PlayBackgroun.png"
|
};
|
AddChidren (middleFrameLayout);
|
topFrameLayout.BringToFront ();//隐藏底层
|
|
if (musicModel.MusicType == 1) {
|
middleFrameLayout.AddChidren (sourceName);
|
}
|
|
var portrait = new Button {
|
Width = Application.GetRealWidth (392),
|
Height = Application.GetRealHeight (392),
|
X = Application.GetRealWidth (120),
|
Y = Application.GetRealHeight (280 - 130),
|
UnSelectedImagePath = "MusicIcon/PlayPortrait.png",
|
};
|
middleFrameLayout.AddChidren (portrait);
|
|
like.Tag = musicModel;
|
like.MouseDownEventHandler += (sener, o) => {
|
like.IsSelected = !like.IsSelected;
|
string number = currentMusicModel.curTypeNumber + currentMusicModel.curListNumber + currentMusicModel.curSongNumber;
|
if (like.IsSelected) {
|
if (null == currentMusicModel.LovePlayList.Find ((song) => { return song.number == number; })) {
|
//如果没有找到,就加入
|
currentMusicModel.LovePlayList.Add (new KeyAndValue {
|
number = number,
|
name = currentMusicModel.curPlayMusicName.Replace (".mp3", "")
|
});
|
}
|
} else {
|
for (int i = 0; i < currentMusicModel.LovePlayList.Count; i++) {
|
if (currentMusicModel.LovePlayList [i].number == number) {
|
currentMusicModel.LovePlayList.RemoveAt (i);
|
break;
|
}
|
}
|
}
|
|
//保存
|
string saveRoomUIName = "Room_" + Room.CurrentRoom.Name;
|
Shared.IO.FileUtils.WriteFileByBytes (saveRoomUIName,
|
Shared.SimpleControl.CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (Room.CurrentRoom)));
|
};
|
//middleFrameLayout.AddChidren(like);
|
if (musicModel.MusicType == 1) {
|
middleFrameLayout.AddChidren (mode);
|
}
|
mode.MouseDownEventHandler += Mode_MouseDownEventHandler;
|
|
middleFrameLayout.AddChidren (title);
|
|
list.Tag = musicModel.Name;
|
if (musicModel.MusicType == 1) {
|
middleFrameLayout.AddChidren (list);
|
}
|
list.MouseDownEventHandler += (sender, e) => {
|
Button button = (Button)sender;
|
ListPage listMusic = new ListPage {
|
Width = LayoutParams.MatchParent,
|
Height = LayoutParams.MatchParent,
|
};
|
MainPage.MainFrameLayout.AddChidren (listMusic);
|
|
if (currentMusicModel.SourceID == "1") {
|
playListmusic = musicModel.SDCardSongList.FindAll (song => { return song.number.StartsWith (musicModel.curTypeNumber + musicModel.curListNumber); });
|
} else if (currentMusicModel.SourceID == "2") {
|
playListmusic = musicModel.NasSongList.FindAll (song => { return song.number.StartsWith (musicModel.curTypeNumber + musicModel.curListNumber); });
|
}
|
listMusic.Musiclist (musicModel, playListmusic, musicModel.curMusicListName, int.Parse (currentMusicModel.SourceID));
|
};
|
|
#region 歌曲时间
|
|
middleFrameLayout.AddChidren (btnMusicplayTime);
|
middleFrameLayout.AddChidren (btnTotalMusicTime);
|
var frameLayout1 = new FrameLayout {
|
Width = Application.GetRealWidth (400 - 26),
|
Height = Application.GetRealHeight (126),
|
X = Application.GetRealWidth (150),
|
Y = Application.GetRealHeight (820 - 130),
|
};
|
middleFrameLayout.AddChidren (frameLayout1);
|
|
frameLayout1.AddChidren (progressMaxButton);
|
frameLayout1.AddChidren (progressButton);
|
#endregion
|
|
#region 上,下,暂停/播放
|
var tempFrameLayout = new FrameLayout {
|
Height = Application.GetRealHeight (130),
|
Y = Application.GetRealHeight (960 - 130)
|
};
|
middleFrameLayout.AddChidren (tempFrameLayout);
|
tempFrameLayout.AddChidren (prve);
|
prve.MouseDownEventHandler += (sender, o) => {
|
prve.IsSelected = true;
|
send ("*S" + currentMusicModel.SourceID + "PREV");
|
};//下
|
prve.MouseUpEventHandler += (sender, o) => {
|
prve.IsSelected = false;
|
};//上
|
|
tempFrameLayout.AddChidren (btnPlay);
|
btnPlay.MouseDownEventHandler += (sender, o) => {
|
btnPlay.IsSelected = !btnPlay.IsSelected;
|
if (btnPlay.IsSelected) {
|
if (musicModel.MusicType== 2) {
|
send ("*Z1ON");
|
} else {
|
send ("*S" + currentMusicModel.SourceID + "PLAY");
|
}
|
currentMusicModel.PlayStatus = MusicModel.Status.Play;
|
} else {
|
if (musicModel.MusicType == 2) {
|
send ("*Z1OFF");
|
} else {
|
send ("*S" + currentMusicModel.SourceID + "STOP");
|
}
|
currentMusicModel.PlayStatus = MusicModel.Status.Stop;
|
}
|
|
};
|
|
next.MouseDownEventHandler += (sender, o) => {
|
next.IsSelected = true;
|
send ("*S" + currentMusicModel.SourceID + "NEXT");
|
};
|
next.MouseUpEventHandler += (sender, o) => {
|
next.IsSelected = false;
|
};
|
tempFrameLayout.AddChidren (next);
|
#endregion
|
|
#region 音量+,-,静音
|
tempFrameLayout.AddChidren (btnMute);
|
btnMute.MouseDownEventHandler += (sender, e) => {
|
btnMute.IsSelected = !btnMute.IsSelected;
|
if (btnMute.IsSelected) {
|
//静音之前先保存之前的音量,为还原音量
|
beforeVol = currentMusicModel.CurVol;
|
send ("*Z1VOL79");
|
currentMusicModel.CurVol = "79";
|
} else {
|
send ("*Z1VOL" + beforeVol);
|
currentMusicModel.CurVol = beforeVol;
|
}
|
};
|
|
var btnMusicvol = new Button {
|
Width = Application.GetRealWidth (107),
|
Height = Application.GetRealHeight (127),
|
X = Application.GetRealWidth (540),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "MusicIcon/PlayVoice.png",
|
SelectedImagePath = "MusicIcon/PlayVoiceSelected.png",
|
};
|
tempFrameLayout.AddChidren (btnMusicvol);
|
btnMusicvol.MouseDownEventHandler += (sender, o) => {
|
btnMusicvol.IsSelected = !btnMusicvol.IsSelected;
|
if (btnMusicvol.IsSelected) {
|
middleFrameLayout.Y -= Application.GetRealHeight (100);
|
} else {
|
middleFrameLayout.Y += Application.GetRealHeight (100);
|
}
|
};
|
|
var ProgFrameLayout = new FrameLayout {
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight (100),
|
Y = Application.GetRealHeight (1120 - 130),
|
};
|
middleFrameLayout.AddChidren (ProgFrameLayout);
|
|
var btnMusicvo2 = new Button {
|
Width = Application.GetRealWidth (107),
|
Height = Application.GetRealHeight (127),
|
X = Application.GetRealWidth (15),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "MusicIcon/PlayVoice.png",
|
};
|
ProgFrameLayout.AddChidren (btnMusicvo2);
|
|
var frameLayout = new FrameLayout {
|
Width = Application.GetRealWidth (490),
|
Height = Application.GetRealHeight (50),
|
Gravity = Gravity.CenterVertical,
|
X = Application.GetRealWidth (120),
|
};
|
ProgFrameLayout.AddChidren (frameLayout);
|
frameLayout.AddChidren (horizontalSeekBarVol);
|
horizontalSeekBarVol.ProgressChanged += (sender, p) => {
|
send ("*Z1VOL" + (79 - p));
|
};
|
#endregion
|
}
|
|
/// <summary>
|
/// 模式切换
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void Mode_MouseDownEventHandler (object sender, MouseEventArgs e)
|
{
|
Button button = (Button)sender;
|
switch (currentMusicModel.playMode) {
|
//1单曲播放playModeDanquplay,2单曲循环playModeDDdanquplay,
|
//3连续播放playModeshunxuplay,4连播循环playModeliebiaoplay
|
case 1:
|
currentMusicModel.playMode = 2;
|
button.UnSelectedImagePath = "MusicIcon/playModeDDdanquplay.png";
|
button.IsSelected = false;
|
break;
|
|
case 2:
|
currentMusicModel.playMode = 3;
|
button.UnSelectedImagePath = "MusicIcon/playModeshunxuplay.png";
|
button.IsSelected = false;
|
break;
|
|
case 3:
|
currentMusicModel.playMode = 4;
|
button.UnSelectedImagePath = "MusicIcon/playModeliebiaoplay.png";
|
button.IsSelected = false;
|
break;
|
|
case 4:
|
currentMusicModel.playMode = 1;
|
button.UnSelectedImagePath = "MusicIcon/playModeDanquplay.png";
|
button.IsSelected = false;
|
break;
|
|
default:
|
currentMusicModel.playMode = 3;
|
button.UnSelectedImagePath = "MusicIcon/playModeshunxuplay.png";
|
button.IsSelected = false;
|
break;
|
|
}
|
send ("*S" + currentMusicModel.SourceID + "MODE+");
|
}
|
|
//点击静音之前的音量
|
string beforeVol = "30";
|
|
/// <summary>
|
/// 发送控制命令
|
/// </summary>
|
/// <param name="command"></param>
|
void send (string command)
|
{
|
//当控制完成时,马上读取状态,会有问题,所以控制后5秒再读取
|
MyMusic.dateTime = System.DateTime.Now;
|
////如果不是当前源,就先切换源
|
//if (currentMusicModel.SourceID != currentMusicModel.SourceID.ToString())
|
//{
|
// Control.ControlBytesSend(Command.ControlMusicModel, currentMusicModel.SubnetID, currentMusicModel.DeviceID, MusicModel.MusiceBytes("*Z1SRC" + sourceId));
|
//}
|
//发送控制命令
|
Control.ControlBytesSend (Command.ControlMusicModel, currentMusicModel.SubnetID, currentMusicModel.DeviceID, MusicModel.MusiceBytes (command), SendCount.Zero);
|
}
|
|
/// <summary>
|
/// 读取音乐状态
|
/// </summary>
|
void readStatus ()
|
{
|
System.Threading.Tasks.Task.Run (() => {
|
System.DateTime dateTime = System.DateTime.Now.AddSeconds (-5);
|
|
while (Parent != null) {
|
//等待1秒,更新界面
|
System.Threading.Thread.Sleep (1000 * 1);
|
|
Application.RunOnMainThread (() => {
|
#region
|
try {
|
showSourcePage ();
|
|
//总共有多少秒
|
int totalSecond = int.Parse (currentMusicModel.musicTime) / 10;
|
//分钟
|
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 ());
|
btnTotalMusicTime.Text = totalTime;
|
|
title.Text = currentMusicModel.curPlayMusicName.Replace (".mp3", "");
|
horizontalSeekBarVol.Progress = 79 - int.Parse (currentMusicModel.CurVol);
|
|
switch (currentMusicModel.playMode) {
|
#region
|
case 1:
|
mode.UnSelectedImagePath = "MusicIcon/playModeDanquplay.png";
|
break;
|
case 2:
|
mode.UnSelectedImagePath = "MusicIcon/playModeDDdanquplay.png";
|
break;
|
case 3:
|
mode.UnSelectedImagePath = "MusicIcon/playModeshunxuplay.png";
|
break;
|
case 4:
|
mode.UnSelectedImagePath = "MusicIcon/playModeliebiaoplay.png";
|
break;
|
default:
|
mode.UnSelectedImagePath = "MusicIcon/playModeshunxuplay.png";
|
break;
|
#endregion
|
}
|
|
if (currentMusicModel.SourceID == "1") {
|
var likeMusic = currentMusicModel.LovePlayList.Find ((like) => {
|
return like.number == currentMusicModel.curTypeNumber + currentMusicModel.curListNumber + currentMusicModel.curSongNumber;
|
});
|
//找到当前的播放ID,就说明是收藏音乐
|
like.IsSelected = likeMusic != null;
|
} else if (currentMusicModel.SourceID == "2") {
|
var likeMusic = currentMusicModel.NasSongList.Find ((like) => {
|
return like.number == currentMusicModel.curTypeNumber + currentMusicModel.curListNumber + currentMusicModel.curSongNumber;
|
});
|
//找到当前的播放ID,就说明是收藏音乐
|
like.IsSelected = likeMusic != null;
|
}
|
|
btnMute.IsSelected = currentMusicModel.CurVol == "79" ? true : false;
|
if (currentMusicModel.PlayStatus == MusicModel.Status.Play) {
|
btnPlay.IsSelected = true;
|
//如果在播放,时间就不断变化
|
//当前播放音乐时间
|
int playSecond = int.Parse (currentMusicModel.musicPalyTime) / 10 + (int)(DateTime.Now - currentMusicModel.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 ());
|
btnMusicplayTime.Text = playTime;
|
if (totalSecond == 0) {
|
progressButton.Width = 0;
|
} else {
|
progressButton.Width = (int)(playSecond * 1.0 / totalSecond * progressMaxButton.Width);
|
}
|
} else {
|
//停止状态
|
btnPlay.IsSelected = false;
|
progressButton.Width = 0;
|
btnMusicplayTime.Text = "00:00";
|
btnTotalMusicTime.Text = "00:00";
|
}
|
} catch {
|
}
|
#endregion
|
//CD 蓝牙 光纤
|
if (currentMusicModel.SourceID == "8" || currentMusicModel.SourceID == "6" || currentMusicModel.SourceID == "9") {
|
title.Text = "UnKown";
|
progressButton.Width = 0;
|
btnMusicplayTime.Text = "00:00";
|
btnTotalMusicTime.Text = "00:00";
|
}
|
});
|
}
|
});
|
}
|
}
|
}
|