/// <summary> /// Detects if a video CD/DVD/BD is contained in the given <paramref name="drive"/>. /// </summary> /// <param name="drive">The drive to be examined.</param> /// <param name="videoMediaType">Returns the type of the media found in the given <paramref name="drive"/>. This parameter /// only returns a sensible value when the return value of this method is <c>true</c>.</param> /// <returns><c>true</c>, if a video media was identified, else <c>false</c>.</returns> public static bool DetectVideoMedia(string drive, out VideoMediaType videoMediaType) { videoMediaType = VideoMediaType.Unknown; if (string.IsNullOrEmpty(drive) || drive.Length < 2) { return(false); } drive = drive.Substring(0, 2); // Clip potential '\\' at the end try { if (Directory.Exists(drive + "\\BDMV")) { ServiceRegistration.Get <ILogger>().Info("RemovableMediaManager: BD inserted into drive {0}", drive); videoMediaType = VideoMediaType.VideoBD; return(true); } if (Directory.Exists(drive + "\\VIDEO_TS")) { ServiceRegistration.Get <ILogger>().Info("RemovableMediaManager: DVD inserted into drive {0}", drive); videoMediaType = VideoMediaType.VideoDVD; return(true); } if (Directory.Exists(drive + "\\MPEGAV")) { ServiceRegistration.Get <ILogger>().Info("RemovableMediaManager: Video CD inserted into drive {0}", drive); videoMediaType = VideoMediaType.VideoCD; return(true); } } catch (IOException) { ServiceRegistration.Get <ILogger>().Warn("VideoDriveHandler: Error checking for video CD in drive {0}", drive); return(false); } return(false); }
/// <summary> /// Detects if a video CD/DVD/BD is contained in the given <paramref name="drive"/>. /// </summary> /// <param name="drive">The drive to be examined.</param> /// <param name="videoMediaType">Returns the type of the media found in the given <paramref name="drive"/>. This parameter /// only returns a sensible value when the return value of this method is <c>true</c>.</param> /// <returns><c>true</c>, if a video media was identified, else <c>false</c>.</returns> public static bool DetectVideoMedia(string drive, out VideoMediaType videoMediaType) { videoMediaType = VideoMediaType.Unknown; if (string.IsNullOrEmpty(drive) || drive.Length < 2) return false; drive = drive.Substring(0, 2); // Clip potential '\\' at the end try { if (Directory.Exists(drive + "\\BDMV")) { ServiceRegistration.Get<ILogger>().Info("RemovableMediaManager: BD inserted into drive {0}", drive); videoMediaType = VideoMediaType.VideoBD; return true; } if (Directory.Exists(drive + "\\VIDEO_TS")) { ServiceRegistration.Get<ILogger>().Info("RemovableMediaManager: DVD inserted into drive {0}", drive); videoMediaType = VideoMediaType.VideoDVD; return true; } if (Directory.Exists(drive + "\\MPEGAV")) { ServiceRegistration.Get<ILogger>().Info("RemovableMediaManager: Video CD inserted into drive {0}", drive); videoMediaType = VideoMediaType.VideoCD; return true; } } catch (IOException) { ServiceRegistration.Get<ILogger>().Warn("VideoDriveHandler: Error checking for video CD in drive {0}", drive); return false; } return false; }