private void ZapTimerElapsed(object sender, EventArgs eventArgs)
        {
            // Zap to channel
            int number;

            if (!int.TryParse(ChannelNumberOrIndex, out number))
            {
                return;
            }

            ClearZapTimer();

#if DEBUG_FOCUS
            ServiceRegistration.Get <MediaPortal.Common.Logging.ILogger>().Debug("EPG: ChannelZapModel goto {0}", number);
#endif
            SlimTvClientSettings settings        = ServiceRegistration.Get <ISettingsManager>().Load <SlimTvClientSettings>();
            IWorkflowManager     workflowManager = ServiceRegistration.Get <IWorkflowManager>();
            if (workflowManager.CurrentNavigationContext.WorkflowModelId == SlimTvMultiChannelGuideModel.MODEL_ID)
            {
                SlimTvMultiChannelGuideModel guide = workflowManager.GetModel(SlimTvMultiChannelGuideModel.MODEL_ID) as SlimTvMultiChannelGuideModel;
                if (guide == null)
                {
                    return;
                }
                if (settings.ZapByChannelIndex)
                {
                    // Channel index starts by 0, user enters 1 based numbers
                    number--;
                    guide.GoToChannelIndex(number);
                }
                else
                {
                    guide.GoToChannelNumber(number);
                }
                return;
            }
            SlimTvClientModel model = workflowManager.GetModel(SlimTvClientModel.MODEL_ID) as SlimTvClientModel;
            if (model == null)
            {
                return;
            }

            // Special case "0", we use it for "zap back" to tune previous watched channel
            if (number == 0)
            {
                _ = model.ZapBack();
                return;
            }

            if (settings.ZapByChannelIndex)
            {
                // Channel index starts by 0, user enters 1 based numbers
                number--;
                _ = model.TuneByIndex(number);
            }
            else
            {
                _ = model.TuneByChannelNumber(number);
            }
        }
        /// <summary>
        /// Executes the method of name <see cref="MethodName"/> in the model with id <see cref="ModelId"/>.
        /// </summary>
        public override void Execute()
        {
            IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();
            object           model           = workflowManager.GetModel(ModelId);

            if (model == null)
            {
                ServiceRegistration.Get <ILogger>().Warn("MethodCallAction: Unable to load model with id '{0}'", ModelId);
                return;
            }

            MethodInfo mi = model.GetType().GetMethod(MethodName);

            if (mi == null)
            {
                ServiceRegistration.Get <ILogger>().Warn("MethodCallAction: Unable to find method of name '{0}' in model with id '{1}'",
                                                         MethodName, ModelId);
                return;
            }
            try
            {
                mi.Invoke(model, new object[] {});
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Warn("MethodCallAction: Error calling method of name '{0}' in model with id '{1}'", e,
                                                         MethodName, ModelId);
            }
        }
Example #3
0
        protected static async Task <bool> PlayChannelAsync(int channelId)
        {
            if (!ServiceRegistration.IsRegistered <ITvHandler>())
            {
                Logger.Error($"WifiRemote: Play Channel: No tv handler");
                return(false);
            }

            ITvHandler tvHandler = ServiceRegistration.Get <ITvHandler>();
            var        channel   = await tvHandler.ChannelAndGroupInfo.GetChannelAsync(channelId);

            if (!channel.Success)
            {
                Logger.Info($"WifiRemote: Play Channel: Channel with id '{0}' not found", channelId);
                return(false);
            }

            IWorkflowManager  workflowManager = ServiceRegistration.Get <IWorkflowManager>();
            SlimTvClientModel model           = workflowManager.GetModel(SlimTvClientModel.MODEL_ID) as SlimTvClientModel;

            if (model != null)
            {
                await model.Tune(channel.Result);
            }

            return(true);
        }
        private void ZapTimerElapsed(object sender, EventArgs eventArgs)
        {
            // Zap to channel
            int number;

            if (!int.TryParse(ChannelNumberOrIndex, out number) || number < 1)
            {
                return;
            }

            IWorkflowManager  workflowManager = ServiceRegistration.Get <IWorkflowManager>();
            SlimTvClientModel model           = workflowManager.GetModel(SlimTvClientModel.MODEL_ID) as SlimTvClientModel;

            if (model == null)
            {
                return;
            }

            SlimTvClientSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <SlimTvClientSettings>();

            if (settings.ZapByChannelIndex)
            {
                // Channel index starts by 0, user enters 1 based numbers
                number--;
                _ = model.TuneByIndex(number);
            }
            else
            {
                _ = model.TuneByChannelNumber(number);
            }

            ClearZapTimer();
        }
        protected static void ShowDialog(string title, ItemsList items)
        {
            IWorkflowManager   workflowManager = ServiceRegistration.Get <IWorkflowManager>();
            LoadSkinThemeModel model           = (LoadSkinThemeModel)workflowManager.GetModel(LST_MODEL_ID);

            model.Initialize(title, items);
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(DIALOG_LOAD_SKIN_THEME);
        }
 protected void SetLayout()
 {
   IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>();
   ViewModeModel vwm = workflowManager.GetModel(ViewModeModel.VM_MODEL_ID) as ViewModeModel;
   if (vwm != null)
   {
     vwm.LayoutType = LayoutType.GridLayout;
     vwm.LayoutSize = LayoutSize.Medium;
   }
 }
