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); } }
private void QueryDVD(string path) { // Check to see if any IFO files exist if (Directory.GetFiles(path, "*.ifo").Length == 0) { // No IFO Files Found // Try to see if there is a VIDEO_TS folder if (Directory.Exists(System.IO.Path.Combine(path, "VIDEO_TS"))) { path = System.IO.Path.Combine(path, "VIDEO_TS"); if (Directory.GetFiles(path, "*.ifo").Length == 0) { return; } } } DVDDiskInfo ddi = DVDDiskInfo.ParseDVD(path); foreach (DVDTitle dt in ddi.Titles) { DIFeature difeature = new DIFeature(); DIVideoStream divideostream = new DIVideoStream(); difeature.Duration = dt.Duration; difeature.Name = dt.ToString(); divideostream.AspectRatio = dt.AspectRatio.ToString(); divideostream.Name = dt.ToString(); divideostream.TitleID = dt.TitleNumber; divideostream.FrameRate = (float)dt.FPS; divideostream.Resolution = dt.Resolution; TimeSpan starttime = new TimeSpan(0); foreach (DVDChapter ch in dt.Chapters) { DIChapter dichapter = new DIChapter(); dichapter.ChapterNumber = ch.ChapterNumber; dichapter.StartTime = starttime; dichapter.Duration = ch.Duration; dichapter.Frames = ch.Frames; dichapter.TotalFrames = ch.TotalFrames; difeature.Chapters.Add(dichapter); starttime += ch.Duration; } foreach (DVDAudioTrack at in dt.AudioTracks) { DIAudioStream diaudiostream = new DIAudioStream(); diaudiostream.Name = at.ToString(); diaudiostream.Encoding = (DIAudioEncoding)at.Format; diaudiostream.EncodingProfile = DIAudioEncodingProfile.Undefined; diaudiostream.LanguageID = at.LanguageID; diaudiostream.SampleFreq = at.Frequency; diaudiostream.AudioID = at.ID; diaudiostream.Bitrate = at.Bitrate; diaudiostream.Channels = at.Channels; diaudiostream.TrackNo = at.TrackNumber; diaudiostream.SubFormat = at.SubFormat; difeature.AudioStreams.Add(diaudiostream); } difeature.VideoStreams.Add(divideostream); DiskFeatures.Add(difeature); } }