/// <summary> /// 从本地载入播放列表 /// </summary> public bool LoadPlayList() { try { string xmlDocPath = PlayerSetting.DefaultVideosPath + "PlayList.xml"; if (System.IO.File.Exists(xmlDocPath)) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(xmlDocPath); PlaylistInfo plm = PlaylistInfo.ToModel(xmlDoc.OuterXml); //播放列表赋值 plists = plm.MediaPlayList; //计算整个播放列表播放时间的间隔加上循环间隔时长 playListTimeLength = 0; //foreach (PlaylistItemInfo item in plists) //{ // playListTimeLength += item.PlayTime; //} for (int i = 0; i < plists.Count; i++) { string relativurl = plists[i].MediaFileName; string path = PlayerSetting.DefaultVideosPath + relativurl; string md5Value = plists[i].MD5Key; if (!string.IsNullOrEmpty(md5Value)) { string MediaMd5 = SeatManage.SeatManageComm.SeatComm.GetMD5HashFromFile(path); if (MediaMd5.Equals(md5Value)) { playListTimeLength += plists[i].PlayTime; } else { PlayListHandleEvent(this, string.Format("文件{0} MD5校验失败!", relativurl)); plists.RemoveAt(i); i--; } } } //TODO:根据当前时间重新排列播放列表 RearrangePlayList(); return(true); } else { SeatManage.SeatManageComm.WriteLog.Write("播放列表不存在"); PlayListHandleEvent(this, "本地播放列表不存在!"); return(false); } } catch { SeatManage.SeatManageComm.WriteLog.Write("载入播放列表失败"); PlayListHandleEvent(this, "载入播放列表失败!"); return(false); } }
/// <summary> /// 获取播放列表 /// </summary> private bool DownloadPlaylist(ref PlaylistInfo model) { while (true) { //获取今天的播放列表 model = null; try { List <AMS_Advertisement> advert = SeatManage.Bll.AdvertisementOperation.GetAdList(false, SeatManage.EnumType.AdType.PlaylistAd); if (advert.Count < 1) { PlayListHandleEvent(this, "没有有效的播放列表"); return(false); } model = PlaylistInfo.ToModel(advert[0].AdContent); model.ID = advert[0].ID; timer1.Stop(); timer1.Dispose(); return(true); } catch (Exception ex) { PlayListHandleEvent(this, "服务器连接失败,正在重试……"); System.Threading.Thread.Sleep(2000); if (s > 300) { timer1.Stop(); timer1.Dispose(); return(false); } } //if (model != null) //{ // timer1.Stop(); // timer1.Dispose(); // return true; //} //else //{ // SeatManage.SeatManageComm.WriteLog.Write(ex.Message); // return false; //} } }
/// <summary> /// 获取播放列表 /// </summary> private bool DownloadPlaylist(ref PlaylistInfo model) { while (true) { //获取今天的播放列表 model = null; try { List <AMS_Advertisement> advert = SeatManage.Bll.AdvertisementOperation.GetAdList(false, SeatManage.EnumType.AdType.PlaylistAd); if (advert.Count < 1) { PlayListHandleEvent(this, "没有有效的播放列表"); return(false); } List <PlaylistInfo> pllist = new List <PlaylistInfo>(); foreach (var pl in advert) { PlaylistInfo plmodel = PlaylistInfo.ToModel(pl.AdContent); plmodel.ID = advert[0].ID; pllist.Add(plmodel); } model = pllist[0]; for (int i = 1; i < pllist.Count; i++) { foreach (string filepath in pllist[i].ImageFilePath) { if (model.ImageFilePath.FindAll(u => u == filepath).Count > 0) { continue; } model.ImageFilePath.Add(filepath); } foreach (var media in pllist[i].MediaPlayList) { model.MediaPlayList.Add(media); } } timer1.Stop(); timer1.Dispose(); return(true); } catch (Exception ex) { PlayListHandleEvent(this, "服务器连接失败,正在重试……"); System.Threading.Thread.Sleep(2000); if (s > 300) { timer1.Stop(); timer1.Dispose(); return(false); } } //if (model != null) //{ // timer1.Stop(); // timer1.Dispose(); // return true; //} //else //{ // SeatManage.SeatManageComm.WriteLog.Write(ex.Message); // return false; //} } }