Example #7
0
        private static void TuneToChannel(IChannel channel)
        {
            if (channel == null)
            {
                return;
            }
            IWorkflowManager  workflowManager = ServiceRegistration.Get <IWorkflowManager>();
            SlimTvClientModel model           = workflowManager.GetModel(SlimTvClientModel.MODEL_ID) as SlimTvClientModel;

            _ = model?.Tune(channel);
        }
Example #8
0
        public static async Task TuneChannel(IChannel channel)
        {
            IWorkflowManager  workflowManager = ServiceRegistration.Get <IWorkflowManager>();
            SlimTvClientModel model           = workflowManager.GetModel(SlimTvClientModel.MODEL_ID) as SlimTvClientModel;

            if (model != null)
            {
                await model.Tune(channel);

                // Always switch to fullscreen
                workflowManager.NavigatePush(Consts.WF_STATE_ID_FULLSCREEN_VIDEO);
            }
        }
        private void UpdateLayout()
        {
            // Clear the initializing flag, so further changes to layout properties will be saved.
            _initializing = false;

            IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();
            ViewModeModel    vm = workflowManager.GetModel(ViewModeModel.VM_MODEL_ID) as ViewModeModel;

            if (vm != null)
            {
                vm.Update();
            }
        }
        private void IsHomeChanged(AbstractProperty property, object oldvalue)
        {
            if (!IsHome)
            {
                return;
            }
            IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();
            LatestMediaModel lmm             = workflowManager.GetModel(LatestMediaModel.LATEST_MEDIA_MODEL_ID) as LatestMediaModel;

            if (lmm != null)
            {
                lmm.UpdateItems();
            }
        }
Example #11
0
        private void CloseOSD()
        {
            IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();
            VideoPlayerModel model           = workflowManager.GetModel(VideoPlayerModel.MODEL_ID) as VideoPlayerModel;

            if (model == null)
            {
                return;
            }

            if (model.IsOSDVisible)
            {
                model.CloseOSD();
            }
        }
        public void Execute()
        {
            IWorkflowManager     workflowManager = ServiceRegistration.Get <IWorkflowManager>();
            MediaNavigationModel model           = (MediaNavigationModel)workflowManager.GetModel(MediaNavigationModel.MEDIA_MODEL_ID);
            NavigationData       navigationData  = model.NavigationData;

            workflowManager.NavigatePopAsync(1);
            if (navigationData == null || !navigationData.IsEnabled)
            {
                ServiceRegistration.Get <ILogger>().Error("DeleteAllRecordings: No enabled navigation data present");
                return;
            }
            List <MediaItem> mediaItems = navigationData.CurrentScreenData.GetAllMediaItems().ToList();

            QueryDeleteAll(mediaItems);
        }
        protected void TuneChannelByProgram(IProgram program)
        {
            IChannel channel;

            if (_tvHandler.ProgramInfo.GetChannel(program, out channel))
            {
                IWorkflowManager  workflowManager = ServiceRegistration.Get <IWorkflowManager>();
                SlimTvClientModel model           = workflowManager.GetModel(SlimTvClientModel.MODEL_ID) as SlimTvClientModel;
                if (model != null)
                {
                    model.Tune(channel);
                    // Always switch to fullscreen
                    workflowManager.NavigatePush(Consts.WF_STATE_ID_FULLSCREEN_VIDEO);
                }
            }
        }
        private void CloseOSD()
        {
            IWorkflowManager   workflowManager = ServiceRegistration.Get <IWorkflowManager>();
            BaseOSDPlayerModel model           = workflowManager.GetModel(_tvHandler.GetChannel(SlotIndex).MediaType == MediaType.Radio ?
                                                                          AudioPlayerModel.MODEL_ID : VideoPlayerModel.MODEL_ID) as BaseOSDPlayerModel;

            if (model == null)
            {
                return;
            }

            if (model.IsOSDVisible)
            {
                model.CloseOSD();
            }
        }
        protected async Task TuneChannelByProgram(IProgram program)
        {
            var result = await _tvHandler.ProgramInfo.GetChannelAsync(program);

            if (result.Success)
            {
                IWorkflowManager  workflowManager = ServiceRegistration.Get <IWorkflowManager>();
                SlimTvClientModel model           = workflowManager.GetModel(SlimTvClientModel.MODEL_ID) as SlimTvClientModel;
                if (model != null)
                {
                    await model.Tune(result.Result);

                    // Always switch to fullscreen
                    workflowManager.NavigatePush(result.Result.MediaType == MediaType.Radio ? Consts.WF_STATE_ID_FULLSCREEN_AUDIO : Consts.WF_STATE_ID_FULLSCREEN_VIDEO);
                }
            }
        }
