protected override void OnClick(int itemIndex) { currentSelectedItem = facadeLayout.SelectedListItemIndex; GUIListItem item = facadeLayout.SelectedListItem; if (item == null) { return; } if (item.IsFolder) { return; } // If the file is an image file, it should be mounted before playing if (VirtualDirectory.IsImageFile(System.IO.Path.GetExtension(item.Path))) { if (!GUIVideoFiles.MountImageFile(GUIWindowManager.ActiveWindow, item.Path, true)) { return; } } playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_VIDEO; playlistPlayer.Reset(); playlistPlayer.Play(itemIndex); }
protected override void OnPageLoad() { int previousWindow = GUIWindowManager.GetPreviousActiveWindow(); // Reset parameters if previous window is not one of video windows if (!GUIVideoFiles.IsVideoWindow(previousWindow)) { ageConfirmed = false; currentPin = 0; currentProtectedShare.Clear(); _currentLevel = 0; } string view = VideoState.View; if (view == string.Empty) { view = ((ViewDefinition)handler.Views[0]).Name; } handler.CurrentView = view; // Resume view lvl position (back from VideoInfo window) handler.CurrentLevel = _currentLevel; base.OnPageLoad(); LoadDirectory(currentFolder); GetProtectedShares(ref protectedShares); SetPinLockSkinProperties(); }
/// <summary> /// Plays a MpVideos movie /// </summary> /// <param name="id"></param> /// <param name="startPos"></param> internal static void PlayVideo(int id, int startPos) { //Code mostly copied from WindowPlugins -> GUIVideoFiles -> GuiVideoTitle.cs IMDBMovie movie = new IMDBMovie(); VideoDatabase.GetMovieInfoById(id, ref movie); if (movie == null && movie.ID < 0) { WifiRemote.LogMessage("No video found for id " + id, WifiRemote.LogType.Warn); return; } GUIVideoFiles.Reset(); // reset pincode ArrayList files = new ArrayList(); //Code for MediaPortal 1.3 Beta and higher VideoDatabase.GetFilesForMovie(movie.ID, ref files); if (files.Count > 1) { GUIVideoFiles.StackedMovieFiles = files; GUIVideoFiles.IsStacked = true; } else { GUIVideoFiles.IsStacked = false; } GUIVideoFiles.MovieDuration(files, false); GUIVideoFiles.PlayMovie(movie.ID, false); }
protected override void OnShowContextMenu() { GUIListItem item = listActorMovies.SelectedListItem; if (item == null) { return; } var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(498); // menu dlg.AddLocalizedString(1296); // Refresh all actor movies dlg.AddLocalizedString(1290); // Refresh selected movie if (item.IsPlayed) // Movie in MP database { dlg.AddLocalizedString(208); // Play dlg.AddLocalizedString(368); // IMDB } dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } switch (dlg.SelectedId) { case 1296: // Refresh All actor movies _forceRefreshAll = true; OnRefreshMovie(); break; case 1290: // Refresh selected movie _forceRefreshAll = true; OnRefreshSingleMovie(); break; case 208: // Play try { GUIVideoFiles.PlayMovie(Convert.ToInt32(item.DVDLabel), true); } catch {} break; case 368: // IMDB OnMovieInfo(item); break; } }
protected override void SetView(int selectedViewId) { switch (selectedViewId) { case 0: // Shares { int nNewWindow = (int)Window.WINDOW_VIDEOS; VideoState.StartWindow = nNewWindow; if (nNewWindow != GetID) { GUIVideoFiles.Reset(); GUIWindowManager.ReplaceWindow(nNewWindow); } } break; default: // a db view { ViewDefinition selectedView = (ViewDefinition)handler.Views[selectedViewId - 1]; handler.CurrentView = selectedView.Name; VideoState.View = selectedView.Name; int nNewWindow = (int)Window.WINDOW_VIDEO_TITLE; // Reset search variables if (GUIVideoTitle.CurrentViewHistory != handler.CurrentLevelWhere) { GUIVideoTitle.IsActorSearch = false; GUIVideoTitle.IsMovieSearch = false; GUIVideoTitle.ActorSearchString = string.Empty; GUIVideoTitle.MovieSearchString = string.Empty; GUIVideoTitle.MovieSearchDbFieldString = string.Empty; } if (GetID != nNewWindow) { VideoState.StartWindow = nNewWindow; if (nNewWindow != GetID) { GUIWindowManager.ReplaceWindow(nNewWindow); } } else { LoadDirectory(string.Empty); if (facadeLayout.Count <= 0) { GUIControl.FocusControl(GetID, btnLayouts.GetID); } } } break; } }
protected override void OnClick(int itemIndex) { GUIListItem item = facadeLayout.SelectedListItem; if (item == null) { return; } if (item.IsFolder) { currentSelectedItem = -1; if (item.Label == "..") { handler.CurrentLevel--; } else { IMDBMovie movie = item.AlbumInfoTag as IMDBMovie; ((VideoViewHandler)handler).Select(movie); } LoadDirectory(item.Path); } else { IMDBMovie movie = item.AlbumInfoTag as IMDBMovie; if (movie == null) { return; } if (movie.ID < 0) { return; } GUIVideoFiles.Reset(); // reset pincode ArrayList files = new ArrayList(); VideoDatabase.GetFiles(movie.ID, ref files); if (files.Count > 1) { GUIVideoFiles._stackedMovieFiles = files; GUIVideoFiles._isStacked = true; GUIVideoFiles.MovieDuration(files); } else { GUIVideoFiles._isStacked = false; } GUIVideoFiles.PlayMovie(movie.ID, false); } }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { base.OnClicked(controlId, control, actionType); // // Movies // if (control == btnMovies) { _viewmode = ViewMode.Movies; Update(); } // // Biography // if (control == btnBiography) { _viewmode = ViewMode.Biography; Update(); } // // List control item // if (control == listActorMovies) { if (listActorMovies.SelectedListItem.IsPlayed) { try { if (_movieInfoBeforePlay && !_playClicked) { OnMovieInfo(listActorMovies.SelectedListItem); return; } _playClicked = false; GUIVideoFiles.PlayMovie(Convert.ToInt32(listActorMovies.SelectedListItem.DVDLabel), true); } catch { } } else { _playClicked = false; _forceRefreshAll = true; OnRefreshSingleMovie(); } } }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { base.OnClicked(controlId, control, actionType); if (control == btnShuffle) { OnShufflePlayList(); } else if (control == btnSave) { OnSavePlayList(); } else if (control == btnClear) { OnClearPlayList(); } else if (control == btnPlay) { GUIListItem item = facadeLayout.SelectedListItem; // If the file is an image file, it should be mounted before playing if (VirtualDirectory.IsImageFile(System.IO.Path.GetExtension(item.Path))) { if (!GUIVideoFiles.MountImageFile(GUIWindowManager.ActiveWindow, item.Path, true)) { return; } } playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_VIDEO; playlistPlayer.Reset(); playlistPlayer.Play(facadeLayout.SelectedListItemIndex); UpdateButtonStates(); } else if (control == btnNext) { playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_VIDEO; GUIVideoFiles.PlayMovieFromPlayList(true, true); } else if (control == btnPrevious) { playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_VIDEO; playlistPlayer.PlayPrevious(); } else if ((btnRepeatPlaylist != null) && (control == btnRepeatPlaylist)) { playlistPlayer.RepeatPlaylist = btnRepeatPlaylist.Selected; } }
protected override void OnPageDestroy(int newWindowId) { SaveSettings(); // Save view using (Profile.Settings xmlwriter = new Profile.MPSettings()) { // Save only MyVideos window views if (GUIVideoFiles.IsVideoWindow(VideoState.StartWindow)) { xmlwriter.SetValue("movies", "startWindow", VideoState.StartWindow.ToString()); xmlwriter.SetValue("movies", "startview", VideoState.View); } } m_bPlaylistsLayout = false; base.OnPageDestroy(newWindowId); }
private void SaveExtensions() { ArrayList aExtensions = new ArrayList(); foreach (var lItem in extensionsListcontrol.ListItems) { aExtensions.Add(lItem.Label); } aExtensions.Sort(); string extensions = string.Empty; foreach (string aExtension in aExtensions) { extensions = extensions + aExtension + ","; } extensions = extensions.Remove(extensions.LastIndexOf(",")); using (Profile.Settings xmlwriter = new MPSettings()) { xmlwriter.SetValue(_section, "extensions", extensions); } switch (_section) { case "movies": GUIVideoFiles.ResetExtensions(aExtensions); break; case "music": GUIMusicFiles.ResetExtensions(aExtensions); break; case "pictures": Pictures.GUIPictures.ResetExtensions(aExtensions); break; } }
internal void PlayMovie(int index) { GUIVideoFiles.Reset(); // reset pincode ArrayList files = new ArrayList(); IMDBMovie movie = (IMDBMovie)latestMyVideosForPlay[index]; VideoDatabase.GetFilesForMovie(movie.ID, ref files); if (files.Count > 1) { GUIVideoFiles.StackedMovieFiles = files; GUIVideoFiles.IsStacked = true; } else { GUIVideoFiles.IsStacked = false; } GUIVideoFiles.MovieDuration(files, false); GUIVideoFiles.PlayMovie(movie.ID, false); }
protected virtual void SetLabels() { bool isShareView = false; if (GUIWindowManager.ActiveWindow == (int)Window.WINDOW_VIDEOS) { isShareView = true; } bool _stackedFolder = true; if (isShareView) { _currentFolder = GUIVideoFiles.GetCurrentFolder; object o; MediaPortal.Database.FolderSettings.GetFolderSetting(_currentFolder, "VideoFiles", typeof(GUIVideoFiles.MapSettings), out o); if (o != null) { GUIVideoFiles.MapSettings mapSettings = o as GUIVideoFiles.MapSettings; _stackedFolder = mapSettings.Stack; } } else { _currentFolder = GUIVideoTitle.GetCurrentView; object o; // MediaPortal.Database.FolderSettings.GetFolderSetting(_currentFolder, "VideoViews", typeof(GUIVideoTitle.MapSettings), out o); MediaPortal.Database.FolderSettings.GetViewSetting(_currentFolder, "VideoViews", typeof(GUIVideoTitle.MapSettings), out o); if (o != null) { GUIVideoTitle.MapSettings mapSettings = o as GUIVideoTitle.MapSettings; if (mapSettings != null) { CurrentSortMethod = (VideoSort.SortMethod)mapSettings.SortBy; CurrentSortAsc = mapSettings.SortAscending; } } } for (int i = 0; i < facadeLayout.Count; ++i) { GUIListItem item = facadeLayout[i]; IMDBMovie movie = item.AlbumInfoTag as IMDBMovie; if (movie != null && movie.ID > 0 && !isShareView && (!item.IsFolder || CurrentSortMethod == VideoSort.SortMethod.NameAll)) { if (CurrentSortMethod == VideoSort.SortMethod.Name || CurrentSortMethod == VideoSort.SortMethod.NameAll || CurrentSortMethod == VideoSort.SortMethod.Name_With_Duration) { if (item.IsFolder) { item.Label2 = string.Empty; } else { // Show real movie duration (from video file) int mDuration = VideoDatabase.GetMovieDuration(movie.ID); if (mDuration <= 0) { ArrayList mFiles = new ArrayList(); VideoDatabase.GetFilesForMovie(movie.ID, ref mFiles); mDuration = GUIVideoFiles.MovieDuration(mFiles, true); if (mDuration <= 0) { item.Label2 = Util.Utils.SecondsToHMString(movie.RunTime * 60); } else { item.Label2 = Util.Utils.SecondsToHMString(mDuration); } } else { item.Label2 = Util.Utils.SecondsToHMString(mDuration); } } } else if (CurrentSortMethod == VideoSort.SortMethod.Year) { item.Label2 = movie.Year.ToString(); } else if (CurrentSortMethod == VideoSort.SortMethod.Rating) { item.Label2 = movie.Rating.ToString(); } else if (CurrentSortMethod == VideoSort.SortMethod.Label) { item.Label2 = movie.DVDLabel.ToString(); } else if (CurrentSortMethod == VideoSort.SortMethod.Size) { if (item.FileInfo != null) { item.Label2 = Util.Utils.GetSize(item.FileInfo.Length); } else { item.Label2 = Util.Utils.SecondsToHMString(movie.RunTime * 60); } } else if (!isShareView && CurrentSortMethod == VideoSort.SortMethod.Date) { string strDate = string.Empty; if (!item.IsFolder && movie != null) { if (movie.DateAdded != "0001-01-01 00:00:00") { strDate = movie.DateAdded; } else { strDate = movie.LastUpdate; } } item.Label2 = strDate; } } else { string strSize1 = string.Empty, strDate = string.Empty; if (item.FileInfo != null && !item.IsFolder) { strSize1 = Util.Utils.GetSize(item.FileInfo.Length); } if (item.FileInfo != null && !item.IsFolder) { if (CurrentSortMethod == VideoSort.SortMethod.Modified) { strDate = item.FileInfo.ModificationTime.ToShortDateString() + " " + item.FileInfo.ModificationTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat); } else { strDate = item.FileInfo.CreationTime.ToShortDateString() + " " + item.FileInfo.CreationTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat); } } if (CurrentSortMethod == VideoSort.SortMethod.Name || CurrentSortMethod == VideoSort.SortMethod.NameAll) { if (item.IsFolder) { item.Label2 = string.Empty; } else { item.Label2 = strSize1; } } if (CurrentSortMethod == VideoSort.SortMethod.Name_With_Duration && !item.IsFolder && item.Label != "..") { if (_stackedFolder) { int newMovieId = VideoDatabase.GetMovieId(item.Path); item.Duration = VideoDatabase.GetMovieDuration(newMovieId); } else { int fileID = VideoDatabase.GetFileId(item.Path); item.Duration = VideoDatabase.GetVideoDuration(fileID); } if (item.Duration > 0) { item.Label2 = Util.Utils.SecondsToShortHMSString(item.Duration); } else { item.Label2 = string.Empty; } } else if (CurrentSortMethod == VideoSort.SortMethod.Created || CurrentSortMethod == VideoSort.SortMethod.Date || CurrentSortMethod == VideoSort.SortMethod.Modified) { if (!isShareView && CurrentSortMethod == VideoSort.SortMethod.Date && string.IsNullOrWhiteSpace(strDate)) { if (!item.IsFolder && movie != null) { if (movie.DateAdded != "0001-01-01 00:00:00") { strDate = movie.DateAdded; } else { strDate = movie.LastUpdate; } } } item.Label2 = strDate; } else { if (item.IsFolder) { item.Label2 = string.Empty; } else { item.Label2 = strSize1; } } } } }
// Changed - covers and the same movie name protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { base.OnClicked(controlId, control, actionType); if (control == btnRefresh) { // Check Internet connection if (!Win32API.IsConnectedToInternet()) { GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(257); dlgOk.SetLine(1, GUILocalizeStrings.Get(703)); dlgOk.DoModal(GUIWindowManager.ActiveWindow); return; } string title = currentMovie.Title; int id = currentMovie.ID; string file = currentMovie.Path + "\\" + currentMovie.File; // Delete covers FanArt.DeleteCovers(title, id); //Delete fanarts FanArt.DeleteFanarts(file, title); if (IMDBFetcher.RefreshIMDB(this, ref currentMovie, false, false, true)) { if ((imageSearchThread != null) && (imageSearchThread.IsAlive)) { imageSearchThread.Abort(); imageSearchThread = null; } imdbCoverArtUrl = currentMovie.ThumbURL; coverArtUrls = new string[1]; coverArtUrls[0] = imdbCoverArtUrl; ResetSpinControl(); Refresh(false); Update(); // Start images search thread SearchImages(); } return; } if (control == spinImages) { int item = spinImages.Value - 1; if (item < 0 || item >= coverArtUrls.Length) { item = 0; } if (currentMovie.ThumbURL == coverArtUrls[item]) { return; } currentMovie.ThumbURL = coverArtUrls[item]; // Title suffix for problem with covers and movie with the same name string titleExt = currentMovie.Title + "{" + currentMovie.ID + "}"; string coverArtImage = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt); string largeCoverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt); Util.Utils.FileDelete(coverArtImage); // // 07.11.2010 Deda: Cache entry Flag change for cover thumb file // Util.Utils.DoInsertNonExistingFileIntoCache(coverArtImage); // Util.Utils.FileDelete(largeCoverArtImage); Refresh(false); Update(); int idMovie = currentMovie.ID; if (idMovie >= 0) { VideoDatabase.SetThumbURL(idMovie, currentMovie.ThumbURL); } return; } if (control == btnCast) { viewmode = ViewMode.Cast; Update(); } if (control == btnPlot) { viewmode = ViewMode.Plot; Update(); } if (control == btnReview) { viewmode = ViewMode.Review; Update(); } if (control == btnWatched) { if (currentMovie.Watched > 0) { GUIPropertyManager.SetProperty("#iswatched", "no"); currentMovie.Watched = 0; VideoDatabase.SetMovieWatchedStatus(currentMovie.ID, false); ArrayList files = new ArrayList(); VideoDatabase.GetFiles(currentMovie.ID, ref files); foreach (string file in files) { int fileId = VideoDatabase.GetFileId(file); VideoDatabase.DeleteMovieStopTime(fileId); } } else { GUIPropertyManager.SetProperty("#iswatched", "yes"); currentMovie.Watched = 1; VideoDatabase.SetMovieWatchedStatus(currentMovie.ID, true); } VideoDatabase.SetWatched(currentMovie); } if (control == spinDisc) { string selectedItem = spinDisc.GetLabel(); int idMovie = currentMovie.ID; if (idMovie > 0) { if (selectedItem != "HD" && selectedItem != "share") { VideoDatabase.SetDVDLabel(idMovie, selectedItem); } else { VideoDatabase.SetDVDLabel(idMovie, "HD"); } } } if (control == btnPlay) { int id = currentMovie.ID; ArrayList files = new ArrayList(); VideoDatabase.GetFiles(id, ref files); if (files.Count > 1) { GUIVideoFiles._stackedMovieFiles = files; GUIVideoFiles._isStacked = true; GUIVideoFiles.MovieDuration(files); } GUIVideoFiles.PlayMovie(id, false); return; } }
/// <summary> /// Initiates Playback of m_currentEpisode[DBEpisode.cFilename] and calls Fullscreen Window /// </summary> /// <param name="timeMovieStopped">Resumepoint of Movie, 0 or negative for Start from Beginning</param> /// bool Play(int timeMovieStopped) { bool result = false; try { // sometimes it takes up to 30+ secs to go to fullscreen even though the video is already playing // lets force fullscreen here // note: MP might still be unresponsive during this time, but at least we are in fullscreen and can see video should this happen // I haven't actually found out why it happens, but I strongly believe it has something to do with the video database and the player doing something in the background // (why does it do anything with the video database.....i just want it to play a file and do NOTHING else!) GUIGraphicsContext.IsFullScreenVideo = true; GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO); // If the file is an image file, it should be mounted before playing string filename = m_currentEpisode[DBEpisode.cFilename]; if (m_bIsImageFile) { if (!GUIVideoFiles.MountImageFile(GUIWindowManager.ActiveWindow, filename, false)) { return(false); } } // Start Listening to any External Player Events listenToExternalPlayerEvents = true; #region Publish Play properties for InfoService plugin string seriesName = Helper.getCorrespondingSeries(m_currentEpisode[DBEpisode.cSeriesID]).ToString(); string seasonID = m_currentEpisode[DBEpisode.cSeasonIndex]; string episodeID = m_currentEpisode[DBEpisode.cEpisodeIndex]; string episodeName = m_currentEpisode[DBEpisode.cEpisodeName]; GUIPropertyManager.SetProperty("#TVSeries.Extended.Title", string.Format("{0}/{1}/{2}/{3}", seriesName, seasonID, episodeID, episodeName)); MPTVSeriesLog.Write(string.Format("#TVSeries.Extended.Title: {0}/{1}/{2}/{3}", seriesName, seasonID, episodeID, episodeName)); #endregion // tell any listeners that we are starting playback if (EpisodeStarted != null) { EpisodeStarted(m_currentEpisode); } // Play File result = g_Player.Play(filename, g_Player.MediaType.Video); // Stope Listening to any External Player Events listenToExternalPlayerEvents = false; // tell player where to resume if (g_Player.Playing && timeMovieStopped > 0) { MPTVSeriesLog.Write("Setting seek position at: " + timeMovieStopped, MPTVSeriesLog.LogLevel.Debug); GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SEEK_POSITION, 0, 0, 0, 0, 0, null); msg.Param1 = (int)timeMovieStopped; GUIGraphicsContext.SendMessage(msg); } } catch (Exception e) { MPTVSeriesLog.Write("TVSeriesPlugin.VideoHandler.Play()\r\n" + e.ToString()); result = false; } return(result); }
protected void LoadPlayList(string strPlayList) { IPlayListIO loader = PlayListFactory.CreateIO(strPlayList); if (loader == null) { return; } PlayList playlist = new PlayList(); if (!loader.Load(playlist, strPlayList)) { TVSeriesPlugin.ShowDialogOk(Translation.Playlist, new string[] { GUILocalizeStrings.Get(477) }); return; } playlistPlayer.CurrentPlaylistName = System.IO.Path.GetFileNameWithoutExtension(strPlayList); if (playlist.Count == 1 && playlistPlayer.PlaylistAutoPlay) { MPTVSeriesLog.Write(string.Format("GUITVSeriesPlaylist: play single playlist item - {0}", playlist[0].FileName)); // If the file is an image file, it should be mounted before playing string filename = playlist[0].FileName; if (Helper.IsImageFile(filename)) { if (!GUIVideoFiles.MountImageFile(GUIWindowManager.ActiveWindow, filename, false)) { return; } } if (g_Player.Play(filename)) { if (MediaPortal.Util.Utils.IsVideo(filename)) { g_Player.ShowFullScreenWindow(); } } return; } // clear current playlist playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES).Clear(); // add each item of the playlist to the playlistplayer for (int i = 0; i < playlist.Count; ++i) { PlayListItem playListItem = playlist[i]; playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES).Add(playListItem); } // if we got a playlist if (playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES).Count > 0) { playlist = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES); // autoshuffle on load if (playlistPlayer.PlaylistAutoShuffle) { playlist.Shuffle(); } // then get 1st item PlayListItem item = playlist[0]; // and start playing it if (playlistPlayer.PlaylistAutoPlay) { playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_TVSERIES; playlistPlayer.Reset(); playlistPlayer.Play(0); } // and activate the playlist window if its not activated yet if (GetID == GUIWindowManager.ActiveWindow) { GUIWindowManager.ActivateWindow(GetID); } } }
protected virtual void SetLabels() { bool isShareView = false; if (GUIWindowManager.ActiveWindow == (int)Window.WINDOW_VIDEOS) { isShareView = true; } for (int i = 0; i < facadeLayout.Count; ++i) { GUIListItem item = facadeLayout[i]; IMDBMovie movie = item.AlbumInfoTag as IMDBMovie; if (movie != null && movie.ID > 0 && !isShareView && (!item.IsFolder || CurrentSortMethod == VideoSort.SortMethod.NameAll)) { if (CurrentSortMethod == VideoSort.SortMethod.Name || CurrentSortMethod == VideoSort.SortMethod.NameAll) { if (item.IsFolder) { item.Label2 = string.Empty; } else { // Show real movie duration (from video file) int mDuration = VideoDatabase.GetMovieDuration(movie.ID); if (mDuration <= 0) { ArrayList mFiles = new ArrayList(); VideoDatabase.GetFilesForMovie(movie.ID, ref mFiles); mDuration = GUIVideoFiles.MovieDuration(mFiles, true); if (mDuration <= 0) { item.Label2 = Util.Utils.SecondsToHMString(movie.RunTime * 60); } else { item.Label2 = Util.Utils.SecondsToHMString(mDuration); } } else { item.Label2 = Util.Utils.SecondsToHMString(mDuration); } } } else if (CurrentSortMethod == VideoSort.SortMethod.Year) { item.Label2 = movie.Year.ToString(); } else if (CurrentSortMethod == VideoSort.SortMethod.Rating) { item.Label2 = movie.Rating.ToString(); } else if (CurrentSortMethod == VideoSort.SortMethod.Label) { item.Label2 = movie.DVDLabel.ToString(); } else if (CurrentSortMethod == VideoSort.SortMethod.Size) { if (item.FileInfo != null) { item.Label2 = Util.Utils.GetSize(item.FileInfo.Length); } else { item.Label2 = Util.Utils.SecondsToHMString(movie.RunTime * 60); } } } else { string strSize1 = string.Empty, strDate = string.Empty; if (item.FileInfo != null && !item.IsFolder) { strSize1 = Util.Utils.GetSize(item.FileInfo.Length); } if (item.FileInfo != null && !item.IsFolder) { if (CurrentSortMethod == VideoSort.SortMethod.Modified) { strDate = item.FileInfo.ModificationTime.ToShortDateString() + " " + item.FileInfo.ModificationTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat); } else { strDate = item.FileInfo.CreationTime.ToShortDateString() + " " + item.FileInfo.CreationTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat); } } if (CurrentSortMethod == VideoSort.SortMethod.Name || CurrentSortMethod == VideoSort.SortMethod.NameAll) { if (item.IsFolder) { item.Label2 = string.Empty; } else { item.Label2 = strSize1; } } else if (CurrentSortMethod == VideoSort.SortMethod.Created || CurrentSortMethod == VideoSort.SortMethod.Date || CurrentSortMethod == VideoSort.SortMethod.Modified) { item.Label2 = strDate; } else { if (item.IsFolder) { item.Label2 = string.Empty; } else { item.Label2 = strSize1; } } } } }
public void SaveSettings(string section) { if (AddOpticalDiskDrives) { AddStaticShares(DriveType.DVD, "DVD"); } using (Profile.Settings xmlwriter = new MPSettings()) { string defaultShare = string.Empty; for (int index = 0; index < 128; index++) { string shareName = String.Format("sharename{0}", index); string sharePath = String.Format("sharepath{0}", index); string sharePin = String.Format("pincode{0}", index); string shareType = String.Format("sharetype{0}", index); string shareServer = String.Format("shareserver{0}", index); string shareLogin = String.Format("sharelogin{0}", index); string sharePwd = String.Format("sharepassword{0}", index); string sharePort = String.Format("shareport{0}", index); string shareRemotePath = String.Format("shareremotepath{0}", index); string shareViewPath = String.Format("shareview{0}", index); xmlwriter.RemoveEntry(section, shareName); xmlwriter.RemoveEntry(section, sharePath); xmlwriter.RemoveEntry(section, sharePin); xmlwriter.RemoveEntry(section, shareType); xmlwriter.RemoveEntry(section, shareServer); xmlwriter.RemoveEntry(section, shareLogin); xmlwriter.RemoveEntry(section, sharePwd); xmlwriter.RemoveEntry(section, sharePort); xmlwriter.RemoveEntry(section, shareRemotePath); xmlwriter.RemoveEntry(section, shareViewPath); if (section == "music" || section == "movies") { string shareScan = String.Format("sharescan{0}", index); xmlwriter.RemoveEntry(section, shareScan); } if (section == "movies") { string thumbs = String.Format("videothumbscreate{0}", index); xmlwriter.RemoveEntry(section, thumbs); string movieFolder = String.Format("eachfolderismovie{0}", index); xmlwriter.RemoveEntry(section, movieFolder); } string shareNameData = string.Empty; string sharePathData = string.Empty; string sharePinData = string.Empty; bool shareTypeData = false; string shareServerData = string.Empty; string shareLoginData = string.Empty; string sharePwdData = string.Empty; int sharePortData = 21; string shareRemotePathData = string.Empty; int shareLayout = (int)MediaPortal.GUI.Library.GUIFacadeControl.Layout.List; bool shareScanData = false; //ThumbsCreate (default true) bool thumbsCreate = true; bool folderIsMovie = false; if (_shareListControl != null && _shareListControl.Count > index) { ShareData shareData = _shareListControl[index].AlbumInfoTag as ShareData; if (shareData != null && !String.IsNullOrEmpty(shareData.Name)) { shareNameData = shareData.Name; sharePathData = shareData.Folder; sharePinData = shareData.PinCode; shareTypeData = shareData.IsRemote; shareServerData = shareData.Server; shareLoginData = shareData.LoginName; sharePwdData = shareData.PassWord; sharePortData = shareData.Port; shareRemotePathData = shareData.RemoteFolder; shareLayout = (int)shareData.DefaultLayout; shareScanData = shareData.ScanShare; // ThumbsCreate thumbsCreate = shareData.CreateThumbs; folderIsMovie = shareData.EachFolderIsMovie; if (shareNameData == _defaultShare) { defaultShare = shareNameData; } xmlwriter.SetValue(section, shareName, shareNameData); xmlwriter.SetValue(section, sharePath, sharePathData); xmlwriter.SetValue(section, sharePin, Util.Utils.EncryptPin(sharePinData)); xmlwriter.SetValueAsBool(section, shareType, shareTypeData); xmlwriter.SetValue(section, shareServer, shareServerData); xmlwriter.SetValue(section, shareLogin, shareLoginData); xmlwriter.SetValue(section, sharePwd, sharePwdData); xmlwriter.SetValue(section, sharePort, sharePortData.ToString()); xmlwriter.SetValue(section, shareRemotePath, shareRemotePathData); xmlwriter.SetValue(section, shareViewPath, shareLayout); if (section == "music" || section == "movies") { string shareScan = String.Format("sharescan{0}", index); xmlwriter.SetValueAsBool(section, shareScan, shareScanData); } if (section == "movies") { string thumbs = String.Format("videothumbscreate{0}", index); xmlwriter.SetValueAsBool(section, thumbs, thumbsCreate); string folderMovie = String.Format("eachfolderismovie{0}", index); xmlwriter.SetValueAsBool(section, folderMovie, folderIsMovie); } } } } xmlwriter.SetValue(section, "default", defaultShare); xmlwriter.SetValueAsBool(section, "rememberlastfolder", RememberLastFolder); xmlwriter.SetValueAsBool(section, "AddOpticalDiskDrives", AddOpticalDiskDrives); xmlwriter.SetValueAsBool(section, "SwitchRemovableDrives", SwitchRemovableDrives); } // Set new shares for internal plugins switch (section) { case "movies": GUIVideoFiles.ResetShares(); break; case "music": GUIMusicFiles.ResetShares(); break; case "pictures": GUIPictures.ResetShares(); break; } }
public bool Play(int iItem) { // if play returns false PlayNext is called but this does not help against selecting an invalid file bool skipmissing = false; do { if (_currentPlayList == PlayListType.PLAYLIST_NONE) { MPTVSeriesLog.Write("PlaylistPlayer.Play() no playlist selected", MPTVSeriesLog.LogLevel.Debug); return(false); } PlayList playlist = GetPlaylist(_currentPlayList); if (playlist.Count <= 0) { MPTVSeriesLog.Write("PlaylistPlayer.Play() playlist is empty", MPTVSeriesLog.LogLevel.Debug); return(false); } if (iItem < 0) { iItem = 0; } if (iItem >= playlist.Count) { if (skipmissing) { return(false); } else { if (_entriesNotFound < playlist.Count) { iItem = playlist.Count - 1; } else { return(false); } } } _currentItem = iItem; PlayListItem item = playlist[_currentItem]; GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS, 0, 0, 0, _currentItem, 0, null); msg.Label = item.FileName; GUIGraphicsContext.SendMessage(msg); if (playlist.AllPlayed()) { playlist.ResetStatus(); } bool playResult = false; // If the file is an image file, it should be mounted before playing string filename = item.FileName; if (Helper.IsImageFile(filename)) { if (!GUIVideoFiles.MountImageFile(GUIWindowManager.ActiveWindow, filename, false)) { return(false); } } // Start Listening to any External Player Events listenToExternalPlayerEvents = true; #region Publish Play properties for InfoService plugin string seriesName = item.SeriesName; string seasonID = item.SeasonIndex; string episodeID = item.EpisodeIndex; string episodeName = item.EpisodeName; GUIPropertyManager.SetProperty("#TVSeries.Extended.Title", string.Format("{0}/{1}/{2}/{3}", seriesName, seasonID, episodeID, episodeName)); MPTVSeriesLog.Write(string.Format("#TVSeries.Extended.Title: {0}/{1}/{2}/{3}", seriesName, seasonID, episodeID, episodeName)); #endregion // Play File playResult = g_Player.Play(filename); // Stope Listening to any External Player Events listenToExternalPlayerEvents = false; if (!playResult) { // Count entries in current playlist // that couldn't be played _entriesNotFound++; MPTVSeriesLog.Write(string.Format("PlaylistPlayer: *** unable to play - {0} - skipping file!", item.FileName)); // do not try to play the next file list if (Utils.IsVideo(item.FileName)) { skipmissing = false; } else { skipmissing = true; } iItem++; } else { item.Played = true; item.IsWatched = true; // for facade watched icons skipmissing = false; if (Utils.IsVideo(item.FileName)) { if (g_Player.HasVideo) { // tell any listeners that we are starting playback if (EpisodeStarted != null) { EpisodeStarted(item.Episode); } g_Player.ShowFullScreenWindow(); Thread.Sleep(2000); SetProperties(item, false); } } } }while (skipmissing); return(g_Player.Playing); }