void CGUIWindowPVRGuide::UpdateSelectedItemPath() { if (m_viewControl.GetCurrentControl() == GUIDE_VIEW_TIMELINE) { CGUIEPGGridContainer *epgGridContainer = (CGUIEPGGridContainer*) GetControl(m_viewControl.GetCurrentControl()); if (epgGridContainer) { CPVRChannel* channel = epgGridContainer->GetChannel(epgGridContainer->GetSelectedChannel()); if (channel != NULL) m_selectedItemPaths.at(m_bRadio) = channel->Path(); } } else CGUIWindowPVRBase::UpdateSelectedItemPath(); }
int CPVRChannels::GetChannels(CFileItemList* results, int iGroupID /* = -1 */, bool bHidden /* = false */) { int iAmount = 0; SortByChannelNumber(); for (unsigned int ptr = 0; ptr < size(); ptr++) { CPVRChannel *channel = at(ptr); if (channel->IsHidden() != bHidden) continue; if (iGroupID != -1 && channel->GroupID() != iGroupID) continue; CFileItemPtr channelFile(new CFileItem(*channel)); if (channel->IsRadio()) { CMusicInfoTag* musictag = channelFile->GetMusicInfoTag(); if (musictag) { const CPVREpgInfoTag *epgNow = channel->GetEPGNow(); musictag->SetURL(channel->Path()); musictag->SetTitle(epgNow->Title()); musictag->SetArtist(channel->ChannelName()); musictag->SetAlbumArtist(channel->ChannelName()); musictag->SetGenre(epgNow->Genre()); musictag->SetDuration(epgNow->GetDuration()); musictag->SetLoaded(true); musictag->SetComment(""); musictag->SetLyrics(""); } } results->Add(channelFile); iAmount++; } return iAmount; }
bool CPVRManager::UpdateItem(CFileItem& item) { /* Don't update if a recording is played */ if (item.IsPVRRecording()) return false; if (!item.IsPVRChannel()) { CLog::Log(LOGERROR, "CPVRManager - %s - no channel tag provided", __FUNCTION__); return false; } CSingleLock lock(m_critSection); if (!m_currentFile || *m_currentFile->GetPVRChannelInfoTag() == *item.GetPVRChannelInfoTag()) return false; g_application.CurrentFileItem() = *m_currentFile; g_infoManager.SetCurrentItem(*m_currentFile); CPVRChannel* channelTag = item.GetPVRChannelInfoTag(); CEpgInfoTag epgTagNow; bool bHasTagNow = channelTag->GetEPGNow(epgTagNow); if (channelTag->IsRadio()) { CMusicInfoTag* musictag = item.GetMusicInfoTag(); if (musictag) { musictag->SetTitle(bHasTagNow ? epgTagNow.Title() : g_localizeStrings.Get(19055)); if (bHasTagNow) musictag->SetGenre(epgTagNow.Genre()); musictag->SetDuration(bHasTagNow ? epgTagNow.GetDuration() : 3600); musictag->SetURL(channelTag->Path()); musictag->SetArtist(channelTag->ChannelName()); musictag->SetAlbumArtist(channelTag->ChannelName()); musictag->SetLoaded(true); musictag->SetComment(StringUtils::EmptyString); musictag->SetLyrics(StringUtils::EmptyString); } } else { CVideoInfoTag *videotag = item.GetVideoInfoTag(); if (videotag) { videotag->m_strTitle = bHasTagNow ? epgTagNow.Title() : g_localizeStrings.Get(19055); if (bHasTagNow) videotag->m_genre = epgTagNow.Genre(); videotag->m_strPath = channelTag->Path(); videotag->m_strFileNameAndPath = channelTag->Path(); videotag->m_strPlot = bHasTagNow ? epgTagNow.Plot() : StringUtils::EmptyString; videotag->m_strPlotOutline = bHasTagNow ? epgTagNow.PlotOutline() : StringUtils::EmptyString; videotag->m_iEpisode = bHasTagNow ? epgTagNow.EpisodeNum() : 0; } } CPVRChannel* tagPrev = item.GetPVRChannelInfoTag(); if (tagPrev && tagPrev->ChannelNumber() != m_LastChannel) { m_LastChannel = tagPrev->ChannelNumber(); m_LastChannelChanged = XbmcThreads::SystemClockMillis(); } if (XbmcThreads::SystemClockMillis() - m_LastChannelChanged >= (unsigned int) g_guiSettings.GetInt("pvrplayback.channelentrytimeout") && m_LastChannel != m_PreviousChannel[m_PreviousChannelIndex]) m_PreviousChannel[m_PreviousChannelIndex ^= 1] = m_LastChannel; else m_LastChannelChanged = XbmcThreads::SystemClockMillis(); return false; }
bool CPVRManager::UpdateItem(CFileItem& item) { /* Don't update if a recording is played */ if (item.IsPVRRecording()) return false; if (!item.IsPVRChannel()) { CLog::Log(LOGERROR, "CPVRManager - %s - no channel tag provided", __FUNCTION__); return false; } CSingleLock lock(m_critSection); if (!m_currentFile || *m_currentFile->GetPVRChannelInfoTag() == *item.GetPVRChannelInfoTag()) return false; g_application.CurrentFileItem() = *m_currentFile; g_infoManager.SetCurrentItem(*m_currentFile); CPVRChannel* channelTag = item.GetPVRChannelInfoTag(); CEpgInfoTag epgTagNow; bool bHasTagNow = channelTag->GetEPGNow(epgTagNow); if (channelTag->IsRadio()) { CMusicInfoTag* musictag = item.GetMusicInfoTag(); if (musictag) { musictag->SetTitle(bHasTagNow ? epgTagNow.Title() : g_guiSettings.GetBool("epg.hidenoinfoavailable") ? StringUtils::EmptyString : g_localizeStrings.Get(19055)); // no information available if (bHasTagNow) musictag->SetGenre(epgTagNow.Genre()); musictag->SetDuration(bHasTagNow ? epgTagNow.GetDuration() : 3600); musictag->SetURL(channelTag->Path()); musictag->SetArtist(channelTag->ChannelName()); musictag->SetAlbumArtist(channelTag->ChannelName()); musictag->SetLoaded(true); musictag->SetComment(StringUtils::EmptyString); musictag->SetLyrics(StringUtils::EmptyString); } } else { CVideoInfoTag *videotag = item.GetVideoInfoTag(); if (videotag) { videotag->m_strTitle = bHasTagNow ? epgTagNow.Title() : g_guiSettings.GetBool("epg.hidenoinfoavailable") ? StringUtils::EmptyString : g_localizeStrings.Get(19055); // no information available if (bHasTagNow) videotag->m_genre = epgTagNow.Genre(); videotag->m_strPath = channelTag->Path(); videotag->m_strFileNameAndPath = channelTag->Path(); videotag->m_strPlot = bHasTagNow ? epgTagNow.Plot() : StringUtils::EmptyString; videotag->m_strPlotOutline = bHasTagNow ? epgTagNow.PlotOutline() : StringUtils::EmptyString; videotag->m_iEpisode = bHasTagNow ? epgTagNow.EpisodeNum() : 0; } } return false; }
bool CPVRManager::PerformChannelSwitch(CPVRChannel &channel, bool bPreview) { // check parental lock state if (IsParentalLocked(channel)) return false; // invalid channel if (channel.ClientID() < 0) return false; // check whether we're waiting for a previous switch to complete { CSingleLock lock(m_critSection); if (m_bIsSwitchingChannels) { CLog::Log(LOGDEBUG, "PVRManager - %s - can't switch to channel '%s'. waiting for the previous switch to complete", __FUNCTION__, channel.ChannelName().c_str()); return false; } // no need to do anything except switching m_currentFile if (bPreview) { delete m_currentFile; m_currentFile = new CFileItem(channel); return true; } m_bIsSwitchingChannels = true; } CLog::Log(LOGDEBUG, "PVRManager - %s - switching to channel '%s'", __FUNCTION__, channel.ChannelName().c_str()); // will be deleted by CPVRChannelSwitchJob::DoWork() CFileItem* previousFile = m_currentFile; m_currentFile = NULL; bool bSwitched(false); // switch channel if (!m_addons->SwitchChannel(channel)) { // switch failed CSingleLock lock(m_critSection); m_bIsSwitchingChannels = false; CLog::Log(LOGERROR, "PVRManager - %s - failed to switch to channel '%s'", __FUNCTION__, channel.ChannelName().c_str()); std::string msg = StringUtils::Format(g_localizeStrings.Get(19035).c_str(), channel.ChannelName().c_str()); // CHANNELNAME could not be played. Check the log for details. CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(19166), // PVR information msg); } else { // switch successful bSwitched = true; // save previous and load new channel's settings (view mode is updated in // the player) g_application.SaveFileState(); g_application.LoadVideoSettings(channel.Path()); // set channel as selected item CGUIWindowPVRBase::SetSelectedItemPath(channel.IsRadio(), channel.Path()); UpdateLastWatched(channel); CSingleLock lock(m_critSection); m_currentFile = new CFileItem(channel); m_bIsSwitchingChannels = false; CLog::Log(LOGNOTICE, "PVRManager - %s - switched to channel '%s'", __FUNCTION__, channel.ChannelName().c_str()); } // announce OnStop and OnPlay. yes, this ain't pretty { CSingleLock lock(m_critSectionTriggers); m_pendingUpdates.push_back(new CPVRChannelSwitchJob(previousFile, m_currentFile)); } m_triggerEvent.Set(); return bSwitched; }