//eject the disc public static void EjectDisc(DiscDataEx Disc) { Collection <MediaChanger> changers = OMLApplication.Current.MediaCenterEnvironment.MediaChangers; if (changers != null && changers.Count > Disc.ChangerId) { //our changer is valid MediaChanger changer = changers[Disc.ChangerId]; Collection <DiscData> discs = changer.GetSlotDiscData(); //check the slot... if (Disc.SlotId != -1) { //the slot is not valid anymore if (Disc.SlotId >= discs.Count || Disc.DiscId != discs[Disc.SlotId].DiscId) { Disc.SlotId = -1; } } //disc was in a drive when we scanned if (Disc.SlotId == -1) { //see if it is still there int driveIdx = 0; foreach (DiscData disc in changer.GetDriveDiscData()) { if (disc.DiscId == Disc.DiscId) { //get it out of the drive Disc.SlotId = changer.UnloadDisc(driveIdx); //force a rescan OMLApplication.Current.MediaChangers.ReScan(); //GetChangers the discs AGAIN discs = changer.GetSlotDiscData(); } } } //our id still valid if (discs.Count > Disc.SlotId && Disc.SlotId != -1 && discs[Disc.SlotId].DiscId == Disc.DiscId) { changer.EjectDisc(Disc.SlotId); //force a rescan OMLApplication.Current.MediaChangers.ReScan(); } else { throw new Exception("Disc Not Found."); } } else { throw new Exception("Disc Not Found."); } }
public DVDChangerItem(DiscDataEx disc, IModelItem owner) : base(owner) { this.disc = disc; if (!string.IsNullOrEmpty(disc.Title)) this.Description = disc.Title; else this.Description = disc.VolumeLabel; //slow load the rest try { DvdInfo.BeginGetDvdInfo(disc.DiscId, new AsyncCallback(AddComplete), null); } catch { } }
/// <summary> /// This is somewhat awkward /// </summary> /// <param name="Disc"></param> /// <returns></returns> public static string LoadDisc(DiscDataEx Disc) { //the drive letter of our disc once we load it string discDrive = ""; Collection<MediaChanger> changers = OMLApplication.Current.MediaCenterEnvironment.MediaChangers; if (changers != null && changers.Count > Disc.ChangerId) { //our changer is valid MediaChanger changer = changers[Disc.ChangerId]; Collection<DiscData> discs = changer.GetSlotDiscData(); //disc was in a drive when we scanned if (Disc.SlotId == -1) { //see if it is still there foreach (DiscData disc in changer.GetDriveDiscData()) { if (disc.DiscId == Disc.DiscId) { //found it-lets get out of here discDrive = disc.DrivePath; return discDrive; } } //if we are here the disc is not in the drive int intSlotId = 0; foreach(DiscData disc in changer.GetSlotDiscData()) { if (Disc.DiscId == disc.DiscId) Disc.SlotId = intSlotId; intSlotId++; } } //load from slot if (Disc.SlotId != -1 && Disc.SlotId < discs.Count && Disc.DiscId == discs[Disc.SlotId].DiscId) { try { changer.UnloadDisc(0); } finally { changer.LoadDisc(Disc.SlotId, 0);//we always load to the first drive } //force a rescan OMLApplication.Current.MediaChangers.ReScan(); foreach (DiscData disc in changer.GetDriveDiscData()) { if (disc.DiscId == Disc.DiscId) { //found it-lets get out of here discDrive = disc.DrivePath; return discDrive; } } } //if we are here lets throw throw new Exception("Disc Not Found."); } else throw new Exception("Disc Not Found."); //return discDrive; }
//eject the disc public static void EjectDisc(DiscDataEx Disc) { Collection<MediaChanger> changers = OMLApplication.Current.MediaCenterEnvironment.MediaChangers; if (changers != null && changers.Count > Disc.ChangerId) { //our changer is valid MediaChanger changer = changers[Disc.ChangerId]; Collection<DiscData> discs = changer.GetSlotDiscData(); //check the slot... if (Disc.SlotId != -1) { //the slot is not valid anymore if (Disc.SlotId >= discs.Count || Disc.DiscId != discs[Disc.SlotId].DiscId) Disc.SlotId = -1; } //disc was in a drive when we scanned if (Disc.SlotId == -1) { //see if it is still there int driveIdx = 0; foreach (DiscData disc in changer.GetDriveDiscData()) { if (disc.DiscId == Disc.DiscId) { //get it out of the drive Disc.SlotId = changer.UnloadDisc(driveIdx); //force a rescan OMLApplication.Current.MediaChangers.ReScan(); //GetChangers the discs AGAIN discs = changer.GetSlotDiscData(); } } } //our id still valid if (discs.Count > Disc.SlotId && Disc.SlotId != -1 && discs[Disc.SlotId].DiscId == Disc.DiscId) { changer.EjectDisc(Disc.SlotId); //force a rescan OMLApplication.Current.MediaChangers.ReScan(); } else throw new Exception("Disc Not Found."); } else throw new Exception("Disc Not Found."); }
/// <summary> /// This is somewhat awkward /// </summary> /// <param name="Disc"></param> /// <returns></returns> public static string LoadDisc(DiscDataEx Disc) { //the drive letter of our disc once we load it string discDrive = ""; Collection <MediaChanger> changers = OMLApplication.Current.MediaCenterEnvironment.MediaChangers; if (changers != null && changers.Count > Disc.ChangerId) { //our changer is valid MediaChanger changer = changers[Disc.ChangerId]; Collection <DiscData> discs = changer.GetSlotDiscData(); //disc was in a drive when we scanned if (Disc.SlotId == -1) { //see if it is still there foreach (DiscData disc in changer.GetDriveDiscData()) { if (disc.DiscId == Disc.DiscId) { //found it-lets get out of here discDrive = disc.DrivePath; return(discDrive); } } //if we are here the disc is not in the drive int intSlotId = 0; foreach (DiscData disc in changer.GetSlotDiscData()) { if (Disc.DiscId == disc.DiscId) { Disc.SlotId = intSlotId; } intSlotId++; } } //load from slot if (Disc.SlotId != -1 && Disc.SlotId < discs.Count && Disc.DiscId == discs[Disc.SlotId].DiscId) { try { changer.UnloadDisc(0); } finally { changer.LoadDisc(Disc.SlotId, 0);//we always load to the first drive } //force a rescan OMLApplication.Current.MediaChangers.ReScan(); foreach (DiscData disc in changer.GetDriveDiscData()) { if (disc.DiscId == Disc.DiscId) { //found it-lets get out of here discDrive = disc.DrivePath; return(discDrive); } } } //if we are here lets throw throw new Exception("Disc Not Found."); } else { throw new Exception("Disc Not Found."); } //return discDrive; }