async void chimneyMpdServer_OnPlayId(object sender, ResponseEventArgs e)
{
int id = -1;
if (e.arguments.Count == 1)
{
try
{
id = Convert.ToInt32(e.arguments[0]);
}
catch
{
}
}
if (id >= 0)
{
var playfile = await Dbconnection.FindAsync<File>(o => o.FileId == id);
if(playfile != null)
{
Play(playfile.FilePath, playfile.IsUrl);
}
var currentPlaylist = await Dbconnection.FindAsync<CurrentPlaylist>(o => o.FileId == playfile.FileId );
if (currentPlaylist != null)
{
await Dbconnection.QueryAsync<CurrentPlaylist>("UPDATE CurrentPlaylist SET CurrentSong = 0 WHERE CurrentSong = 1");
currentPlaylist.CurrentSong = true;
await Dbconnection.UpdateAsync(currentPlaylist);
}
}
chimneyMpdServer.AppendResponse(string.Empty, e.id, e.position);
if (OnIdleEvent != null) OnIdleEvent(this, new IdleEventArgs("player"));
}