void Stop(int sid) { bool bl = false; try { bl = IPCast.FilePlayStop(sid); Log(string.Format("IPCast.FilePlayStop({0})={1}", sid, bl)); } catch (Exception e) { Log(string.Format("IPCast.FilePlayStop({0})={1} (Error:{2})", sid, bl, e.Message)); } bl = false; try { bl = IPCast.RMSession(sid); Log(string.Format("IPCast.RMSession({0})={1}", sid, bl)); } catch (Exception e) { Log(string.Format("IPCast.RMSession({0})={1} (Error:{2})", sid, bl, e.Message)); } }
void Play(DataGridViewRow rc, DataRow rt) { int pc = int.Parse(rc.Cells["PlayID"].Value.ToString()); int pt = int.Parse(rt["A40_PLAY_ID"].ToString()); if (pc == pt) { return; } int sc = int.Parse(rc.Cells["SID"].Value.ToString()); if (sc > 0) { Stop(sc); } int tid = int.Parse(rt["A40_CLIENT_ID"].ToString()); string mp3 = rt["A41_MP3_FILE"].ToString(); int mod = int.Parse(rt["A40_PLAY_MODE"].ToString()); int st = 0; if (pt > 0) { try { st = IPCast.FilePlayStart(mp3, mod, tid); Log(string.Format("IPCast.FilePlayStart({0},{1},{2})={3}", mp3, mod, tid, st)); } catch (Exception e) { Log(string.Format("IPCast.FilePlayStart({0},{1},{2})={3} (Error:{4})", mp3, mod, tid, st, e.Message)); } int s = 0; if (st > 0) { try { s = IPCast.GetSessionStatus(st); Log(string.Format("GetSessionStatus({0})={1}", st, s)); } catch (Exception e) { Log(string.Format("GetSessionStatus({0})={1} (Error:{2})", st, s, e.Message)); } } } rc.Cells["PlayID"].Value = pt; rc.Cells["PlayDesc"].Value = rt["A41_PLAY_DESC"]; rc.Cells["SID"].Value = st; }
private void fmMain_FormClosed(object sender, FormClosedEventArgs e) { timer.Enabled = false; db.Close(); db.Dispose(); IPCast.DisConnect(); Log("IPCast.DisConnect"); }
private void fmMain_Load(object sender, EventArgs e) { CONFIG.Load(); bool bl = IPCast.Connect("127.0.0.1", "admin", "admin"); Log(string.Format("IPCast.Connect={0}", bl)); StopAll(); string con = CONFIG.GetText("SQLDB", "ConStr", ""); db = new DB("System.Data.SqlClient", con); db.Open(); InitClient(); timer.Enabled = true; }
void StopAll() { int[] s = null; try { s = IPCast.GetSessionList(); Log(string.Format("IPCast.GetSessionList()={0}", s == null ? 0 : s.Length)); } catch (Exception e) { Log(e.Message); } if (s != null) { foreach (int sid in s) { Stop(sid); } } }