public override async Task <AsyncResult <ContentDirectoryMessaging.MediaItemChangeType> > ProcessAsync(MediaItem mediaItem)
        {
            await PlayItemsModel.PlayOrEnqueueItem(mediaItem, false, PlayerContextConcurrencyMode.None);

            AsyncResult <ContentDirectoryMessaging.MediaItemChangeType> result = new AsyncResult <ContentDirectoryMessaging.MediaItemChangeType>(true, ContentDirectoryMessaging.MediaItemChangeType.None);

            return(result);
        }
Esempio n. 2
0
        public async Task <bool> StartTimeshiftAsync(int slotIndex, IChannel channel)
        {
            if (TimeshiftControl == null || channel == null)
            {
                return(false);
            }

            ServiceRegistration.Get <ILogger>().Debug("SlimTvHandler: StartTimeshift slot {0} for channel '{1}'", slotIndex, channel.Name);

            int newSlotIndex = GetMatchingSlotIndex(slotIndex);

            if (_slotContexes[newSlotIndex].Channel != null && _slotContexes[newSlotIndex].Channel.MediaType != channel.MediaType)
            {
                // Switching between TV and radio - must close old player and start brand new one
                IPlayerContext playerContext = existingPlayerContext(newSlotIndex);
                if (playerContext == null)
                {
                    return(false);
                }
                playerContext.Close();
                await StopTimeshiftAsync(newSlotIndex);
            }
            var result = await TimeshiftControl.StartTimeshiftAsync(newSlotIndex, channel);

            IList <MultipleMediaItemAspect> pras;
            MediaItem timeshiftMediaItem = result.Result;

            if (result.Success && timeshiftMediaItem != null && MediaItemAspect.TryGetAspects(timeshiftMediaItem.Aspects, ProviderResourceAspect.Metadata, out pras))
            {
                string newAccessorPath = (string)pras[0].GetAttributeValue(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH);

                // if slot was empty, start a new player
                if (_slotContexes[newSlotIndex].AccessorPath == null)
                {
                    AddOrUpdateTimeshiftContext(timeshiftMediaItem as LiveTvMediaItem, channel);
                    PlayerContextConcurrencyMode playMode = GetMatchingPlayMode();
                    await PlayItemsModel.PlayOrEnqueueItem(timeshiftMediaItem, true, playMode);
                }
                else
                {
                    try
                    {
                        _slotContexes[newSlotIndex].CardChanging = true;
                        UpdateExistingMediaItem(timeshiftMediaItem, newSlotIndex);
                    }
                    finally
                    {
                        _slotContexes[newSlotIndex].CardChanging = false;
                    }
                }
                _slotContexes[newSlotIndex].AccessorPath = newAccessorPath;
                _slotContexes[newSlotIndex].Channel      = channel;
            }
            return(result.Success);
        }
Esempio n. 3
0
        public bool WatchRecordingFromBeginning(IProgram program)
        {
            string fileOrStream;

            if (ScheduleControl.GetRecordingFileOrStream(program, out fileOrStream))
            {
                IChannel channel;
                if (ChannelAndGroupInfo.GetChannel(program.ChannelId, out channel))
                {
                    MediaItem recordig = SlimTvMediaItemBuilder.CreateRecordingMediaItem(0, fileOrStream, program, channel);
                    PlayerContextConcurrencyMode playMode = GetMatchingPlayMode();
                    PlayItemsModel.PlayOrEnqueueItem(recordig, true, playMode);
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 4
0
        public bool StartTimeshift(int slotIndex, IChannel channel)
        {
            if (TimeshiftControl == null || channel == null)
            {
                return(false);
            }

            ServiceRegistration.Get <ILogger>().Debug("SlimTvHandler: StartTimeshift slot {0} for channel '{1}'", slotIndex, channel.Name);

            int       newSlotIndex = GetMatchingSlotIndex(slotIndex);
            MediaItem timeshiftMediaItem;
            bool      result = TimeshiftControl.StartTimeshift(newSlotIndex, channel, out timeshiftMediaItem);
            IList <MultipleMediaItemAspect> pras;

            if (result && timeshiftMediaItem != null && MediaItemAspect.TryGetAspects(timeshiftMediaItem.Aspects, ProviderResourceAspect.Metadata, out pras))
            {
                string newAccessorPath = (string)pras[0].GetAttributeValue(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH);

                // if slot was empty, start a new player
                if (_slotContexes[newSlotIndex].AccessorPath == null)
                {
                    AddOrUpdateTimeshiftContext(timeshiftMediaItem as LiveTvMediaItem, channel);
                    PlayerContextConcurrencyMode playMode = GetMatchingPlayMode();
                    PlayItemsModel.PlayOrEnqueueItem(timeshiftMediaItem, true, playMode);
                }
                else
                {
                    try
                    {
                        _slotContexes[newSlotIndex].CardChanging = true;
                        UpdateExistingMediaItem(timeshiftMediaItem);
                    }
                    finally
                    {
                        _slotContexes[newSlotIndex].CardChanging = false;
                    }
                }
                _slotContexes[newSlotIndex].AccessorPath = newAccessorPath;
                _slotContexes[newSlotIndex].Channel      = channel;
            }

            return(result);
        }
Esempio n. 5
0
        public bool StartTimeshift(int slotIndex, IChannel channel)
        {
            if (TimeshiftControl == null || channel == null)
            {
                return(false);
            }

            int       newSlotIndex = GetMatchingSlotIndex(slotIndex);
            MediaItem timeshiftMediaItem;
            bool      result = TimeshiftControl.StartTimeshift(newSlotIndex, channel, out timeshiftMediaItem);

            if (result && timeshiftMediaItem != null)
            {
                string newAccessorPath =
                    (string)timeshiftMediaItem.Aspects[ProviderResourceAspect.ASPECT_ID].GetAttributeValue(
                        ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH);

                // if slot was empty, start a new player
                if (_slotContexes[newSlotIndex].AccessorPath == null)
                {
                    AddTimeshiftContext(timeshiftMediaItem as LiveTvMediaItem, channel);
                    PlayerContextConcurrencyMode playMode = GetMatchingPlayMode();
                    PlayItemsModel.PlayOrEnqueueItem(timeshiftMediaItem, true, playMode);
                }
                else
                {
                    try
                    {
                        _slotContexes[newSlotIndex].CardChanging = true;
                        UpdateExistingMediaItem(timeshiftMediaItem);
                    }
                    finally
                    {
                        _slotContexes[newSlotIndex].CardChanging = false;
                    }
                }
                _slotContexes[newSlotIndex].AccessorPath = newAccessorPath;
                _slotContexes[newSlotIndex].Channel      = channel;
            }

            return(result);
        }
Esempio n. 6
0
 public override bool Process(MediaItem mediaItem, out ContentDirectoryMessaging.MediaItemChangeType changeType)
 {
     changeType = ContentDirectoryMessaging.MediaItemChangeType.None;
     PlayItemsModel.PlayOrEnqueueItem(mediaItem, false, PlayerContextConcurrencyMode.None);
     return(true);
 }