public void Execute() { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); IPlayerContext pc = playerContextManager.GetPlayerContext(PlayerManagerConsts.PRIMARY_SLOT); if (pc == null) { return; } IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePush(pc.FullscreenContentWorkflowStateId); }
public void ProcessTurn(IPlayerContext ctx) { Send(new Neof5Protocols.ProtocolData(playerNum, "ProcessTurn", ctx)); if (IsConnected) { // タイマースタート _startTimer(TurnTimeoutSec * 1000); } else { room.Master.PutCards(this, DeckGenerator.FromCardsetString("")); } }
public static void OpenAudioMenuDialog(IPlayerContext playerContext, bool showMute) { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePush(Consts.WF_STATE_ID_PLAYER_AUDIO_MENU_DIALOG, new NavigationContextConfig { AdditionalContextVariables = new Dictionary <string, object> { { Consts.KEY_PLAYER_CONTEXT, playerContext }, { Consts.KEY_SHOW_MUTE, showMute } } }); }
public void Execute() { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); IPlayerContext pc = playerContextManager.CurrentPlayerContext; if (pc == null) { return; } IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePush(pc.CurrentlyPlayingWorkflowStateId); }
protected override void Update() { if (_updating) { return; } _updating = true; try { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); IPlayerContext playerContext = playerContextManager.GetPlayerContext(_playerContext); _currentMediaItem = playerContext == null ? null : playerContext.CurrentMediaItem; MediaItemAspect imageAspect; if (_currentMediaItem == null || !_currentMediaItem.Aspects.TryGetValue(ImageAspect.ASPECT_ID, out imageAspect)) { imageAspect = null; } if (imageAspect == null) { ImageDimensions = string.Empty; CameraMake = string.Empty; CameraModel = string.Empty; ImageISOSpeed = string.Empty; ImageExposureTime = string.Empty; ImageFNumber = string.Empty; ImageFlashMode = string.Empty; ImageMeteringMode = string.Empty; } else { ImageDimensions = String.Format("{0} x {1}", imageAspect[ImageAspect.ATTR_WIDTH], imageAspect[ImageAspect.ATTR_HEIGHT]); CameraMake = (string)imageAspect[ImageAspect.ATTR_MAKE]; CameraModel = (string)imageAspect[ImageAspect.ATTR_MODEL]; ImageISOSpeed = (string)imageAspect[ImageAspect.ATTR_ISO_SPEED]; ImageExposureTime = (string)imageAspect[ImageAspect.ATTR_EXPOSURE_TIME]; ImageFNumber = (string)imageAspect[ImageAspect.ATTR_FNUMBER]; ImageFlashMode = (string)imageAspect[ImageAspect.ATTR_FLASH_MODE]; ImageMeteringMode = (string)imageAspect[ImageAspect.ATTR_METERING_MODE]; } } catch (Exception e) { ServiceRegistration.Get <ILogger>().Warn("ImagePlayerUIContributor: Error updating properties", e); } finally { _updating = false; } }
protected override void Update() { // Don't update the current channel and program information if we are in zap osd. if (_tvHandler == null || (_zapTimer != null && _zapTimer.IsEventPending)) { return; } // Update current programs for all channels of current group (visible inside MiniGuide). UpdateAllCurrentPrograms(); _zapChannelIndex = ChannelContext.Instance.Channels.CurrentIndex; if (_tvHandler.NumberOfActiveSlots < 1) { PiPAvailable = false; PiPEnabled = false; return; } PiPAvailable = true; // get the current channel and program out of the LiveTvMediaItems' TimeshiftContexes IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); IPlayerContext playerContext = playerContextManager.GetPlayerContext(PlayerChoice.PrimaryPlayer); if (playerContext != null) { LiveTvPlayer player = playerContext.CurrentPlayer as LiveTvPlayer; if (player != null) { ITimeshiftContext context = player.TimeshiftContexes.LastOrDefault(); IProgram currentProgram = null; IProgram nextProgram = null; IChannel channel = null; if (context != null && context.Channel != null) { channel = context.Channel; ChannelName = channel.Name; if (_tvHandler.ProgramInfo != null && _tvHandler.ProgramInfo.GetNowNextProgram(channel, out currentProgram, out nextProgram) && currentProgram != null) { double progress = (DateTime.Now - currentProgram.StartTime).TotalSeconds / (currentProgram.EndTime - currentProgram.StartTime).TotalSeconds * 100; _programProgressProperty.SetValue(progress); } } CurrentProgram.SetProgram(currentProgram, channel); NextProgram.SetProgram(nextProgram, channel); } } }
public void init() { this._rule = new SimplestRule(); _ctx = ContextFactory.CreateGameContext() as GameContext; var p1 = new TestPlayer("test1"); _pctx1 = ContextFactory.CreatePlayerContext(p1, _ctx); var p2 = new TestPlayer("test2"); _pctx2 = ContextFactory.CreatePlayerContext(p2, _ctx); }
private void SetPlayerBounds() { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); for (int index = 0; index < playerContextManager.NumActivePlayerContexts; index++) { IPlayerContext playerContext = playerContextManager.GetPlayerContext(index); if (playerContext != null && playerContext.CurrentPlayer is WebBrowserVideoPlayer) { WebBrowserVideoPlayer webPlayer = (WebBrowserVideoPlayer)playerContext.CurrentPlayer; webPlayer.TargetBounds = TransformBoundingBox(BoundingBox); } } }
private void DoSkipStep(int skipDirection) { IPlayerContext pc = GetPlayerContext(); if (pc == null) { return; } ReSetSkipTimer(); // First we find the new skip index, then we check if the player is able to skip. int newSkipStepIndex = _skipStepIndex; // We are in the matching range and want to step "forward" (greater step into this direction). if (_skipStepDirection == skipDirection) { // Last step must be valid to do next step if (_skipStepValid && _skipStepIndex < _skipSteps.Count - 1) { newSkipStepIndex++; } } else { // The current index is in the opposite direction, so we take one step back. if (_skipStepIndex > 0) { newSkipStepIndex--; } else { _skipStepDirection *= -1; // swap sign and direction newSkipStepIndex = 1; } } _skipStepIndex = newSkipStepIndex; if (pc.CanSkipRelative(TimeSpan.FromSeconds(_skipStepDirection * _skipSteps[newSkipStepIndex]))) { // Skip target is inside valid range SkipStep = FormatStepUnit(_skipStepDirection * _skipSteps[_skipStepIndex]); _skipStepValid = true; } else { _skipStepValid = false; SkipStep = _skipStepDirection == -1 ? "[Media.Start]" : "[Media.End]"; } }
protected void UpdatePlayerContexts() { IPlayerContext pc = ServiceRegistration.Get <IPlayerContextManager>().GetPlayerContext(PlayerManagerConsts.PRIMARY_SLOT); if (pc != null) { pc.CloseWhenFinished = _yes; } pc = ServiceRegistration.Get <IPlayerContextManager>().GetPlayerContext(PlayerManagerConsts.SECONDARY_SLOT); if (pc != null) { pc.CloseWhenFinished = _yes; } }
protected virtual bool RemoveItem(int index) { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); IPlayerContext pc = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer); IPlaylist playlist = pc == null ? null : pc.Playlist; lock (_syncObj) if (pc == null || pc.Playlist != _playlist) { return(false); } playlist.RemoveAt(index); return(true); }
private void OnMessageReceived(AsynchronousMessageQueue queue, SystemMessage message) { if (message.ChannelName == PlaylistMessaging.CHANNEL) { PlaylistMessaging.MessageType messageType = (PlaylistMessaging.MessageType)message.MessageType; switch (messageType) { case PlaylistMessaging.MessageType.PlaylistUpdate: UpdatePlaylist(); break; case PlaylistMessaging.MessageType.CurrentItemChange: UpdateCurrentItem(); break; case PlaylistMessaging.MessageType.PropertiesChange: UpdateProperties(); break; } } else if (message.ChannelName == PlayerManagerMessaging.CHANNEL) { PlayerManagerMessaging.MessageType messageType = (PlayerManagerMessaging.MessageType)message.MessageType; switch (messageType) { case PlayerManagerMessaging.MessageType.PlayerSlotClosed: IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); ISystemStateService sss = ServiceRegistration.Get <ISystemStateService>(); IPlayerContext pc = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer); if (pc == null && sss.CurrentState == SystemState.Running) { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePopToState(Consts.WF_STATE_ID_SHOW_PLAYLIST, true); } break; // We don't need to track the PlayerSlotActivated or PlayerSlotsChanged messages, because all information // we need is contained in the CurrentPlayer information } } else if (message.ChannelName == PlayerContextManagerMessaging.CHANNEL) { PlayerContextManagerMessaging.MessageType messageType = (PlayerContextManagerMessaging.MessageType)message.MessageType; switch (messageType) { case PlayerContextManagerMessaging.MessageType.CurrentPlayerChanged: UpdatePlaylist(); break; } } }
protected virtual void PlayItem(int index) { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); IPlayerContext pc = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer); IPlaylist playlist = pc == null ? null : pc.Playlist; lock (_syncObj) if (pc == null || pc.Playlist != _playlist) { return; } playlist.ItemListIndex = index; pc.DoPlay(playlist.Current); }
protected void Update() { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); IPlayerContext pc = playerContextManager.CurrentPlayerContext; bool visible = pc != null && !workflowManager.IsStateContainedInNavigationStack(pc.CurrentlyPlayingWorkflowStateId); if (visible == _isVisible) { return; } _isVisible = visible; FireStateChanged(); }
protected override void Update() { // Don't update the current channel and program information if we are in zap osd. if (!_active || _zapTimer != null) { return; } if (_tvHandler.NumberOfActiveSlots < 1) { PiPAvailable = false; PiPEnabled = false; return; } PiPAvailable = true; // get the current channel and program out of the LiveTvMediaItems' TimeshiftContexes IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); IPlayerContext playerContext = playerContextManager.GetPlayerContext(PlayerChoice.PrimaryPlayer); if (playerContext != null) { LiveTvMediaItem liveTvMediaItem = playerContext.CurrentMediaItem as LiveTvMediaItem; LiveTvPlayer player = playerContext.CurrentPlayer as LiveTvPlayer; if (liveTvMediaItem != null && player != null) { ITimeshiftContext context = player.CurrentTimeshiftContext; if (context != null) { ChannelName = context.Channel.Name; CurrentProgram.SetProgram(context.Program); if (context.Program != null) { IProgram currentProgram = context.Program; double progress = (DateTime.Now - currentProgram.StartTime).TotalSeconds / (currentProgram.EndTime - currentProgram.StartTime).TotalSeconds * 100; _programProgressProperty.SetValue(progress); IList <IProgram> nextPrograms; DateTime nextTime = currentProgram.EndTime.Add(TimeSpan.FromSeconds(10)); if (_tvHandler.ProgramInfo.GetPrograms(context.Channel, nextTime, nextTime, out nextPrograms)) { NextProgram.SetProgram(nextPrograms[0]); } } } } } }
/// <summary> /// Called from the skin if the user invokes the "InstantSkip" action. This will start the InstantSkip in the /// underlaying player. /// </summary> public void InstantSkipBackward() { IPlayerContext pc = GetPlayerContext(); if (pc == null) { return; } ClearSkipTimer(); MediaModelSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <MediaModelSettings>(); pc.InstantSkip(-(int)settings.InstantSkipPercent); }
public IEnumerable <IPlayerContext> GetPlayerContextsByAVType(AVType avType) { lock (SyncObj) { for (int i = 0; i < 2; i++) { IPlayerContext pc = GetPlayerContext(i); if (pc != null && pc.AVType == avType) { yield return(pc); } } } }
public IEnumerable <IPlayerContext> GetPlayerContextsByMediaModuleId(Guid mediaModuleId) { lock (SyncObj) { for (int i = 0; i < 2; i++) { IPlayerContext pc = GetPlayerContext(i); if (pc != null && pc.MediaModuleId == mediaModuleId) { yield return(pc); } } } }
protected void UpdateAudioStreamsMenu() { // Some updates could be avoided if we tracked a "dirty" flag and break execution if !dirty lock (_syncObj) { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); int numActivePlayers = playerContextManager.NumActivePlayerContexts; int numberOfAudioStreams = GetTotalNumberOfAudioStreams(); _audioStreamsMenu.Clear(); for (int i = 0; i < numActivePlayers; i++) { IPlayerContext pc = playerContextManager.GetPlayerContext(i); if (pc == null || !pc.IsActive) { continue; } IPlayer player = pc.CurrentPlayer; AudioStreamDescriptor currentAudioStream; IList <AudioStreamDescriptor> asds = new List <AudioStreamDescriptor>(pc.GetAudioStreamDescriptors(out currentAudioStream)); foreach (AudioStreamDescriptor asd in asds) { string playedItem = player == null ? null : player.MediaItemTitle ?? pc.Name; string choiceItemName; int count = asds.Count; if (numActivePlayers > 1 && count > 1 && count != numberOfAudioStreams) { // Only display the playedItem name if more than one player is able to provide audio streams. If a single player provides // multiple streams, they will be distinguished by the VideoPlayer. choiceItemName = playedItem + ": " + asd.AudioStreamName; } else { choiceItemName = count != numberOfAudioStreams ? playedItem : asd.AudioStreamName; } AudioStreamDescriptor asdClosureCopy = asd; ListItem item = new ListItem(Consts.KEY_NAME, choiceItemName) { Command = new MethodDelegateCommand(() => ChooseAudioStream(asdClosureCopy)), Selected = asd == currentAudioStream, }; item.AdditionalProperties[Consts.KEY_NAVIGATION_MODE] = NavigationMode.ExitPCWorkflow; _audioStreamsMenu.Add(item); } } _audioStreamsMenu.FireChange(); } }
private void HandlePlayerMessage(PlayerManagerMessaging.MessageType message, IPlayerSlotController psc) { switch (message) { case PlayerManagerMessaging.MessageType.PlayerEnded: case PlayerManagerMessaging.MessageType.PlayerStopped: case PlayerManagerMessaging.MessageType.PlayerError: IPlayerContext pc = PlayerContext.GetPlayerContext(psc); if (pc != null) { onPlayerStopped(pc.CurrentMediaItem); } break; } }
private MediaItem GetCurrentMediaItem(IVideoPlayer player) { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); for (int index = 0; index < playerContextManager.NumActivePlayerContexts; index++) { IPlayerContext playerContext = playerContextManager.GetPlayerContext(index); if (playerContext == null || playerContext.CurrentPlayer != player) { continue; } return(playerContext.CurrentMediaItem); } return(null); }
public Unload(IPlayerContext playerContext, IDrone drone, DateTime startedAt) { var item = playerContext.GetMap().Factories.FirstOrDefault( itm => drone.CurrentPosition.IsNear(itm.Position) ); if (item == null) { throw new InvalidInstructionException("No factory near the drone"); } Drone = drone; StartedAt = startedAt; Resource = drone.Storage; AbortedAt = null; }
public ProtocolData(int playerNum, string kind, IPlayerContext ctx) { _data = new { YourNum = playerNum, Kind = kind, Teban = ctx.GameContext.Teban, IsKakumei = ctx.GameContext.IsKakumei, PlayerInfo = ctx.GameContext.PlayerInfo, Deck = ctx.Deck.ToCardsetString(), Ba = ctx.GameContext.Ba.Select(cards => cards.ToCardsetString()), Yama = ctx.GameContext.Yama.JoinString(" "), History = ctx.GameContext.History.Select(gh => gh.ToString()), }; }
protected static void CompletePlayOrEnqueue(IPlayerContext pc, bool play) { IPlayerContextManager pcm = ServiceRegistration.Get <IPlayerContextManager>(); MediaModelSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <MediaModelSettings>(); pc.CloseWhenFinished = settings.ClosePlayerWhenFinished; // Has to be done before starting the media item, else the slot will not close in case of an error / when the media item cannot be played if (play) { pc.Play(); if (pc.AVType == AVType.Video) { pcm.ShowFullscreenContent(true); } } }
protected IList <IPlayerContext> GetVideoPlayerContexts() { IPlayerContextManager pcm = ServiceRegistration.Get <IPlayerContextManager>(); IList <IPlayerContext> videoPCs = new List <IPlayerContext>(); for (int i = 0; i < pcm.NumActivePlayerContexts; i++) { IPlayerContext pc = pcm.GetPlayerContext(i); if (pc != null && pc.CurrentPlayer is IVideoPlayer) { videoPCs.Add(pc); } } return(videoPCs); }
public IPlayerContextDto Map(IPlayerContext playerContext) { return(new PlayerContextDto() { Drones = playerContext.Drones.Select(Map), PlayerName = playerContext.PlayerName, Level = playerContext.Level, Resources = playerContext.Resources, IsResourceGoalAchieved = playerContext.IsResourceGoalAchieved(), StartTime = playerContext.GetStartTime(), TimeWhenResoucesGoalIsAchieved = playerContext.GetTimeWhenResoucesGoalIsAchieved(), SpentTime = playerContext.GetSpentTime(), IsTimeGoalAchieved = playerContext.IsTimeGoalAchieved() }); }
public override State Handle(PlayerAction action, IPlayerContext playerContext) { // [_, ход пятёркой] -> "конечное состояние. Подсказка есть." if (IsPlayFiveRankedAction(action) || IsDiscardNoNeedCard(action)) { return(new FinalWithClueState(this)); } // [A, ход картой] -> A // ["возможна подсказка", сброс некритичной карты] -> "возможна подсказка" if (IsPlayCardAction(action) || IsWhateverToPlayCardAction(action)) { return(this); } // ["возможна подсказка", взрыв] -> "требуется подсказка" или "безвыходная ситуация" // ["возможна подсказка", сброс критичной карты] -> "требуется подсказка" или "безвыходная ситуация" if (action.IsActionToAvoid) { ClueAndAction clueAndAction = action.CreateClueToAvoid(BoardContext, playerContext); IClueSituationStrategy solution; if (clueAndAction == null) { // придумаем подсказку про запас var possibleClue = CreateClue(playerContext, action.Cards); if (possibleClue != null) { solution = new OnlyClueExistsSituation(playerContext, possibleClue); return(new RequiredClue(this, solution)); } else { return(this); } } // TODO выяснить, что будет делать игрок после этой подсказки // Если действие порождает подсказку, то можно уходить в конечной состояние. solution = new OnlyClueExistsSituation(playerContext, clueAndAction.Clue); return(new RequiredClue(this, solution)); } throw new ArgumentException(action.ToString()); }
private static bool GetPlayerWorkflowStates(out Guid?fullscreenContentWfStateId, out Guid?currentlyPlayingWorkflowStateId) { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); IPlayerContext playerContext = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer); if (playerContext == null) { fullscreenContentWfStateId = null; currentlyPlayingWorkflowStateId = null; return(false); } fullscreenContentWfStateId = playerContext.FullscreenContentWorkflowStateId; currentlyPlayingWorkflowStateId = playerContext.CurrentlyPlayingWorkflowStateId; return(true); }
protected void HandlePlayerStopped(IPlayerSlotController psc) { IPlayerContext pc = PlayerContext.GetPlayerContext(psc); if (pc == null || !pc.IsActive) { return; } // We get the player message asynchronously, so we have to check the state of the slot again to ensure // we close the correct one if (pc.CloseWhenFinished && pc.CurrentPlayer == null) { pc.Close(); } CheckMediaWorkflowStates_Async(); }
/// <summary> /// Depending on parameter <paramref name="play"/>, plays or enqueues the specified media <paramref name="item"/>. /// </summary> /// <param name="item">Media item to be played.</param> /// <param name="play">If <c>true</c>, plays the specified <paramref name="item"/>, else enqueues it.</param> /// <param name="concurrencyMode">Determines if the media item will be played or enqueued in concurrency mode.</param> /// <param name="resumeState">Contains optional information for players to resume playback.</param> public static async Task PlayOrEnqueueItem(MediaItem item, bool play, PlayerContextConcurrencyMode concurrencyMode, IResumeState resumeState = null) { IPlayerContextManager pcm = ServiceRegistration.Get <IPlayerContextManager>(); AVType avType = pcm.GetTypeOfMediaItem(item); IPlayerContext pc = PreparePlayerContext(avType, play, concurrencyMode); if (pc == null) { return; } // Always add items to playlist. This allows audio playlists as well as video/image playlists. pc.Playlist.Add(item); await CompletePlayOrEnqueue(pc, play, resumeState); }
public void SetSubtitle(IPlayerContext playerContext, string subtitle) { if (playerContext != null) { ISubtitlePlayer sp = playerContext.CurrentPlayer as ISubtitlePlayer; if (sp != null) sp.SetSubtitle(subtitle); } }
internal static void SendUpdatePlayerRolesMessage(IPlayerContext newCurrentPlayerContext, IPlayerContext newAudioPlayerContext) { SystemMessage msg = new SystemMessage(MessageType.UpdatePlayerRolesInternal); msg.MessageData[NEW_CURRENT_PLAYER_CONTEXT] = newCurrentPlayerContext; msg.MessageData[NEW_AUDIO_PLAYER_CONTEXT] = newAudioPlayerContext; ServiceRegistration.Get<IMessageBroker>().Send(CHANNEL, msg); }
public static void SendPlayerContextManagerMessage(MessageType type, IPlayerContext playerContext) { SystemMessage msg = new SystemMessage(type); msg.MessageData[PLAYER_CONTEXT] = playerContext; ServiceRegistration.Get<IMessageBroker>().Send(CHANNEL, msg); }
public AudioStreamDescriptor(IPlayerContext playerContext, string playerName, string audioStreamName) { _playerContext = playerContext; _playerName = playerName; _audioStreamName = audioStreamName; }
protected static void CompletePlayOrEnqueue(IPlayerContext pc, bool play, IResumeState resumeState = null) { IPlayerContextManager pcm = ServiceRegistration.Get<IPlayerContextManager>(); MediaModelSettings settings = ServiceRegistration.Get<ISettingsManager>().Load<MediaModelSettings>(); pc.CloseWhenFinished = settings.ClosePlayerWhenFinished; // Has to be done before starting the media item, else the slot will not close in case of an error / when the media item cannot be played if (play) { if (resumeState != null) pc.SetContextVariable(PlayerContext.KEY_RESUME_STATE, resumeState); pc.Play(); if (pc.AVType == AVType.Video) pcm.ShowFullscreenContent(true); } }
protected void AsyncAddToPlaylist(IPlayerContext pc, GetMediaItemsDlgt getMediaItemsFunction, bool play) { IScreenManager screenManager = ServiceRegistration.Get<IScreenManager>(); Guid? dialogInstanceId = screenManager.ShowDialog(Consts.DIALOG_ADD_TO_PLAYLIST_PROGRESS, (dialogName, instanceId) => StopAddToPlaylist()); try { int numItems = 0; _stopAddToPlaylist = false; SetNumItemsAddedToPlaylist(0); ICollection<MediaItem> items = new List<MediaItem>(); foreach (MediaItem item in getMediaItemsFunction()) { SetNumItemsAddedToPlaylist(++numItems); if (_stopAddToPlaylist) break; items.Add(item); } pc.Playlist.AddAll(items); } finally { if (dialogInstanceId.HasValue) screenManager.CloseDialog(dialogInstanceId.Value); IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>(); workflowManager.NavigatePopToState(Consts.WF_STATE_ID_PLAY_OR_ENQUEUE_ITEMS, true); } // Must be done after the dialog is closed CompletePlayOrEnqueue(pc, play); }
/// <summary> /// Creates Scrobble data based on a DBMovieInfo object /// </summary> /// <param name="psc"></param> /// <param name="pc">PlayerContext</param> /// <param name="starting"></param> /// <param name="scrobbleData"></param> /// <param name="state"></param> /// <returns>The Trakt scrobble data to send</returns> private bool TryCreateScrobbleData(IPlayerSlotController psc, IPlayerContext pc, bool starting, out AbstractScrobble scrobbleData, out TraktScrobbleStates state) { scrobbleData = null; state = starting ? TraktScrobbleStates.watching : TraktScrobbleStates.scrobble; if (_settings.Settings.Authentication == null) return false; string username = _settings.Settings.Authentication.Username; string password = _settings.Settings.Authentication.Password; if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) return false; // For canceling the watching, it is to have no TraktMovieScrobble. if (pc.CurrentMediaItem == null) { if (starting) return false; state = TraktScrobbleStates.cancelwatching; return true; } bool isMovie = pc.CurrentMediaItem.Aspects.ContainsKey(MovieAspect.ASPECT_ID); bool isSeries = pc.CurrentMediaItem.Aspects.ContainsKey(SeriesAspect.ASPECT_ID); if (!isMovie && !isSeries) return false; string title = pc.CurrentPlayer != null ? pc.CurrentPlayer.MediaItemTitle : null; IMediaPlaybackControl pmc = pc.CurrentPlayer as IMediaPlaybackControl; TimeSpan currentPosition; if (pmc != null) { _progressUpdateWorks[psc].Duration = pmc.Duration; currentPosition = pmc.CurrentTime; } else { // Player is already removed on stopping, so take the resume position if available currentPosition = _progressUpdateWorks[psc].ResumePosition; } int progress = currentPosition == TimeSpan.Zero ? (starting ? 0 : 100) : Math.Min((int)(currentPosition.TotalSeconds * 100 / _progressUpdateWorks[psc].Duration.TotalSeconds), 100); string value; int iValue; DateTime dtValue; long lValue; if (isMovie) { TraktMovieScrobble movie = new TraktMovieScrobble(); if (MediaItemAspect.TryGetAttribute(pc.CurrentMediaItem.Aspects, MovieAspect.ATTR_IMDB_ID, out value) && !string.IsNullOrWhiteSpace(value)) movie.IMDBID = value; if (MediaItemAspect.TryGetAttribute(pc.CurrentMediaItem.Aspects, MovieAspect.ATTR_TMDB_ID, out iValue) && iValue > 0) movie.TMDBID = iValue.ToString(); if (MediaItemAspect.TryGetAttribute(pc.CurrentMediaItem.Aspects, MediaAspect.ATTR_RECORDINGTIME, out dtValue)) movie.Year = dtValue.Year.ToString(); if (MediaItemAspect.TryGetAttribute(pc.CurrentMediaItem.Aspects, MovieAspect.ATTR_RUNTIME_M, out iValue) && iValue > 0) movie.Duration = iValue.ToString(); scrobbleData = movie; } if (isSeries) { TraktEpisodeScrobble series = new TraktEpisodeScrobble(); if (MediaItemAspect.TryGetAttribute(pc.CurrentMediaItem.Aspects, SeriesAspect.ATTR_IMDB_ID, out value) && !string.IsNullOrWhiteSpace(value)) series.IMDBID = value; if (MediaItemAspect.TryGetAttribute(pc.CurrentMediaItem.Aspects, SeriesAspect.ATTR_TVDB_ID, out iValue)) series.SeriesID = iValue.ToString(); if (MediaItemAspect.TryGetAttribute(pc.CurrentMediaItem.Aspects, SeriesAspect.ATTR_SERIESNAME, out value) && !string.IsNullOrWhiteSpace(value)) series.Title = value; if (MediaItemAspect.TryGetAttribute(pc.CurrentMediaItem.Aspects, SeriesAspect.ATTR_FIRSTAIRED, out dtValue)) series.Year = dtValue.Year.ToString(); if (MediaItemAspect.TryGetAttribute(pc.CurrentMediaItem.Aspects, SeriesAspect.ATTR_SEASON, out iValue)) series.Season = iValue.ToString(); List<int> intList; if (MediaItemAspect.TryGetAttribute(pc.CurrentMediaItem.Aspects, SeriesAspect.ATTR_EPISODE, out intList) && intList.Any()) series.Episode = intList.First().ToString(); // TODO: multi episode files?! scrobbleData = series; } // Fallback duration info if (string.IsNullOrWhiteSpace(scrobbleData.Duration) && MediaItemAspect.TryGetAttribute(pc.CurrentMediaItem.Aspects, VideoAspect.ATTR_DURATION, out lValue) && lValue > 0) scrobbleData.Duration = (lValue / 60).ToString(); if (string.IsNullOrWhiteSpace(scrobbleData.Title)) scrobbleData.Title = title; scrobbleData.Progress = progress.ToString(); if (!starting && progress < WATCHED_PERCENT) state = TraktScrobbleStates.cancelwatching; scrobbleData.PluginVersion = TraktSettings.Version; scrobbleData.MediaCenter = "MediaPortal 2"; scrobbleData.MediaCenterVersion = Assembly.GetEntryAssembly().GetName().Version.ToString(); scrobbleData.MediaCenterBuildDate = String.Empty; scrobbleData.Username = username; scrobbleData.Password = password; return true; }
protected int _inBatchUpdate = 0; // 0 ^= no batch update, >0 ^= in batch update mode public Playlist(IPlayerContext context) { _playerContext = context; }
public void StartPartyMode() { ServiceRegistration.Get<ILogger>().Info("PartyMusicPlayerModel: Starting party mode"); SaveSettings(); if (!LoadPlaylist()) return; LoadPlayRepeatMode(); IPlayerContextManager pcm = ServiceRegistration.Get<IPlayerContextManager>(); IPlayerContext audioPlayerContext = pcm.OpenAudioPlayerContext(Consts.MODULE_ID_PARTY_MUSIC_PLAYER, Consts.RES_PLAYER_CONTEXT_NAME, false, Consts.WF_STATE_ID_PARTY_MUSIC_PLAYER, Consts.WF_STATE_ID_PARTY_MUSIC_PLAYER); IPlaylist playlist = audioPlayerContext.Playlist; playlist.StartBatchUpdate(); try { playlist.Clear(); foreach (MediaItem mediaItem in _mediaItems) playlist.Add(mediaItem); playlist.PlayMode = PlayMode; playlist.RepeatMode = RepeatMode; _playerContext = audioPlayerContext; } finally { playlist.EndBatchUpdate(); } audioPlayerContext.Play(); IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>(); workflowManager.NavigatePushAsync(Consts.WF_STATE_ID_PARTY_MUSIC_PLAYER); }
/// <summary> /// Gets a name for a player context. /// </summary> /// <param name="playerContext">Player context to return the name for.</param> /// <param name="slotNo">Number of the player slot of the given <paramref name="playerContext"/>.</param> /// <returns>Human readable name for the given <paramref name="playerContext"/>.</returns> protected static string GetNameForPlayerContext(IPlayerContext playerContext, int slotNo) { IPlayer player = playerContext.CurrentPlayer; if (player == null) { IResourceString playerOfType = LocalizationHelper.CreateResourceString(Consts.RES_PLAYER_OF_TYPE); // "{0} player" IResourceString slotNoRes = LocalizationHelper.CreateResourceString(Consts.RES_SLOT_NO); // "Slot #{0}" return playerOfType.Evaluate(playerContext.AVType.ToString()) + " (" + slotNoRes.Evaluate((slotNo + 1).ToString()) + ")"; // "Video player (Slot #1)" } return player.Name + ": " + player.MediaItemTitle; }
// Hack! The following code was copied from PlayerConfigurationDialogModel.OpenAudioMenuDialog. // Actually, we are not allowed to access the SkinBase plugin, because we have not declared an explicit dependency... public static void OpenAudioMenuDialog(IPlayerContext playerContext, bool showMute) { IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>(); workflowManager.NavigatePush(WF_STATE_ID_PLAYER_SLOT_AUDIO_MENU_DIALOG, new NavigationContextConfig { AdditionalContextVariables = new Dictionary<string, object> { {KEY_PLAYER_CONTEXT, playerContext}, {KEY_SHOW_MUTE, showMute} } }); }
public void SetEffect(IPlayerContext playerContext, string effect) { if (playerContext != null) playerContext.OverrideEffect(effect); }
public void SetGeometry(IPlayerContext playerContext, IGeometry geometry) { if (playerContext != null) playerContext.OverrideGeometry(geometry); }
public static void OpenChooseEffectDialog(IPlayerContext playerContext) { IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>(); workflowManager.NavigatePush(Consts.WF_STATE_ID_PLAYER_CHOOSE_EFFECT_MENU_DIALOG, new NavigationContextConfig { AdditionalContextVariables = new Dictionary<string, object> { {Consts.KEY_PLAYER_CONTEXT, playerContext}, } }); }
protected void EnterContext(NavigationContext newContext) { _messageQueue.Start(); if (newContext.WorkflowState.StateId == Consts.WF_STATE_ID_PLAYER_CONFIGURATION_DIALOG) { UpdatePlayerConfigurationMenu(); _inPlayerConfigurationDialog = true; } else if (newContext.WorkflowState.StateId == Consts.WF_STATE_ID_CHOOSE_AUDIO_STREAM_DIALOG) { UpdateAudioStreamsMenu(); _inChooseAudioStreamDialog = true; } else if (newContext.WorkflowState.StateId == Consts.WF_STATE_ID_PLAYER_AUDIO_MENU_DIALOG) { _playerAudioMenuPlayerContext = newContext.GetContextVariable(Consts.KEY_PLAYER_CONTEXT, false) as IPlayerContext; bool? showToggleMute = newContext.GetContextVariable(Consts.KEY_SHOW_MUTE, false) as bool?; _showToggleMute = showToggleMute ?? true; UpdatePlayerSlotAudioMenu(); _inPlayerSlotAudioMenuDialog = true; } else if (newContext.WorkflowState.StateId == Consts.WF_STATE_ID_PLAYER_CHOOSE_GEOMETRY_MENU_DIALOG) { _playerGeometryMenuPlayerContext = newContext.GetContextVariable(Consts.KEY_PLAYER_CONTEXT, false) as IPlayerContext; UpdatePlayerChooseGeometryMenu(); _inPlayerChooseGeometryMenuDialog = true; } else if (newContext.WorkflowState.StateId == Consts.WF_STATE_ID_PLAYER_CHOOSE_EFFECT_MENU_DIALOG) { _playerEffectMenuPlayerContext = newContext.GetContextVariable(Consts.KEY_PLAYER_CONTEXT, false) as IPlayerContext; UpdatePlayerChooseEffectMenu(); _inPlayerChooseEffectMenuDialog = true; } }