Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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;
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        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;
            }
        }