private async Task <bool> InitActionsList() { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); IPlayerContext playerContext = playerContextManager.GetPlayerContext(PlayerChoice.PrimaryPlayer); if (playerContext == null) { return(false); } LiveTvMediaItem liveTvMediaItem = playerContext.CurrentMediaItem as LiveTvMediaItem; ILivePlayer player = playerContext.CurrentPlayer as ILivePlayer; if (liveTvMediaItem == null || player == null) { return(false); } ITimeshiftContext context = liveTvMediaItem.TimeshiftContexes.LastOrDefault(); if (context == null || context.Channel == null) { return(false); } ILocalization localization = ServiceRegistration.Get <ILocalization>(); var result = await _tvHandler.ProgramInfo.GetNowNextProgramAsync(context.Channel); return(await InitActionsList(result.Success?result.Result[0] : null, context.Channel)); }
protected async 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). await 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) { ILivePlayer player = playerContext.CurrentPlayer as ILivePlayer; if (player != null) { LiveTvMediaItem item = player.CurrentItem; ITimeshiftContext context = item == null ? null : item.TimeshiftContexes.LastOrDefault(); IProgram currentProgram = null; IProgram nextProgram = null; IChannel channel = null; if (context != null && context.Channel != null) { channel = context.Channel; ChannelName = channel.Name; ChannelLogoType = channel.GetFanArtMediaType(); if (_tvHandler.ProgramInfo != null) { var result = await _tvHandler.ProgramInfo.GetNowNextProgramAsync(channel); if (result.Success) { currentProgram = result.Result[0]; nextProgram = result.Result[1]; double progress = currentProgram == null ? 100d : (DateTime.Now - currentProgram.StartTime).TotalSeconds / (currentProgram.EndTime - currentProgram.StartTime).TotalSeconds * 100; _programProgressProperty.SetValue(progress); } } } CurrentProgram.SetProgram(currentProgram, channel); NextProgram.SetProgram(nextProgram, channel); } } }
private bool InitActionsList() { _dialogActionsList.Clear(); DialogHeader = "[SlimTvClient.RecordActions]"; IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); IPlayerContext playerContext = playerContextManager.GetPlayerContext(PlayerChoice.PrimaryPlayer); if (playerContext == null) { return(false); } LiveTvMediaItem liveTvMediaItem = playerContext.CurrentMediaItem as LiveTvMediaItem; LiveTvPlayer player = playerContext.CurrentPlayer as LiveTvPlayer; if (liveTvMediaItem == null || player == null) { return(false); } ITimeshiftContext context = player.TimeshiftContexes.LastOrDefault(); if (context == null || context.Channel == null) { return(false); } IProgram programNow; IProgram programNext; ListItem item; ILocalization localization = ServiceRegistration.Get <ILocalization>(); bool isRecording = false; if (_tvHandler.ProgramInfo.GetNowNextProgram(context.Channel, out programNow, out programNext)) { var recStatus = GetRecordingStatus(programNow); isRecording = recStatus.HasValue && recStatus.Value.HasFlag(RecordingStatus.Scheduled | RecordingStatus.Recording); item = new ListItem(Consts.KEY_NAME, localization.ToString(isRecording ? "[SlimTvClient.StopCurrentRecording]" : "[SlimTvClient.RecordCurrentProgram]", programNow.Title)) { Command = new MethodDelegateCommand(() => CreateOrDeleteSchedule(programNow)) }; _dialogActionsList.Add(item); } if (!isRecording) { item = new ListItem(Consts.KEY_NAME, "[SlimTvClient.RecordManual]") { Command = new MethodDelegateCommand(() => CreateOrDeleteSchedule(new Program { Title = localization.ToString("[SlimTvClient.ManualRecordingTitle]"), ChannelId = context.Channel.ChannelId, StartTime = DateTime.Now, EndTime = DateTime.Now.AddDays(1) })) }; _dialogActionsList.Add(item); } _dialogActionsList.FireChange(); return(true); }
protected string GetContextTitle(ITimeshiftContext timeshiftContext) { if (timeshiftContext == null) { return(string.Empty); } // We only use the channel history return(string.Format("{0}", timeshiftContext.Channel.Name)); }
private async Task <bool> InitActionsList() { _dialogActionsList.Clear(); DialogHeader = "[SlimTvClient.RecordActions]"; IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); IPlayerContext playerContext = playerContextManager.GetPlayerContext(PlayerChoice.PrimaryPlayer); if (playerContext == null) { return(false); } LiveTvMediaItem liveTvMediaItem = playerContext.CurrentMediaItem as LiveTvMediaItem; LiveTvPlayer player = playerContext.CurrentPlayer as LiveTvPlayer; if (liveTvMediaItem == null || player == null) { return(false); } ITimeshiftContext context = player.TimeshiftContexes.LastOrDefault(); if (context == null || context.Channel == null) { return(false); } ListItem item; ILocalization localization = ServiceRegistration.Get <ILocalization>(); bool isRecording = false; var result = await _tvHandler.ProgramInfo.GetNowNextProgramAsync(context.Channel); if (result.Success) { IProgram programNow = result.Result[0]; var recStatus = await GetRecordingStatusAsync(programNow); isRecording = recStatus.HasValue && recStatus.Value.HasFlag(RecordingStatus.Scheduled | RecordingStatus.Recording); item = new ListItem(Consts.KEY_NAME, localization.ToString(isRecording ? "[SlimTvClient.StopCurrentRecording]" : "[SlimTvClient.RecordCurrentProgram]", programNow.Title)) { Command = new AsyncMethodDelegateCommand(() => CreateOrDeleteSchedule(programNow)) }; _dialogActionsList.Add(item); } if (!isRecording) { item = new ListItem(Consts.KEY_NAME, "[SlimTvClient.RecordManual]") { Command = new AsyncMethodDelegateCommand(() => CreateOrDeleteScheduleByTimeAsync(context.Channel, DateTime.Now, DateTime.Now.AddDays(1))) }; _dialogActionsList.Add(item); } _dialogActionsList.FireChange(); return(true); }
protected override void Update() { // Don't update the current channel and program information if we are in zap osd. if (_tvHandler == null || !_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; IProgram currentProgram = null; IProgram nextProgram = null; if (context != null) { ChannelName = context.Channel.Name; currentProgram = context.Program; if (currentProgram != null) { 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 = nextPrograms[0]; } } } CurrentProgram.SetProgram(currentProgram); NextProgram.SetProgram(nextProgram); } } }
protected string GetContextTitle(ITimeshiftContext timeshiftContext) { if (timeshiftContext == null) { return(string.Empty); } string program = timeshiftContext.Program != null ? timeshiftContext.Program.Title : ServiceRegistration.Get <ILocalization>().ToString("[SlimTvClient.NoProgram]"); return(string.Format("{0}: {1}", timeshiftContext.Channel.Name, program)); }
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; if (context != null && context.Channel != null) { ChannelName = context.Channel.Name; if (_tvHandler.ProgramInfo != null && _tvHandler.ProgramInfo.GetNowNextProgram(context.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); NextProgram.SetProgram(nextProgram); } } }
private void AddTimeshiftContext(LiveTvMediaItem timeshiftMediaItem, IChannel channel) { IProgram program = GetCurrentProgram(channel); TimeshiftContext tsContext = new TimeshiftContext { Channel = channel, Program = program, TuneInTime = DateTime.Now }; int tc = timeshiftMediaItem.TimeshiftContexes.Count; if (tc > 0) { ITimeshiftContext lastContext = timeshiftMediaItem.TimeshiftContexes[tc - 1]; lastContext.TimeshiftDuration = DateTime.Now - lastContext.TuneInTime; } timeshiftMediaItem.TimeshiftContexes.Add(tsContext); }
protected string GetContextTitle(ITimeshiftContext timeshiftContext) { if (timeshiftContext == null) return string.Empty; string program = timeshiftContext.Program != null ? timeshiftContext.Program.Title : ServiceRegistration.Get<ILocalization>().ToString("[SlimTvClient.NoProgram]"); return string.Format("{0}: {1}", timeshiftContext.Channel.Name, program); }
protected string GetContextTitle(ITimeshiftContext timeshiftContext) { if (timeshiftContext == null) return string.Empty; // We only use the channel history return string.Format("{0}", timeshiftContext.Channel.Name); }