private void UpdateExistingMediaItem(MediaItem timeshiftMediaItem) { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); for (int index = 0; index < playerContextManager.NumActivePlayerContexts; index++) { IPlayerContext playerContext = playerContextManager.GetPlayerContext(index); if (playerContext == null) { continue; } LiveTvMediaItem liveTvMediaItem = playerContext.CurrentMediaItem as LiveTvMediaItem; LiveTvMediaItem newLiveTvMediaItem = timeshiftMediaItem as LiveTvMediaItem; // Check if this is "our" media item to update. if (liveTvMediaItem == null || newLiveTvMediaItem == null || !IsSameSlot(liveTvMediaItem, newLiveTvMediaItem)) { continue; } if (!IsSameLiveTvItem(liveTvMediaItem, newLiveTvMediaItem)) { // Switch MediaItem in current slot, the LiveTvPlayer implements IReusablePlayer and will change its source without need to change full player. playerContext.DoPlay(newLiveTvMediaItem); // Copy old channel history into new item liveTvMediaItem.TimeshiftContexes.ToList().ForEach(tc => newLiveTvMediaItem.TimeshiftContexes.Add(tc)); // Use new MediaItem, so new context will be added to new instance. liveTvMediaItem = newLiveTvMediaItem; } // Add new timeshift context AddOrUpdateTimeshiftContext(liveTvMediaItem, newLiveTvMediaItem.AdditionalProperties[LiveTvMediaItem.CHANNEL] as IChannel); } }
private void UpdateExistingMediaItem(MediaItem timeshiftMediaItem) { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); for (int index = 0; index < playerContextManager.NumActivePlayerContexts; index++) { IPlayerContext playerContext = playerContextManager.GetPlayerContext(index); if (playerContext == null) { continue; } LiveTvMediaItem liveTvMediaItem = playerContext.CurrentMediaItem as LiveTvMediaItem; LiveTvMediaItem newLiveTvMediaItem = timeshiftMediaItem as LiveTvMediaItem; // Check if this is "our" media item to update. if (liveTvMediaItem == null || newLiveTvMediaItem == null || !IsSameSlot(liveTvMediaItem, newLiveTvMediaItem)) { continue; } if (!IsSameLiveTvItem(liveTvMediaItem, newLiveTvMediaItem)) { // Switch MediaItem in current slot playerContext.DoPlay(newLiveTvMediaItem); // Clear former timeshift contexes (card change cause loss of buffer in rtsp mode). liveTvMediaItem.TimeshiftContexes.Clear(); } // Add new timeshift context AddTimeshiftContext(liveTvMediaItem, newLiveTvMediaItem.AdditionalProperties[LiveTvMediaItem.CHANNEL] as IChannel); } }
private void UpdateExistingMediaItem(MediaItem timeshiftMediaItem) { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); for (int index = 0; index < playerContextManager.NumActivePlayerContexts; index++) { IPlayerContext playerContext = playerContextManager.GetPlayerContext(index); if (playerContext != null) { LiveTvMediaItem liveTvMediaItem = playerContext.CurrentMediaItem as LiveTvMediaItem; LiveTvMediaItem newLiveTvMediaItem = timeshiftMediaItem as LiveTvMediaItem; if (liveTvMediaItem != null && newLiveTvMediaItem != null) { // check if this is "our" media item to update. if ((int)liveTvMediaItem.AdditionalProperties[LiveTvMediaItem.SLOT_INDEX] == (int)newLiveTvMediaItem.AdditionalProperties[LiveTvMediaItem.SLOT_INDEX]) { if (liveTvMediaItem.Aspects[ProviderResourceAspect.ASPECT_ID].GetAttributeValue(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH).ToString() != newLiveTvMediaItem.Aspects[ProviderResourceAspect.ASPECT_ID].GetAttributeValue(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH).ToString()) { //switch MediaItem in current slot playerContext.DoPlay(newLiveTvMediaItem); //clear former timeshift contexes (card change cause loss of buffer in rtsp mode). liveTvMediaItem.TimeshiftContexes.Clear(); } // add new timeshift context AddTimeshiftContext(liveTvMediaItem, newLiveTvMediaItem.AdditionalProperties[LiveTvMediaItem.CHANNEL] as IChannel); } } } } }
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); }
private void UpdateExistingMediaItem(MediaItem timeshiftMediaItem, int slotIndex) { LiveTvMediaItem newLiveTvMediaItem = timeshiftMediaItem as LiveTvMediaItem; IPlayerContext playerContext = existingPlayerContext(slotIndex); if (playerContext == null) { return; } LiveTvMediaItem liveTvMediaItem = playerContext.CurrentMediaItem as LiveTvMediaItem; if (!IsSameLiveTvItem(liveTvMediaItem, newLiveTvMediaItem)) { // Switch MediaItem in current slot, the LiveTvPlayer implements IReusablePlayer and will change its source without need to change full player. playerContext.DoPlay(newLiveTvMediaItem); // Copy old channel history into new item liveTvMediaItem.TimeshiftContexes.ToList().ForEach(tc => newLiveTvMediaItem.TimeshiftContexes.Add(tc)); // Use new MediaItem, so new context will be added to new instance. liveTvMediaItem = newLiveTvMediaItem; } // Add new timeshift context AddOrUpdateTimeshiftContext(liveTvMediaItem, newLiveTvMediaItem.AdditionalProperties[LiveTvMediaItem.CHANNEL] as IChannel); }