public void Play(DBMovieInfo movie, int part) { // stop the mediainfo background process if it is running MovingPicturesCore.ProcessManager.CancelProcess(typeof(MediaInfoUpdateProcess)); // stop the internal player if it's running if (g_Player.Playing) { g_Player.Stop(); } // set player state working _playerState = MoviePlayerState.Processing; // queue the local media object in case we first need to play the custom intro // we can get back to it later. queuedMedia = movie.LocalMedia[part - 1]; // try playing our custom intro (if present). If successful quit, as we need to // wait for the intro to finish. bool success = playCustomIntro(); if (success) { return; } // Start movie playMovie(movie, part); }
public RenamableFile(DBMovieInfo movie, DBLocalMedia localMedia) { _movie = movie; _localMedia = localMedia; _originalName = localMedia.FullPath; _originalFile = localMedia.File; }
//process selected files to unignore private void unignoreSelectedFiles() { //setup array to store movie list and number of rows variable ArrayList selMovie = new ArrayList(); int rowSel = ignoredMovieGrid.SelectedRows.Count; //process each selected cell and copy the movie name to the arraylist foreach (DataGridViewCell cellSel in ignoredMovieGrid.SelectedCells) { if (cellSel.ToolTipText.Length > 0) { selMovie.Add(cellSel.ToolTipText); } } //look for all ignored DBLocalMedia and see if it was in the array build from the selectedCell list above foreach (DBLocalMedia currFile in DBLocalMedia.GetAll()) { if (currFile.Ignored && selMovie.Contains(currFile.File.FullName)) { currFile.Delete(); } } MovingPicturesCore.Importer.RestartScanner(); }
// method replaces encoded file rename string to contain movie specific information. private string GetNewFileName(DBLocalMedia file) { // use existing or generate new base filename string baseFileName; if (baseFileNameLookup.ContainsKey(file.AttachedMovies[0])) { baseFileName = baseFileNameLookup[file.AttachedMovies[0]]; } else { // parse variables in pattern for base filename string pattern = MovingPicturesCore.Settings.FileRenameString; baseFileName = ReplaceVariables(file.AttachedMovies[0], pattern); // store the new base filename for reuse later baseFileNameLookup[file.AttachedMovies[0]] = baseFileName; } // add multipart information as needed string newFileName = AddPartInfo(baseFileName, file); // remove characters not accepted by the OS in a filename newFileName = Regex.Replace(newFileName, @"[?:\/*""<>|]", ""); // remove any unwanted double spacing due to missing variables newFileName = newFileName.Trim(); newFileName = newFileName.Replace(" ", " "); return(newFileName); }
private List <Renamable> GetSecondaryFiles(DBLocalMedia mainFile) { List <Renamable> secondaryFiles = new List <Renamable>(); // grab information about files to be renamed DirectoryInfo targetDir = new DirectoryInfo(mainFile.File.DirectoryName); string[] fileExtensions = MovingPicturesCore.Settings.Rename_SecondaryFileTypes.Split('|'); // loop through our possible files and flag any exist for renaming foreach (string currFileExt in fileExtensions) { string originalNameBase = targetDir + @"\" + Path.GetFileNameWithoutExtension(mainFile.FullPath); string newNameBase = targetDir + @"\" + GetNewFileName(mainFile); FileInfo newFile = new FileInfo(originalNameBase + currFileExt); if (newFile.Exists) { RenamableFile newRenamable = new RenamableFile(mainFile.AttachedMovies[0], newFile); newRenamable.NewName = newNameBase + currFileExt; secondaryFiles.Add(newRenamable); } } return(secondaryFiles); }
/// <summary> /// Constructor. /// </summary> /// <param name="filename">Filename of the currently played media file</param> public NowPlayingMovingPictures(string filename) { try { DBLocalMedia possibleMatches = DBLocalMedia.Get(filename); if (possibleMatches.AttachedMovies.Count > 0) { movieFound = true; DBMovieInfo match = possibleMatches.AttachedMovies[0]; ItemId = (int)match.ID; Title = match.Title; AlternateTitles = match.AlternateTitles.ToString(); Directors = match.Directors.ToString(); Writers = match.Writers.ToString(); Actors = match.Actors.ToString(); Year = match.Year; Genres = match.Genres.ToString(); Certification = match.Certification; Tagline = match.Tagline; Summary = match.Summary; Rating = match.Score.ToString(); DetailsUrl = match.DetailsURL; ImageName = match.CoverFullPath; } } catch (Exception e) { WifiRemote.LogMessage("Error getting now playing moving pictures: " + e.Message, WifiRemote.LogType.Error); } }
/// <summary> /// Resets player variables /// </summary> private void resetPlayer() { // If we have an image mounted, unmount it if (mountedPlayback) { queuedMedia.UnMount(); mountedPlayback = false; } // reset player variables if (GUIGraphicsContext.IsFullScreenVideo) { GUIGraphicsContext.IsFullScreenVideo = false; } activeMedia = null; queuedMedia = null; _playerState = MoviePlayerState.Idle; _resumeActive = false; _forcePlay = false; listenToExternalPlayerEvents = false; donePlayingCustomIntros = false; customIntrosPlayed = 0; ClearPlayProperties(); logger.Debug("Reset."); }
// store the duration of the file if it is not set private void updateMediaDuration(DBLocalMedia localMedia) { if (localMedia.Duration == 0) { logger.Debug("UpdateMediaDuration: LocalMedia={0}, Format={1}, Duration={2}", localMedia.FullPath, localMedia.VideoFormat, g_Player.Player.Duration.ToString(NumberFormatInfo.InvariantInfo)); localMedia.Duration = ((int)g_Player.Player.Duration) * 1000; localMedia.Commit(); } }
public static LatestMediaHandler.MQTTItem CheckDB(string SearchFile) { LatestMediaHandler.MQTTItem item = new LatestMediaHandler.MQTTItem(); if (MQTTPlugin.DebugMode) { Logger.Debug("Check to see if video is in MovingPictures database."); } if (Utils.IsAssemblyAvailable("MovingPictures", new Version(1, 0, 6, 1116))) { if (MQTTPlugin.DebugMode) { Logger.Debug("MovingPictures found, searching Database for: " + SearchFile); } if (SearchFile.IndexOf(".MPLS") != -1) // Blu-Ray played with BDHandler { if (MQTTPlugin.DebugMode) { Logger.Debug("Blu-Ray being played with BDHandler, converting filename."); } int BDMVindex; string OldFile = SearchFile; BDMVindex = SearchFile.IndexOf("\\BDMV\\"); if (BDMVindex != -1) { SearchFile = SearchFile.Substring(0, BDMVindex + 6) + "INDEX.BDMV"; } if (MQTTPlugin.DebugMode) { Logger.Debug("Filename converted from: " + OldFile + " to: " + SearchFile); } } if (MQTTPlugin.DebugMode) { Logger.Debug("Searching Database for: " + SearchFile); } DBLocalMedia Matches = DBLocalMedia.Get(SearchFile); if (Matches.AttachedMovies.Count > 0) { if (MQTTPlugin.DebugMode) { Logger.Debug("Found " + Matches.AttachedMovies.Count.ToString() + " matches."); } DBMovieInfo moviematch = Matches.AttachedMovies[0]; item.Id = moviematch.ImdbID; item.Title = moviematch.Title + " (" + moviematch.Year + ")"; item.Filename = SearchFile; item.Genres = moviematch.Genres.ToString(); item.GetArtwork("movie"); } } return(item); }
// Gets and resturns a List<> of all ignored files private List <DBLocalMedia> getIgnoredFiles() { List <DBLocalMedia> hidFil = new List <DBLocalMedia>(); foreach (DBLocalMedia currFile in DBLocalMedia.GetAll()) { if (currFile.Ignored) { hidFil.Add(currFile); } } return(hidFil); }
private void onPlayBackStoppedOrChanged(g_Player.MediaType type, int timeMovieStopped, string filename) { if (type != g_Player.MediaType.Video || _playerState != MoviePlayerState.Playing) { return; } if (customIntrosPlayed > 0) { return; } logger.Debug("OnPlayBackStoppedOrChanged: File={0}, Movie={1}, Part={2}, TimeStopped={3}", filename, _activeMovie.Title, _activePart, timeMovieStopped); // Because we can't get duration for DVD's at start like with normal files // we are getting the duration when the DVD is stopped. If the duration of // feature is an hour or more it's probably the main feature and we will update // the database. if (g_Player.IsDVD && (g_Player.Player.Duration >= 3600)) { DBLocalMedia playingFile = _activeMovie.LocalMedia[_activePart - 1]; updateMediaDuration(playingFile); } int requiredWatchedPercent = MovingPicturesCore.Settings.MinimumWatchPercentage; int watchedPercentage = _activeMovie.GetPercentage(_activePart, timeMovieStopped); int resumeTitleBD = g_Player.SetResumeBDTitleState; logger.Debug("Watched: Percentage=" + watchedPercentage + ", Required=" + requiredWatchedPercent); // if enough of the movie has been watched if (watchedPercentage >= requiredWatchedPercent) { // run movie ended logic onMovieEnded(_activeMovie); } // otherwise, store resume data. else { byte[] resumeData = null; g_Player.Player.GetResumeState(out resumeData); updateMovieResumeState(_activeMovie, _activePart, timeMovieStopped, resumeData, resumeTitleBD); // run movie stopped logic onMovieStopped(_activeMovie); } }
// add part information as needed private string AddPartInfo(string baseFileName, DBLocalMedia file) { string newFileName = baseFileName; DBMovieInfo movie = file.AttachedMovies[0]; int part = movie.LocalMedia.IndexOf(file) + 1; // either add the correct part number or remove the part substring as needed if (movie.LocalMedia.Count > 1) { newFileName = newFileName.Replace("#", part.ToString()); } else { newFileName = newFileName.Replace(MovingPicturesCore.Settings.FileMultipartString, ""); } return(newFileName); }
public override void Work() { if (!MovingPicturesCore.Settings.AutoRetrieveMediaInfo) { return; } logger.Info("Starting background media info update process."); List <DBLocalMedia> allLocalMedia = DBLocalMedia.GetAll(); foreach (DBLocalMedia lm in allLocalMedia) { if (lm.ID != null && !lm.HasMediaInfo) { lm.UpdateMediaInfo(); lm.Commit(); } } logger.Info("Background media info update process complete."); }
/// <summary> /// Create a Random Playlist of All HD Videos /// </summary> private void playRandomHDAll() { PlayList playlist = Player.playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MVCENTRAL); playlist.Clear(); List <DBTrackInfo> videos = DBTrackInfo.GetAll(); foreach (DBTrackInfo video in videos) { DBLocalMedia mediaInfo = (DBLocalMedia)video.LocalMedia[0]; if (mediaInfo.VideoResolution.StartsWith("1080") || mediaInfo.VideoResolution.StartsWith("720") || mediaInfo.VideoResolution.Equals("HD", StringComparison.OrdinalIgnoreCase)) { playlist.Add(new PlayListItem(video)); } } Player.playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_MVCENTRAL; playlist.Shuffle(); Player.playlistPlayer.Play(0); if (mvCentralCore.Settings.AutoFullscreen) { GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO); } }
private void onMediaStarted(DBLocalMedia localMedia) { // set playback active _playerState = MoviePlayerState.Playing; DBMovieInfo previousMovie = CurrentMovie; activeMedia = localMedia; // Update OSD (delayed) Thread newThread = new Thread(new ThreadStart(UpdatePlaybackInfo)); newThread.IsBackground = true; newThread.Start(); // only invoke movie started event if we were not playing this movie before if (previousMovie != CurrentMovie) { if (MovieStarted != null) { MovieStarted(CurrentMovie); } } }
/// <summary> /// Publishes Audio related Details to the skin /// </summary> /// <param name="localMedia">LocalMedia to Publish Audio Details from</param> /// <param name="forceLogging">indicate wether to log all properties</param> private void PublishAudioDetails(DBLocalMedia localMedia, bool forceLogging) { // Reset Properties ResetProperties("#MovingPictures.LocalMedia.AudioStreams"); // Retrieve Audio Details for LocalMedia var audioDetails = DBLocalMediaAudioStreams.GetAll((int)localMedia.ID); // Some totals / General things SetProperty("#MovingPictures.LocalMedia.AudioStreams.Count", audioDetails.Count.ToString(), forceLogging); SetProperty("#MovingPictures.LocalMedia.HasCommentary", audioDetails.Exists(stream => stream.AudioIsCommentary).ToString(), forceLogging); // Display Streams for (var i = 0; i < audioDetails.Count; i++) { // Empty Audio = UNKNOWN if (string.IsNullOrEmpty(audioDetails[i].AudioLanguage) || audioDetails[i].AudioLanguage == " ") audioDetails[i].AudioLanguage = "UNKNOWN"; SetProperty("#MovingPictures.LocalMedia.AudioStreams." + i + ".Enabled", "true", forceLogging); SetProperty("#MovingPictures.LocalMedia.AudioStreams." + i + ".AudioChannels", audioDetails[i].AudioChannels, forceLogging); SetProperty("#MovingPictures.LocalMedia.AudioStreams." + i + ".AudioCodec", audioDetails[i].AudioCodec, forceLogging); SetProperty("#MovingPictures.LocalMedia.AudioStreams." + i + ".AudioLanguage", audioDetails[i].AudioLanguage, forceLogging); SetProperty("#MovingPictures.LocalMedia.AudioStreams." + i + ".AudioIsCommentary", audioDetails[i].AudioIsCommentary.ToString(), forceLogging); } }
private void playMovie(DBMovieInfo movie, int requestedPart) { logger.Debug("playMovie()"); _playerState = MoviePlayerState.Processing; if (movie == null || requestedPart > movie.LocalMedia.Count || requestedPart < 1) { resetPlayer(); return; } logger.Debug("Request: Movie='{0}', Part={1}", movie.Title, requestedPart); for (int i = 0; i < movie.LocalMedia.Count; i++) { logger.Debug("LocalMedia[{0}] = {1}, Duration = {2}", i, movie.LocalMedia[i].FullPath, movie.LocalMedia[i].Duration); } int part = requestedPart; // if this is a request to start the movie from the beginning, check if we should resume // or prompt the user for disk selection if (requestedPart == 1) { // check if we should be resuming, and if not, clear resume data _resumeActive = PromptUserToResume(movie); if (_resumeActive) { part = movie.ActiveUserSettings.ResumePart; } else { clearMovieResumeState(movie); } // if we have a multi-part movie composed of disk images and we are not resuming // ask which part the user wants to play if (!_resumeActive && movie.LocalMedia.Count > 1 && (movie.LocalMedia[0].IsImageFile || movie.LocalMedia[0].IsVideoDisc)) { GUIDialogFileStacking dlg = (GUIDialogFileStacking)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_FILESTACKING); if (null != dlg) { dlg.SetNumberOfFiles(movie.LocalMedia.Count); dlg.DoModal(GUIWindowManager.ActiveWindow); part = dlg.SelectedFile; if (part < 1) { resetPlayer(); return; } } } } DBLocalMedia mediaToPlay = movie.LocalMedia[part - 1]; MediaState mediaState = mediaToPlay.State; while (mediaState != MediaState.Online) { switch (mediaState) { case MediaState.Removed: _gui.ShowMessage("Error", Translation.MediaIsMissing); resetPlayer(); return; case MediaState.Offline: string bodyString = String.Format(Translation.MediaNotAvailableBody, mediaToPlay.MediaLabel); // Special debug line to troubleshoot availability issues logger.Debug("Media not available: Path={0}, DriveType={1}, Serial={2}, ExpectedSerial={3}", mediaToPlay.FullPath, mediaToPlay.ImportPath.GetDriveType().ToString(), mediaToPlay.ImportPath.GetVolumeSerial(), mediaToPlay.VolumeSerial); // Prompt user to enter media if (!_gui.ShowCustomYesNo(Translation.MediaNotAvailableHeader, bodyString, Translation.Retry, Translation.Cancel, true)) { // user cancelled so exit resetPlayer(); return; } break; case MediaState.NotMounted: // Mount this media MountResult result = mediaToPlay.Mount(); while (result == MountResult.Pending) { if (_gui.ShowCustomYesNo(Translation.VirtualDriveHeader, Translation.VirtualDriveMessage, Translation.Retry, Translation.Cancel, true)) { // User has chosen to retry // We stay in the mount loop result = mediaToPlay.Mount(); } else { // Exit the player resetPlayer(); return; } } // If the mounting failed (can not be solved within the loop) show error and return if (result == MountResult.Failed) { _gui.ShowMessage(Translation.Error, Translation.FailedMountingImage); // Exit the player resetPlayer(); return; } // Mounting was succesfull, break the mount loop break; } // Check mediaState again mediaState = mediaToPlay.State; } // Get the path to the playable video. string videoPath = mediaToPlay.GetVideoPath(); // If the media is an image, it will be mounted by this point so // we flag the mounted playback variable mountedPlayback = mediaToPlay.IsImageFile; // if we do not have MediaInfo but have the AutoRetrieveMediaInfo setting toggled // get the media info if (!mediaToPlay.HasMediaInfo && MovingPicturesCore.Settings.AutoRetrieveMediaInfo) { mediaToPlay.UpdateMediaInfo(); mediaToPlay.Commit(); } // store the current media object so we can request it later queuedMedia = mediaToPlay; // start playback if (_resumeActive && movie.LocalMedia[0].IsBluray) { _forcePlay = true; g_Player.SetResumeBDTitleState = movie.ActiveUserSettings.ResumeTitleBD; } logger.Info("Playing: Movie='{0}' FullPath='{1}', VideoPath='{2}', Mounted='{3}'", movie.Title, mediaToPlay.FullPath, videoPath, mountedPlayback.ToString()); playFile(videoPath, mediaToPlay.VideoFormat); }
private void rescanButton_Click(object sender, EventArgs e) { unapprovedGrid.EndEdit(); foreach (DataGridViewRow currRow in unapprovedGrid.SelectedRows) { MovieMatch selectedMatch = (MovieMatch)currRow.DataBoundItem; // Check if the first file belonging to the movie is available. // Because the identification process uses the first file and it's "environment" bool continueRescan = false; while (!continueRescan) { continueRescan = true; DBLocalMedia localMedia = selectedMatch.LocalMedia[0]; // if the file is offline if (!localMedia.IsAvailable) { // do not continue continueRescan = false; // Prompt the user to insert the media containing the files string connect = string.Empty; if (localMedia.DriveLetter != null) { if (localMedia.ImportPath.GetDriveType() == DriveType.CDRom) { connect = "Please insert the disc labeled '" + localMedia.MediaLabel + "'."; } else { connect = "Please reconnect the media labeled '" + localMedia.MediaLabel + "' to " + localMedia.DriveLetter; } } else { connect = "Please make sure the network share '" + localMedia.FullPath + "' is available."; } // Show dialog DialogResult resultInsert = MessageBox.Show( "The file or files you want to rescan are currently not available.\n\n" + connect, "File(s) not available.", MessageBoxButtons.RetryCancel); // if cancel is pressed stop the rescan process. if (resultInsert == DialogResult.Cancel) { return; } } } SearchStringPopup popup = new SearchStringPopup(selectedMatch); popup.ShowDialog(this); // reprocess if (popup.DialogResult == DialogResult.OK) { MovingPicturesCore.Importer.Reprocess(selectedMatch); } } }
/// <summary> /// Marks a local media object for removal by the importer. /// This will ensure the object is securely removed from the system. /// </summary> /// <param name="localMedia">local media object.</param> /// <returns>True if the media was added to the removal queue, false if it was queued previously.</returns> public bool MarkMediaForRemoval(DBLocalMedia localMedia) { lock (filesDeleted) { if (!filesDeleted.Contains(localMedia)) { filesDeleted.Add(localMedia); return true; } } return false; }
private void RemoveCommitedRelations(DBLocalMedia file) { foreach (DBMovieInfo currMovie in file.AttachedMovies) currMovie.Delete(); file.AttachedMovies.Clear(); }
private List<Renamable> GetSecondaryFiles(DBLocalMedia mainFile) { List<Renamable> secondaryFiles = new List<Renamable>(); // grab information about files to be renamed DirectoryInfo targetDir = new DirectoryInfo(mainFile.File.DirectoryName); string[] fileExtensions = MovingPicturesCore.Settings.Rename_SecondaryFileTypes.Split('|'); // loop through our possible files and flag any exist for renaming foreach(string currFileExt in fileExtensions) { string originalNameBase = targetDir + @"\" + Path.GetFileNameWithoutExtension(mainFile.FullPath); string newNameBase = targetDir + @"\" + GetNewFileName(mainFile); FileInfo newFile = new FileInfo(originalNameBase + currFileExt); if (newFile.Exists) { RenamableFile newRenamable = new RenamableFile(mainFile.AttachedMovies[0], newFile); newRenamable.NewName = newNameBase + currFileExt; secondaryFiles.Add(newRenamable); } } return secondaryFiles; }
private void BuildGraph() { int hr; try { lblTotalTime.Text = mvs.PlayTime.ToString(); TimeSpan tt = TimeSpan.Parse(mvs.PlayTime); DateTime dt = new DateTime(tt.Ticks); lblTotalTime.Text = String.Format("{0:HH:mm:ss}", dt); if (mvs.LocalMedia[0].IsDVD) { mediaToPlay = mvs.LocalMedia[0]; MediaState mediaState = mediaToPlay.State; if (mediaState == MediaState.NotMounted) { MountResult result = mediaToPlay.Mount(); } string videoPath = mediaToPlay.GetVideoPath(); if (videoPath != null) { FirstPlayDvd(videoPath); } else { FirstPlayDvd(mvs.LocalMedia[0].File.FullName); } // Add delegates for Windowless operations AddHandlers(); MainForm_ResizeMove(null, null); } else { _graphBuilder = (IFilterGraph2) new FilterGraph(); _rotEntry = new DsROTEntry((IFilterGraph)_graphBuilder); _mediaCtrl = (IMediaControl)_graphBuilder; _mediaSeek = (IMediaSeeking)_graphBuilder; _mediaPos = (IMediaPosition)_graphBuilder; _mediaStep = (IVideoFrameStep)_graphBuilder; _vmr9Filter = (IBaseFilter) new VideoMixingRenderer9(); ConfigureVMR9InWindowlessMode(); AddHandlers(); MainForm_ResizeMove(null, null); hr = _graphBuilder.AddFilter(_vmr9Filter, "Video Mixing Render 9"); AddPreferedCodecs(_graphBuilder); DsError.ThrowExceptionForHR(hr); hr = _graphBuilder.RenderFile(mvs.LocalMedia[0].File.FullName, null); DsError.ThrowExceptionForHR(hr); } } catch (Exception e) { CloseDVDInterfaces(); logger.ErrorException("An error occured during the graph building : \r\n\r\n", e); } }
/// <summary> /// Publishes Audio related Details to the skin /// </summary> /// <param name="localMedia">LocalMedia to Publish Audio Details from</param> private void PublishAudioDetails(DBLocalMedia localMedia) { PublishAudioDetails(localMedia, true); }
/// <summary> /// Resets player variables /// </summary> private void resetPlayer() { // If we have an image mounted, unmount it if (mountedPlayback) { queuedMedia.UnMount(); mountedPlayback = false; } // reset player variables if (GUIGraphicsContext.IsFullScreenVideo) GUIGraphicsContext.IsFullScreenVideo = false; activeMedia = null; queuedMedia = null; _playerState = MoviePlayerState.Idle; _resumeActive = false; _forcePlay = false; listenToExternalPlayerEvents = false; donePlayingCustomIntros = false; customIntrosPlayed = 0; ClearPlayProperties(); logger.Debug("Reset."); }
private void onMediaStarted(DBLocalMedia localMedia) { // set playback active _playerState = MoviePlayerState.Playing; DBMovieInfo previousMovie = CurrentMovie; activeMedia = localMedia; // Update OSD (delayed) Thread newThread = new Thread(new ThreadStart(UpdatePlaybackInfo)); newThread.IsBackground = true; newThread.Start(); // only invoke movie started event if we were not playing this movie before if (previousMovie != CurrentMovie) { if (MovieStarted != null) MovieStarted(CurrentMovie); } }
private void onMediaStarted(DBLocalMedia localMedia) { // set playback active _playerState = MoviePlayerState.Playing; DBMovieInfo previousMovie = CurrentMovie; activeMedia = localMedia; // Update OSD (delayed) Thread newThread = new Thread(new ThreadStart(UpdatePlaybackInfo)); newThread.Start(); // only invoke movie started event if we were not playing this movie before if (previousMovie != CurrentMovie) { if (MovingPicturesCore.Settings.FollwitEnabled) MovingPicturesCore.Follwit.CurrentlyWatching(localMedia.AttachedMovies[0], true); if (MovieStarted != null) MovieStarted(CurrentMovie); } }
private void BuildGraph() { int hr; try { lblTotalTime.Text = mvs.PlayTime.ToString(); TimeSpan tt = TimeSpan.Parse(mvs.PlayTime); DateTime dt = new DateTime(tt.Ticks); lblTotalTime.Text = String.Format("{0:HH:mm:ss}", dt); if (mvs.LocalMedia[0].IsDVD) { mediaToPlay = mvs.LocalMedia[0]; MediaState mediaState = mediaToPlay.State; if (mediaState == MediaState.NotMounted) { MountResult result = mediaToPlay.Mount(); } string videoPath = mediaToPlay.GetVideoPath(); if (videoPath != null) FirstPlayDvd(videoPath); else FirstPlayDvd(mvs.LocalMedia[0].File.FullName); // Add delegates for Windowless operations AddHandlers(); MainForm_ResizeMove(null, null); } else { _graphBuilder = (IFilterGraph2)new FilterGraph(); _rotEntry = new DsROTEntry((IFilterGraph)_graphBuilder); _mediaCtrl = (IMediaControl)_graphBuilder; _mediaSeek = (IMediaSeeking)_graphBuilder; _mediaPos = (IMediaPosition)_graphBuilder; _mediaStep = (IVideoFrameStep)_graphBuilder; _vmr9Filter = (IBaseFilter)new VideoMixingRenderer9(); ConfigureVMR9InWindowlessMode(); AddHandlers(); MainForm_ResizeMove(null, null); hr = _graphBuilder.AddFilter(_vmr9Filter, "Video Mixing Render 9"); AddPreferedCodecs(_graphBuilder); DsError.ThrowExceptionForHR(hr); hr = _graphBuilder.RenderFile(mvs.LocalMedia[0].File.FullName, null); DsError.ThrowExceptionForHR(hr); } } catch (Exception e) { CloseDVDInterfaces(); logger.ErrorException("An error occured during the graph building : \r\n\r\n",e); } }
public override void Work() { float count = 0; float total = DBTrackInfo.GetAll().Count; if (!mvCentralCore.Settings.AutoRetrieveMediaInfo) { return; } logger.Info("Begining background media info update process."); List <DBLocalMedia> allLocalMedia = DBLocalMedia.GetAll(); foreach (DBLocalMedia lm in allLocalMedia) { if (lm.ID != null && !lm.HasMediaInfo) { lm.UpdateMediaInfo(); lm.Commit(); } } foreach (DBTrackInfo currTrack in DBTrackInfo.GetAll()) { OnProgress((count * 100) / total); count++; // Check for Artist missing data try { if (currTrack.ID == null) { continue; } if (currTrack.ArtistInfo[0].DisallowBackgroundUpdate && !mvCentralCore.Settings.BackgroundScanAlways) { continue; } logger.Debug("Checking for Artist missing deails " + currTrack.GetType().ToString() + " CurrMusicVideo.ID : " + currTrack.Track); mvCentralCore.DataProviderManager.GetArtistDetail(currTrack); // because this operation can take some time we check again // if the artist/album/track was not deleted while we were getting artwork if (currTrack.ID == null) { continue; } currTrack.Commit(); } catch (Exception e) { if (e is ThreadAbortException) { throw e; } logger.ErrorException("Error retrieving Artist details for " + currTrack.Basic, e); } // Check for Album missing data if album support enabled if (currTrack.AlbumInfo.Count > 0 && !mvCentralCore.Settings.DisableAlbumSupport) { try { if (currTrack.ID == null) { continue; } if (currTrack.ArtistInfo[0].DisallowBackgroundUpdate && !mvCentralCore.Settings.BackgroundScanAlways) { continue; } logger.Debug("Checking for Album missing deails " + currTrack.GetType().ToString() + " Title : " + currTrack.AlbumInfo[0].Album); mvCentralCore.DataProviderManager.GetAlbumDetail(currTrack); // because this operation can take some time we check again // if the artist/album/track was not deleted while we were getting artwork if (currTrack.ID == null) { continue; } currTrack.Commit(); } catch (Exception e) { if (e is ThreadAbortException) { throw e; } logger.ErrorException("Error retrieving Album details for " + currTrack.Basic, e); } } // Prevent further background updates currTrack.ArtistInfo[0].DisallowBackgroundUpdate = true; if (currTrack.AlbumInfo.Count > 0) { currTrack.AlbumInfo[0].DisallowBackgroundUpdate = true; } currTrack.Commit(); } logger.Info("Background media info update process complete."); OnProgress(100.0); }
/// <summary> /// Publishes Subtitle related Details to the skin /// </summary> /// <param name="localMedia">LocalMedia to Publish Subtitle Details from</param> private void PublishSubtitleDetails(DBLocalMedia localMedia) { PublishSubtitleDetails(localMedia, true); }
public void Play(DBMovieInfo movie, int part) { // stop the mediainfo background process if it is running MovingPicturesCore.ProcessManager.CancelProcess(typeof(MediaInfoUpdateProcess)); // stop the internal player if it's running if (g_Player.Playing) g_Player.Stop(); // set player state working _playerState = MoviePlayerState.Processing; // queue the local media object in case we first need to play the custom intro // we can get back to it later. queuedMedia = movie.LocalMedia[part-1]; // try playing our custom intro (if present). If successful quit, as we need to // wait for the intro to finish. bool success = playCustomIntro(); if (success) return; // Start movie playMovie(movie, part); }
/// <summary> /// Publishes Subtitle related Details to the skin /// </summary> /// <param name="localMedia">LocalMedia to Publish Subtitle Details from</param> /// <param name="forceLogging">indicate wether to log all properties</param> private void PublishSubtitleDetails(DBLocalMedia localMedia, bool forceLogging) { // Reset Properties ResetProperties("#MovingPictures.LocalMedia.Subtitles"); // Retrieve Subtitle Details for LocalMedia var subtitleDetails = DBLocalMediaSubtitles.GetAll((int)localMedia.ID); // Display Subtitles for (var i = 0; i < subtitleDetails.Count; i++) { SetProperty("#MovingPictures.LocalMedia.Subtitles." + i + ".Enabled", "true", forceLogging); SetProperty("#MovingPictures.LocalMedia.Subtitles." + i + ".Language", subtitleDetails[i].Language, forceLogging); SetProperty("#MovingPictures.LocalMedia.Subtitles." + i + ".Internal", subtitleDetails[i].Internal.ToString(), forceLogging); } }
private void playMovie(DBMovieInfo movie, int requestedPart) { logger.Debug("playMovie()"); _playerState = MoviePlayerState.Processing; if (movie == null || requestedPart > movie.LocalMedia.Count || requestedPart < 1) { resetPlayer(); return; } logger.Debug("Request: Movie='{0}', Part={1}", movie.Title, requestedPart); for (int i = 0; i < movie.LocalMedia.Count; i++) { logger.Debug("LocalMedia[{0}] = {1}, Duration = {2}", i, movie.LocalMedia[i].FullPath, movie.LocalMedia[i].Duration); } int part = requestedPart; // if this is a request to start the movie from the beginning, check if we should resume // or prompt the user for disk selection if (requestedPart == 1) { // check if we should be resuming, and if not, clear resume data switch (PromptUserToResume(movie)) { case ResumeDialogResult.Resume: _resumeActive = true; part = movie.ActiveUserSettings.ResumePart; break; case ResumeDialogResult.FromBeginning: _resumeActive = false; clearMovieResumeState(movie); break; case ResumeDialogResult.Cancel:return; } // if we have a multi-part movie composed of disk images and we are not resuming // ask which part the user wants to play if (!_resumeActive && movie.LocalMedia.Count > 1 && (movie.LocalMedia[0].IsImageFile || movie.LocalMedia[0].IsVideoDisc)) { GUIDialogFileStacking dlg = (GUIDialogFileStacking)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_FILESTACKING); if (null != dlg) { dlg.SetNumberOfFiles(movie.LocalMedia.Count); dlg.DoModal(GUIWindowManager.ActiveWindow); part = dlg.SelectedFile; if (part < 1) { resetPlayer(); return; } } } } DBLocalMedia mediaToPlay = movie.LocalMedia[part - 1]; MediaState mediaState = mediaToPlay.State; while (mediaState != MediaState.Online) { switch (mediaState) { case MediaState.Removed: _gui.ShowMessage("Error", Translation.MediaIsMissing); resetPlayer(); return; case MediaState.Offline: string bodyString = String.Format(Translation.MediaNotAvailableBody, mediaToPlay.MediaLabel); // Special debug line to troubleshoot availability issues logger.Debug("Media not available: Path={0}, DriveType={1}, Serial={2}, ExpectedSerial={3}", mediaToPlay.FullPath, mediaToPlay.ImportPath.GetDriveType().ToString(), mediaToPlay.ImportPath.GetVolumeSerial(), mediaToPlay.VolumeSerial); // Prompt user to enter media if (!_gui.ShowCustomYesNo(Translation.MediaNotAvailableHeader, bodyString, Translation.Retry, Translation.Cancel, true)) { // user cancelled so exit resetPlayer(); return; } break; case MediaState.NotMounted: // Mount this media MountResult result = mediaToPlay.Mount(); while (result == MountResult.Pending) { if (_gui.ShowCustomYesNo(Translation.VirtualDriveHeader, Translation.VirtualDriveMessage, Translation.Retry, Translation.Cancel, true)) { // User has chosen to retry // We stay in the mount loop result = mediaToPlay.Mount(); } else { // Exit the player resetPlayer(); return; } } // If the mounting failed (can not be solved within the loop) show error and return if (result == MountResult.Failed) { _gui.ShowMessage(Translation.Error, Translation.FailedMountingImage); // Exit the player resetPlayer(); return; } // Mounting was succesfull, break the mount loop break; } // Check mediaState again mediaState = mediaToPlay.State; } // Get the path to the playable video. string videoPath = mediaToPlay.GetVideoPath(); // If the media is an image, it will be mounted by this point so // we flag the mounted playback variable mountedPlayback = mediaToPlay.IsImageFile; // if we do not have MediaInfo but have the AutoRetrieveMediaInfo setting toggled // get the media info if (!mediaToPlay.HasMediaInfo && MovingPicturesCore.Settings.AutoRetrieveMediaInfo) { mediaToPlay.UpdateMediaInfo(); mediaToPlay.Commit(); } // store the current media object so we can request it later queuedMedia = mediaToPlay; // start playback if (_resumeActive && movie.LocalMedia[0].IsBluray) { _forcePlay = true; g_Player.SetResumeBDTitleState = movie.ActiveUserSettings.ResumeTitleBD; } logger.Info("Playing: Movie='{0}' FullPath='{1}', VideoPath='{2}', Mounted='{3}'", movie.Title, mediaToPlay.FullPath, videoPath, mountedPlayback.ToString()); playFile(videoPath, mediaToPlay.VideoFormat); }
// add part information as needed private string AddPartInfo(string baseFileName, DBLocalMedia file) { string newFileName = baseFileName; DBMovieInfo movie = file.AttachedMovies[0]; int part = movie.LocalMedia.IndexOf(file) + 1; // either add the correct part number or remove the part substring as needed if (movie.LocalMedia.Count > 1) newFileName = newFileName.Replace("#", part.ToString()); else newFileName = newFileName.Replace(MovingPicturesCore.Settings.FileMultipartString, ""); return newFileName; }
// method replaces encoded file rename string to contain movie specific information. private string GetNewFileName(DBLocalMedia file) { // use existing or generate new base filename string baseFileName; if (baseFileNameLookup.ContainsKey(file.AttachedMovies[0])) baseFileName = baseFileNameLookup[file.AttachedMovies[0]]; else { // parse variables in pattern for base filename string pattern = MovingPicturesCore.Settings.FileRenameString; baseFileName = ReplaceVariables(file.AttachedMovies[0], pattern); // store the new base filename for reuse later baseFileNameLookup[file.AttachedMovies[0]] = baseFileName; } // add multipart information as needed string newFileName = AddPartInfo(baseFileName, file); // remove characters not accepted by the OS in a filename newFileName = Regex.Replace(newFileName, @"[?:\/*""<>|]", ""); // remove any unwanted double spacing due to missing variables newFileName = newFileName.Trim(); newFileName = newFileName.Replace(" ", " "); return newFileName; }