public static void Test(string videoTS_Folder) { DVDDiskInfo thisDVD = ParseDVD(videoTS_Folder); XmlSerializer ser = new XmlSerializer(typeof(DVDDiskInfo)); StringWriter outStr = new StringWriter(); ser.Serialize(outStr, thisDVD); Console.WriteLine(outStr.ToString()); }
public bool PlayMovie() { _info = _source.DVDDiskInfo; string videoFile = FindMPeg(_source); if (videoFile == null && _info != null) { OMLApplication.DebugLine("[MoviePlayerExtenderDVD] PlayMovie: DVD Disk info: '{0}'", _info); DVDTitle dvdTitle = _source.DVDTitle; if (dvdTitle != null) { string videoTSDir = _source.VIDEO_TS; int fileID = int.Parse(dvdTitle.File.Substring(4)); OMLApplication.DebugLine("[MoviePlayerExtenderDVD] PlayMovie: main title fileID={1} found for '{0}'", _source, fileID); string vts = string.Format("VTS_{0:D2}_", fileID); List<string> vobs = new List<string>(Directory.GetFiles(videoTSDir, vts + "*.VOB")); vobs.Remove(Path.Combine(videoTSDir, vts + "0.VOB")); if (vobs.Count < 1) { OMLApplication.DebugLine("[MoviePlayerExtenderDVD] PlayMovie: no VOB files found for '{0}'", _source); return false; } string mpegFolder = Path.Combine(FileSystemWalker.ExtenderCacheDirectory, Guid.NewGuid().ToString()); if (Directory.Exists(mpegFolder) == false) { OMLApplication.DebugLine("[MoviePlayerExtenderDVD] PlayMovie: creating folder '{0}'", mpegFolder); Directory.CreateDirectory(mpegFolder); } if (vobs.Count == 1) { OMLApplication.DebugLine("[MoviePlayerExtenderDVD] Single VOB file, trying to use a hard-link approach and direct playback"); OMLApplication.DebugLine("[MoviePlayerExtenderDVD] Calling MakeMPEGLink on WCF Transcoder Service"); string mpegFile = transcoder.MakeMPEGLink(mpegFolder, vobs[0]); if (File.Exists(mpegFile)) { OMLApplication.DebugLine("[MoviePlayerExtenderDVD] directly use MPEG"); videoFile = mpegFile; } } else if (OMLSettings.Extender_MergeVOB) { OMLApplication.DebugLine("[MoviePlayerExtenderDVD] Multiple VOB files, and Extender_MergeVOB == true, trying to use a hard-link and auto-merge into single large .VOB file approach "); OMLApplication.DebugLine("[MoviePlayerExtenderDVD] Calling MakeMPEGLink on WCF Transcoder Service"); string mpegFile = transcoder.MakeMPEGLink(mpegFolder, vobs[0]); OMLApplication.DebugLine("[MoviePlayerExtenderDVD] Merge VOB's, use first VOB to play and merge into"); if (File.Exists(mpegFile) == false) return false; videoFile = mpegFile; Microsoft.MediaCenter.UI.Application.DeferredInvokeOnWorkerThread(delegate { FileStream writer = null; try { writer = File.Open(vobs[0], FileMode.Append, FileAccess.Write, FileShare.Read); for (int i = 1; i < vobs.Count; ++i) MergeFile(writer, vobs[0], vobs[i]); for (int i = 1; i < vobs.Count; ++i) { OMLApplication.DebugLine("[MoviePlayerExtenderDVD] Deleting '{0}'", vobs[i]); File.Delete(vobs[i]); } } finally { if (writer != null) { OMLApplication.DebugLine("[MoviePlayerExtenderDVD] Done merging into '{0}'", vobs[0]); writer.Close(); } } }, delegate { Utilities.DebugLine("[MoviePlayerExtenderDVD] Merging done, restart play, and reset posision"); if (AddInHost.Current.MediaCenterEnvironment.MediaExperience != null) { TimeSpan cur = AddInHost.Current.MediaCenterEnvironment.MediaExperience.Transport.Position; Utilities.DebugLine("[MoviePlayerExtenderDVD] Current position: {0}", cur); if (AddInHost.Current.MediaCenterEnvironment.PlayMedia(MediaType.Video, videoFile, false)) { AddInHost.Current.MediaCenterEnvironment.MediaExperience.Transport.Position = cur; Utilities.DebugLine("[MoviePlayerExtenderDVD] Done starting over, resetting position: {0}", cur); } } }, null); } //else if (OMLSettings.Extender_UseAsx) else { OMLApplication.DebugLine("[MoviePlayerExtenderDVD] Multiple VOB files, and Extender_UseAsx == true, trying to use a hard-link and asx playlist approach "); foreach (string vob in vobs) { OMLApplication.DebugLine("[MoviePlayerExtenderDVD] Calling MakeMPEGLink on WCF Transcoder Service"); transcoder.MakeMPEGLink(mpegFolder, vob); } if (File.Exists(GetMPEGName(mpegFolder, vobs[0]))) videoFile = CreateASX(mpegFolder, vts, _source.Name, vobs); } } else OMLApplication.DebugLine("[MoviePlayerExtenderDVD] PlayMovie: no main title found for {0}", _source); } else OMLApplication.DebugLine("[MoviePlayerExtenderDVD] PlayMovie: no DVD-DiskInfo found for {0}", _source); if (videoFile == null) videoFile = GetAsxFile(); if (videoFile != null && AddInHost.Current.MediaCenterEnvironment.PlayMedia(MediaType.Video, videoFile, false)) { if (AddInHost.Current.MediaCenterEnvironment.MediaExperience != null) { Utilities.DebugLine("[MoviePlayerExtenderDVD] PlayMovie: movie '{0}', Playing file '{1}'", _source.Name, videoFile); OMLApplication.Current.NowPlayingMovieName = _source.Name; OMLApplication.Current.NowPlayingStatus = PlayState.Playing; if (_source.ResumeTime != null) { Utilities.DebugLine("[MoviePlayerExtenderDVD] PlayMovie: set resume time to: {0}", _source.ResumeTime); AddInHost.Current.MediaCenterEnvironment.MediaExperience.Transport.Position = _source.ResumeTime.Value; } //AddInHost.Current.MediaCenterEnvironment.MediaExperience.Transport.PropertyChanged -= MoviePlayerFactory.Transport_PropertyChanged; //AddInHost.Current.MediaCenterEnvironment.MediaExperience.Transport.PropertyChanged += MoviePlayerFactory.Transport_PropertyChanged; //AddInHost.Current.MediaCenterEnvironment.MediaExperience.Transport.PropertyChanged -= this.Transport_PropertyChanged; //AddInHost.Current.MediaCenterEnvironment.MediaExperience.Transport.PropertyChanged += this.Transport_PropertyChanged; AddInHost.Current.MediaCenterEnvironment.MediaExperience.GoToFullScreen(); } return true; } else { return false; } }