/** * 音乐继续(修改播放状态为1并记录继续的瞬时时间-已播放长度) * * @param teamName * @return */ public String continueMusic() { String flag = "初始flag"; long sTime = -1; if (getMusicState() == 1) { flag = "当前已是播放状态"; } else { if (getPauseTime() == -1) { flag = "未找到已播放时间"; } else { sTime = getPauseTime(); // 修改播放状态为1并记录继续的瞬时时间-已播放长度 long t = StringProcess.ConvertDataTimeLong(DateTime.Now) - sTime; DateTime ts = StringProcess.ConvertLongDateTime(t); try { SyncEntity ms = db.MusicSync.Find(syncId); ms.syncId = syncId; ms.startDateTime = ts; ms.pauseTime = -1; ms.playState = 1; db.Entry(ms).State = EntityState.Modified; db.SaveChanges(); flag = "继续成功"; } catch (Exception e) { flag = "继续失败:" + e.ToString(); } } } return(flag); }
/** * 音乐暂停(修改播放状态为0并记录已播放长度) * * @param teamName * @return */ public String pauseMusic() { String flag = "初始flag"; long sTime = -1; if (getMusicState() == 0) { flag = "当前已是暂停状态"; } else { if (getStartDateTime() == null) { flag = "未找到歌曲时间"; } else { sTime = StringProcess.ConvertDataTimeLong(DateTime.Now) - StringProcess.ConvertDataTimeLong(getStartDateTime()); } try { SyncEntity ms = db.MusicSync.Find(syncId); ms.syncId = syncId; ms.pauseTime = sTime; ms.playState = 0; db.Entry(ms).State = EntityState.Modified; db.SaveChanges(); flag = "暂停成功"; } catch (Exception e) { flag = "暂停失败:" + e.ToString(); } } return(flag); }