public ConfigureMediaPlayerPage(PlayerConfiguration playerConfig, IPlaybackManager playbackManager, ITheaterConfigurationManager config, IPresentationManager presentation, INavigationService nav, IApiClient apiClient)
        {
            _playerConfig = playerConfig;
            _playbackManager = playbackManager;
            _config = config;
            _presentation = presentation;
            _nav = nav;
            _apiClient = apiClient;

            InitializeComponent();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationConfiguration" /> class.
        /// </summary>
        public ApplicationConfiguration()
            : base()
        {
            EnableBackdrops = true;
            MediaPlayers = new PlayerConfiguration[] { };

            InternalPlayerConfiguration = new InternalPlayerConfiguration();

            MaxStreamingBitrate = 3000000;

            VlcConfiguration = new VlcConfiguration();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationConfiguration" /> class.
        /// </summary>
        public ApplicationConfiguration()
            : base()
        {
            ServerHostName = "localhost";
            ServerApiPort  = 8096;

            EnableHighQualityImageScaling = true;
            EnableBackdrops = true;
            MediaPlayers    = new PlayerConfiguration[] { };

            InternalPlayerConfiguration = new InternalPlayerConfiguration();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationConfiguration" /> class.
        /// </summary>
        public ApplicationConfiguration()
            : base()
        {
            ServerHostName = "localhost";
            ServerApiPort = 8096;

            EnableHighQualityImageScaling = true;
            EnableBackdrops = true;
            MediaPlayers = new PlayerConfiguration[] { };

            InternalPlayerConfiguration = new InternalPlayerConfiguration();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationConfiguration" /> class.
        /// </summary>
        public ApplicationConfiguration()
            : base()
        {
            EnableBackdrops = true;
            MediaPlayers    = new PlayerConfiguration[] { };

            InternalPlayerConfiguration = new InternalPlayerConfiguration();

            MaxStreamingBitrate = 3000000;

            VlcConfiguration = new VlcConfiguration();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationConfiguration" /> class.
        /// </summary>
        public ApplicationConfiguration()
            : base()
        {
            ServerAddress = "http://localhost:8096";
            AutoLoginConfiguration = new AutoLoginConfiguration();

            EnableBackdrops = true;
            MediaPlayers = new PlayerConfiguration[] { };

            InternalPlayerConfiguration = new InternalPlayerConfiguration();

            MaxStreamingBitrate = 8000000;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationConfiguration" /> class.
        /// </summary>
        public ApplicationConfiguration()
            : base()
        {
            ServerAddress          = "http://localhost:8096";
            AutoLoginConfiguration = new AutoLoginConfiguration();

            EnableBackdrops = true;
            MediaPlayers    = new PlayerConfiguration[] { };

            InternalPlayerConfiguration = new InternalPlayerConfiguration();

            MaxStreamingBitrate = 3000000;
        }
 public MediaPlayerViewModel(PlayerConfiguration config)
 {
     PlayerConfiguration = config;
 }
        /// <summary>
        /// Plays the specified player.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="options">The options.</param>
        /// <param name="configuration">The configuration.</param>
        /// <returns>Task.</returns>
        private async Task Play(IMediaPlayer player, PlayOptions options, PlayerConfiguration configuration)
        {
            if (options.Shuffle)
            {
                options.Items = options.Items.OrderBy(i => Guid.NewGuid()).ToList();
            }

            var firstItem = options.Items[0];

            if (options.StartPositionTicks == 0 && player.SupportsMultiFilePlayback && firstItem.IsVideo && firstItem.LocationType == LocationType.FileSystem && options.GoFullScreen)
            {
                try
                {
                    var intros = await _apiClient.GetIntrosAsync(firstItem.Id, _apiClient.CurrentUserId);

                    options.Items.InsertRange(0, intros.Items);
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error retrieving intros", ex);
                }
            }

            options.Configuration = configuration;

            await player.Play(options);

            if (player is IInternalMediaPlayer && player is IVideoPlayer && firstItem.IsVideo)
            {
                await _presentationManager.Window.Dispatcher.InvokeAsync(() => _presentationManager.WindowOverlay.SetResourceReference(FrameworkElement.StyleProperty, "WindowBackgroundContentDuringPlayback"));

                if (options.GoFullScreen)
                {
                    await _nav.NavigateToInternalPlayerPage();
                }
            }

            OnPlaybackStarted(player, options);
        }
        private bool IsConfiguredForFileExtension(PlayerConfiguration configuration, string path)
        {
            var extensions = configuration.FileExtensions.Select(i => i.TrimStart('.'));

            return extensions.Contains(Path.GetExtension(path).TrimStart('.'), StringComparer.OrdinalIgnoreCase);
        }
        /// <summary>
        /// Determines whether [is configured to play] [the specified configuration].
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="item">The item.</param>
        /// <returns><c>true</c> if [is configured to play] [the specified configuration]; otherwise, <c>false</c>.</returns>
        private bool IsConfiguredToPlay(PlayerConfiguration configuration, BaseItemDto item)
        {
            // Make this configurable if/when needed
            if (item.LocationType != LocationType.FileSystem)
            {
                return false;
            }

            // If it's configured for specific item types
            if (!string.Equals(configuration.MediaType, item.MediaType, StringComparison.OrdinalIgnoreCase))
            {
                return false;
            }

            if (string.Equals(configuration.MediaType, MediaType.Video))
            {
                if (!item.VideoType.HasValue)
                {
                    return false;
                }

                if (item.VideoType.Value == VideoType.VideoFile)
                {
                    // If it's configured for specific file extensions
                    if (!IsConfiguredForFileExtension(configuration, item.Path))
                    {
                        return false;
                    }
                }

                if (item.VideoType.Value == VideoType.BluRay && !configuration.PlayBluray)
                {
                    return false;
                }
                if (item.VideoType.Value == VideoType.Dvd && !configuration.PlayDvd)
                {
                    return false;
                }

                if (!configuration.Play3DVideo && item.Video3DFormat.HasValue)
                {
                    return false;
                }

                if (item.VideoType.Value == VideoType.Iso & configuration.IsoMethod == IsoConfiguration.None)
                {
                    return false;
                }
            }

            else if (string.Equals(configuration.MediaType, MediaType.Book))
            {
                // If it's configured for specific file extensions
                if (!IsConfiguredForFileExtension(configuration, item.Path))
                {
                    return false;
                }
            }

            else if (string.Equals(configuration.MediaType, MediaType.Audio))
            {
                // If it's configured for specific file extensions
                if (!IsConfiguredForFileExtension(configuration, item.Path))
                {
                    return false;
                }
            }

            else if (string.Equals(configuration.MediaType, MediaType.Game))
            {
                // If it's configured for specific file extensions
                if (!string.Equals(item.GameSystem, configuration.GameSystem, StringComparison.OrdinalIgnoreCase))
                {
                    return false;
                }
            }

            return true;
        }
 /// <summary>
 /// Determines whether [is configured to play] [the specified configuration].
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="items">The items.</param>
 /// <returns><c>true</c> if [is configured to play] [the specified configuration]; otherwise, <c>false</c>.</returns>
 private bool IsConfiguredToPlay(PlayerConfiguration configuration, IEnumerable<BaseItemDto> items)
 {
     return items.All(i => IsConfiguredToPlay(configuration, i));
 }
        /// <summary>
        /// Gets the player.
        /// </summary>
        /// <param name="items">The items.</param>
        /// <param name="configuration">The configuration.</param>
        /// <returns>IMediaPlayer.</returns>
        private IMediaPlayer GetPlayer(IEnumerable<BaseItemDto> items, out PlayerConfiguration configuration)
        {
            var configuredPlayer = _configurationManager.Configuration.MediaPlayers.FirstOrDefault(p => IsConfiguredToPlay(p, items));

            if (configuredPlayer != null)
            {
                var player = MediaPlayers.FirstOrDefault(i => string.Equals(i.Name, configuredPlayer.PlayerName, StringComparison.OrdinalIgnoreCase));

                if (player != null)
                {
                    configuration = configuredPlayer;
                    return player;
                }
            }

            configuration = null;

            // If there's no explicit configuration just find the first matching player who says they can play it
            return MediaPlayers.FirstOrDefault(p => items.All(p.CanPlayByDefault));
        }
        /// <summary>
        /// Plays the specified player.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="options">The options.</param>
        /// <param name="configuration">The configuration.</param>
        /// <returns>Task.</returns>
        private async Task Play(IMediaPlayer player, PlayOptions options, PlayerConfiguration configuration)
        {
            if (options.Items[0].IsPlaceHolder??false)
            {
                // play a phyical disc in the cdrom drive
                // Will be re-entrant call, so has to be made befpre the interlocked.CompareExchange below
                await PlayExternalDisc(true);
                return;
            }

            if (Interlocked.CompareExchange(ref _isStarting, 1, 0) == 0) // prevent race conditions, thread safe check we are not already starting to play an item
            {
                try
                {
                    if (options.Shuffle)
                    {
                        options.Items = options.Items.OrderBy(i => Guid.NewGuid()).ToList();
                    }

                    var firstItem = options.Items[0];

                  
                    if (options.StartPositionTicks == 0 && player.SupportsMultiFilePlayback && firstItem.IsVideo && firstItem.LocationType == LocationType.FileSystem && options.GoFullScreen)
                    {
                        try
                        {
                            var intros = await _apiClient.GetIntrosAsync(firstItem.Id, _apiClient.CurrentUserId);

                            options.Items.InsertRange(0, intros.Items);
                        }
                        catch (Exception ex)
                        {
                            _logger.ErrorException("Error retrieving intros", ex);
                        }
                    }


                    options.Configuration = configuration;

                    await player.Play(options);

                    if (player is IInternalMediaPlayer && player is IVideoPlayer && firstItem.IsVideo)
                    {
                        await _presentationManager.Window.Dispatcher.InvokeAsync(() => _presentationManager.WindowOverlay.SetResourceReference(FrameworkElement.StyleProperty, "WindowBackgroundContentDuringPlayback"));

                        if (options.GoFullScreen)
                        {
                            await _nav.NavigateToInternalPlayerPage();
                        }
                    }
                    OnPlaybackStarted(player, options);
                    
                }
                finally
                {
                    Interlocked.Exchange(ref _isStarting, 0);
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationConfiguration" /> class.
        /// </summary>
        public ApplicationConfiguration()
            : base()
        {
            ServerHostName = "localhost";
            ServerApiPort = 8096;
            AutoLoginConfiguration = new AutoLoginConfiguration();

            EnableBackdrops = true;
            MediaPlayers = new PlayerConfiguration[] { };

            InternalPlayerConfiguration = new InternalPlayerConfiguration();
        }