Example #1
0
        /// <summary>
        /// Scans a bluray folder and returns a BDInfo object
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        private static BDInfoExt ScanWorker(string path)
        {
            BDPlayerBuilder.LogInfo("Scanning bluray structure: {0}", path);
            BDInfoExt bluray = new BDInfoExt(path.ToUpper(), true); // For title selection we need all information here, but this can cause quite big delays for remote resources!

            bluray.Scan();
            return(bluray);
        }
Example #2
0
        /// <summary>
        /// Returns wether a choice was made and changes the file path
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns>True if playback should continue, False if user cancelled.</returns>
        private bool DoFeatureSelection(ref string filePath)
        {
            try
            {
                // If we have chosen a specific playlist, build the path directly without scanning the complete structure again
                if (_manualTitleSelection != null && !string.IsNullOrEmpty(_playlistFolder))
                {
                    filePath = Path.Combine(_playlistFolder, _manualTitleSelection.Name);
                    GetChapters(_manualTitleSelection);
                    _manualTitleSelection = null;
                    return(true);
                }

                BDInfoExt bluray;
                try
                {
                    bluray = ScanWorker(filePath);
                }
                catch (Exception)
                {
                    // If our parsing of BD structure fails, the splitter might still be able to handle the BDMV directly, so return "success" here.
                    return(true);
                }

                // Store all playlist files for title selection
                _bdTitles = bluray.PlaylistFiles.Values.Where(p => p.IsValid && !p.HasLoops).Distinct().ToList();
                int counter = 0;
                _bdTitleNames   = _bdTitles.Select(t => FormatTitle(t, ++counter)).ToArray();
                _playlistFolder = bluray.DirectoryPLAYLIST.FullName;

                List <TSPlaylistFile> allPlayLists = _bdTitles.OrderByDescending(p => p.TotalLength).ToList();

                // Feature selection logic
                TSPlaylistFile listToPlay;
                if (allPlayLists.Count == 0)
                {
                    BDPlayerBuilder.LogInfo("No valid playlists found, use default INDEX.BDMV.");
                    return(true);
                }
                if (allPlayLists.Count == 1)
                {
                    // if we have only one playlist to show just move on
                    BDPlayerBuilder.LogInfo("Found one valid playlist {0}.", allPlayLists[0].Name);
                    listToPlay = allPlayLists[0];
                }
                else
                {
                    // Show selection dialog
                    BDPlayerBuilder.LogInfo("Found {0} playlists, title selection available.", allPlayLists.Count);

                    // first make an educated guess about what the real features are (more than one chapter, no loops and longer than one hour)
                    // todo: make a better filter on the playlists containing the real features
                    List <TSPlaylistFile> playLists = allPlayLists.Where(p => (p.Chapters.Count > 1 || p.TotalLength >= MINIMAL_FULL_FEATURE_LENGTH) && !p.HasLoops).ToList();

                    // if the filter yields zero results just list all playlists
                    if (playLists.Count == 0)
                    {
                        playLists = allPlayLists;
                    }

                    listToPlay = playLists[0];
                }

                BDPlayerBuilder.LogInfo("Using playlist {0}.", listToPlay.Name);
                for (int idx = 0; idx < _bdTitles.Count; idx++)
                {
                    if (_bdTitles[idx] != listToPlay)
                    {
                        continue;
                    }
                    _currentTitleName = _bdTitleNames[idx];
                    break;
                }

                GetChapters(listToPlay);

                // Combine the chosen file path (playlist)
                filePath = Path.Combine(bluray.DirectoryPLAYLIST.FullName, listToPlay.Name);
                return(true);
            }
            catch (Exception e)
            {
                BDPlayerBuilder.LogError("Exception while reading bluray structure {0} {1}", e.Message, e.StackTrace);
                return(false);
            }
        }