public static async Task <IList <WebChannelState> > ProcessAsync(IOwinContext context, string groupId, string userName) { if (!ServiceRegistration.IsRegistered <ITvProvider>()) { throw new BadRequestException("GetAllChannelStatesForGroup: ITvProvider not found"); } if (userName == String.Empty) { throw new BadRequestException("GetAllChannelStatesForGroup: userName is null"); } List <WebChannelState> output = new List <WebChannelState>(); IChannelAndGroupInfoAsync channelAndGroupInfo = ServiceRegistration.Get <ITvProvider>() as IChannelAndGroupInfoAsync; IChannelGroup channelGroup = new ChannelGroup { ChannelGroupId = int.Parse(groupId) }; var channels = await channelAndGroupInfo.GetChannelsAsync(channelGroup); if (!channels.Success) { throw new BadRequestException(string.Format("GetAllChannelStatesForGroup: Couldn't get channels for group: {0}", groupId)); } foreach (var channel in channels.Result) { output.Add(new WebChannelState { ChannelId = channel.ChannelId, State = ChannelState.Tunable // TODO: implement in SlimTv }); } return(output); }
public IList <IChannel> GetItems(string sortCriteria) { if (ServiceRegistration.IsRegistered <ITvProvider>()) { IChannelAndGroupInfoAsync channelAndGroupInfo = ServiceRegistration.Get <ITvProvider>() as IChannelAndGroupInfoAsync; IChannelGroup group = new ChannelGroup() { ChannelGroupId = GroupId }; var res = channelAndGroupInfo.GetChannelsAsync(group).Result; if (res.Success) { return(res.Result.OrderBy(c => c.Name).ToList()); } } return(null); }
private UPnPError OnGetChannels(DvAction action, IList <object> inParams, out IList <object> outParams, CallContext context) { outParams = new List <object>(); IChannelAndGroupInfoAsync channelAndGroupInfo = ServiceRegistration.Get <ITvProvider>() as IChannelAndGroupInfoAsync; if (channelAndGroupInfo == null) { return(new UPnPError(500, "IChannelAndGroupInfo service not available")); } int channelGroupId = (int)inParams[0]; AsyncResult <IList <IChannel> > result = channelAndGroupInfo.GetChannelsAsync(new ChannelGroup { ChannelGroupId = channelGroupId }).Result; outParams = new List <object> { result.Success, result.Result }; return(null); }