Example #16
0
        public void Execute()
        {
            IWorkflowManager         workflowManager         = ServiceRegistration.Get <IWorkflowManager>();
            IServerConnectionManager serverConnectionManager = ServiceRegistration.Get <IServerConnectionManager>();
            IContentDirectory        contentDirectory        = serverConnectionManager.ContentDirectory;
            SystemName homeServerSystem   = serverConnectionManager.LastHomeServerSystem;
            bool       localHomeServer    = homeServerSystem == null ? false : homeServerSystem.IsLocalSystem();
            bool       homeServerConncted = contentDirectory != null;

            ILocalSharesManagement localSharesManagement = ServiceRegistration.Get <ILocalSharesManagement>();

            if (localHomeServer)
            {
                if (homeServerConncted && contentDirectory.GetShares(null, SharesFilter.All).Count == 0)
                {
                    contentDirectory.SetupDefaultServerShares();
                }
                // Update of shares lists is only necessary in case the shares are managed by our home server because
                // in this case, we don't get a notification about the change in the set of shares.
                // Maybe we should add such a notification later...
                SharesConfigModel model = workflowManager.GetModel(SharesConfigModel.MODEL_ID_SHARESCONFIG) as SharesConfigModel;
                if (model != null)
                {
                    model.UpdateSharesLists_NoLock(false);
                }
            }
            else
            {
                if (localSharesManagement.Shares.Count == 0)
                {
                    localSharesManagement.SetupDefaultShares();
                }
                // The shares config model listens to update events from the local shares management, so we don't need to
                // trigger an update of the shares lists here
            }
        }
Example #17
0
        public static MediaNavigationModel GetCurrentInstance()
        {
            IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();

            return((MediaNavigationModel)workflowManager.GetModel(MEDIA_MODEL_ID));
        }
Example #18
0
        public static VideoBackgroundModel GetCurrentInstance()
        {
            IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();

            return((VideoBackgroundModel)workflowManager.GetModel(MODEL_ID));
        }
        protected void ShowProgramActions(IProgram program)
        {
            if (program == null)
            {
                return;
            }

            ILocalization loc = ServiceRegistration.Get <ILocalization>();

            _programActions = new ItemsList();
            // if program is over already, there is nothing to do.
            if (program.EndTime < DateTime.Now)
            {
                _programActions.Add(new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.ProgramOver]")));
            }
            else
            {
                // Check if program is currently running.
                bool isRunning = DateTime.Now >= program.StartTime && DateTime.Now <= program.EndTime;
                if (isRunning)
                {
                    _programActions.Add(new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.WatchNow]"))
                    {
                        Command = new MethodDelegateCommand(() =>
                        {
                            IChannel channel;
                            if (_tvHandler.ProgramInfo.GetChannel(program, out channel))
                            {
                                IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();
                                SlimTvClientModel model          = workflowManager.GetModel(SlimTvClientModel.MODEL_ID) as SlimTvClientModel;
                                if (model != null)
                                {
                                    model.Tune(channel);
                                }
                            }
                        })
                    });
                }

                if (_tvHandler.ScheduleControl != null)
                {
                    RecordingStatus recordingStatus;
                    if (_tvHandler.ScheduleControl.GetRecordingStatus(program, out recordingStatus) && recordingStatus != RecordingStatus.None)
                    {
                        if (isRunning)
                        {
                            _programActions.Add(
                                new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.WatchFromBeginning]"))
                            {
                                Command = new MethodDelegateCommand(() => _tvHandler.WatchRecordingFromBeginning(program))
                            });
                        }

                        _programActions.Add(
                            new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.DeleteSchedule]"))
                        {
                            Command = new MethodDelegateCommand(() =>
                            {
                                if (_tvHandler.ScheduleControl.RemoveScheduleForProgram(program, ScheduleRecordingType.Once))
                                {
                                    UpdateRecordingStatus(program, RecordingStatus.None);
                                }
                            }
                                                                )
                        });
                    }
                    else
                    {
                        _programActions.Add(
                            new ListItem(Consts.KEY_NAME, loc.ToString(isRunning ? "[SlimTvClient.RecordNow]" : "[SlimTvClient.CreateSchedule]"))
                        {
                            Command = new MethodDelegateCommand(() =>
                            {
                                ISchedule schedule;
                                if (_tvHandler.ScheduleControl.CreateSchedule(program, ScheduleRecordingType.Once, out schedule))
                                {
                                    UpdateRecordingStatus(program, RecordingStatus.Scheduled);
                                }
                            }
                                                                )
                        });
                    }
                }
            }

            // Add list entries for extensions
            foreach (KeyValuePair <Guid, TvExtension> programExtension in _programExtensions)
            {
                TvExtension extension = programExtension.Value;
                // First check if this extension applies for the selected program
                if (!extension.Extension.IsAvailable(program))
                {
                    continue;
                }

                _programActions.Add(
                    new ListItem(Consts.KEY_NAME, loc.ToString(extension.Caption))
                {
                    Command = new MethodDelegateCommand(() => extension.Extension.ProgramAction(program))
                });
            }

            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(_programActionsDialogName);
        }