void CPlayerCoreFactory::GetPlayers(const CFileItem& item, std::vector<std::string>&players) const { CURL url(item.GetPath()); CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers(%s)", CURL::GetRedacted(item.GetPath()).c_str()); std::vector<std::string>validPlayers; GetPlayers(validPlayers); // Process rules for (auto rule: m_vecCoreSelectionRules) rule->GetPlayers(item, validPlayers, players); CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: matched {0} rules with players", players.size()); // Process defaults // Set video default player. Check whether it's video first (overrule audio and // game check). Also push these players in case it is NOT audio or game either. if (item.IsVideo() || (!item.IsAudio() && !item.IsGame())) { int idx = GetPlayerIndex("videodefaultplayer"); if (idx > -1) { std::string eVideoDefault = GetPlayerName(idx); CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: adding videodefaultplayer (%s)", eVideoDefault.c_str()); players.push_back(eVideoDefault); } GetPlayers(players, false, true); // Video-only players GetPlayers(players, true, true); // Audio & video players } // Set audio default player // Pushback all audio players in case we don't know the type if (item.IsAudio()) { int idx = GetPlayerIndex("audiodefaultplayer"); if (idx > -1) { std::string eAudioDefault = GetPlayerName(idx); CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: adding audiodefaultplayer (%s)", eAudioDefault.c_str()); players.push_back(eAudioDefault); } GetPlayers(players, true, false); // Audio-only players GetPlayers(players, true, true); // Audio & video players } if (item.IsGame()) { CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: adding retroplayer"); players.push_back("RetroPlayer"); } CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: added {0} players", players.size()); }
void CPlayerSelectionRule::GetPlayers(const CFileItem& item, VECPLAYERCORES &vecCores) { CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: considering rule: %s", m_name.c_str()); if (m_bStreamDetails && !item.HasVideoInfoTag()) return; if (m_tAudio >= 0 && (m_tAudio > 0) != item.IsAudio()) return; if (m_tVideo >= 0 && (m_tVideo > 0) != item.IsVideo()) return; if (m_tInternetStream >= 0 && (m_tInternetStream > 0) != item.IsInternetStream()) return; if (m_tDVD >= 0 && (m_tDVD > 0) != item.IsDVD()) return; if (m_tDVDFile >= 0 && (m_tDVDFile > 0) != item.IsDVDFile()) return; if (m_tDVDImage >= 0 && (m_tDVDImage > 0) != item.IsDVDImage()) return; CRegExp regExp; if (m_bStreamDetails) { if (!item.GetVideoInfoTag()->HasStreamDetails()) { CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: cannot check rule: %s, no StreamDetails", m_name.c_str()); return; } CStreamDetails streamDetails = item.GetVideoInfoTag()->m_streamDetails; if (CompileRegExp(m_audioCodec, regExp) && !MatchesRegExp(streamDetails.GetAudioCodec(), regExp)) return; if (CompileRegExp(m_videoCodec, regExp) && !MatchesRegExp(streamDetails.GetVideoCodec(), regExp)) return; if (CompileRegExp(m_videoResolution, regExp) && !MatchesRegExp(CStreamDetails::VideoDimsToResolutionDescription(streamDetails.GetVideoWidth(), streamDetails.GetVideoHeight()), regExp)) return; if (CompileRegExp(m_videoAspect, regExp) && !MatchesRegExp(CStreamDetails::VideoAspectToAspectDescription(streamDetails.GetVideoAspect()), regExp)) return; } CURL url(item.GetPath()); if (CompileRegExp(m_fileTypes, regExp) && !MatchesRegExp(url.GetFileType(), regExp)) return; if (CompileRegExp(m_protocols, regExp) && !MatchesRegExp(url.GetProtocol(), regExp)) return; if (CompileRegExp(m_mimeTypes, regExp) && !MatchesRegExp(item.GetMimeType(), regExp)) return; if (CompileRegExp(m_fileName, regExp) && !MatchesRegExp(item.GetPath(), regExp)) return; CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: matches rule: %s", m_name.c_str()); for (unsigned int i = 0; i < vecSubRules.size(); i++) vecSubRules[i]->GetPlayers(item, vecCores); PLAYERCOREID playerCoreId = GetPlayerCore(); if (playerCoreId != EPC_NONE) { CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: adding player: %s (%d) for rule: %s", m_playerName.c_str(), playerCoreId, m_name.c_str()); vecCores.push_back(GetPlayerCore()); } }
void CApplicationMessenger::MediaPlay(string filename) { CFileItem item; item.m_strPath = filename; item.m_bIsFolder = false; if (item.IsAudio()) item.SetMusicThumb(); else item.SetVideoThumb(); item.FillInDefaultIcon(); MediaPlay(item); }
void CPlayerCoreFactory::GetPlayers( const CFileItem& item, VECPLAYERCORES &vecCores) { CURL url(item.GetPath()); CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers(%s)", item.GetPath().c_str()); // Process rules for(unsigned int i = 0; i < s_vecCoreSelectionRules.size(); i++) s_vecCoreSelectionRules[i]->GetPlayers(item, vecCores); CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: matched %"PRIuS" rules with players", vecCores.size()); if( PAPlayer::HandlesType(url.GetFileType()) ) { // We no longer force PAPlayer as our default audio player (used to be true): bool bAdd = false; if (url.GetProtocol().Equals("mms")) { bAdd = false; } else if (item.IsType(".wma")) { // bAdd = true; // DVDPlayerCodec codec; // if (!codec.Init(item.GetPath(),2048)) // bAdd = false; // codec.DeInit(); } if (bAdd) { if( g_guiSettings.GetInt("audiooutput.mode") == AUDIO_ANALOG && !AUDIO_IS_BITSTREAM(g_guiSettings.GetInt("audiooutput2.mode")) ) { CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: adding PAPlayer (%d)", EPC_PAPLAYER); vecCores.push_back(EPC_PAPLAYER); } else if (url.GetFileType().Equals("ac3") || url.GetFileType().Equals("dts")) { CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: adding DVDPlayer (%d)", EPC_DVDPLAYER); vecCores.push_back(EPC_DVDPLAYER); } else { CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: adding PAPlayer (%d)", EPC_PAPLAYER); vecCores.push_back(EPC_PAPLAYER); } } } // Process defaults // Set video default player. Check whether it's video first (overrule audio check) // Also push these players in case it is NOT audio either if (item.IsVideo() || !item.IsAudio()) { PLAYERCOREID eVideoDefault = GetPlayerCore("videodefaultplayer"); if (eVideoDefault != EPC_NONE) { CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: adding videodefaultplayer (%d)", eVideoDefault); vecCores.push_back(eVideoDefault); } GetPlayers(vecCores, false, true); // Video-only players GetPlayers(vecCores, true, true); // Audio & video players } // Set audio default player // Pushback all audio players in case we don't know the type if (item.IsAudio()) { PLAYERCOREID eAudioDefault = GetPlayerCore("audiodefaultplayer"); if (eAudioDefault != EPC_NONE) { CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: adding audiodefaultplayer (%d)", eAudioDefault); vecCores.push_back(eAudioDefault); } GetPlayers(vecCores, true, false); // Audio-only players GetPlayers(vecCores, true, true); // Audio & video players } /* make our list unique, preserving first added players */ unique(vecCores); CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: added %"PRIuS" players", vecCores.size()); }
void CSaveFileState::DoWork(CFileItem& item, CBookmark& bookmark, bool updatePlayCount) { std::string progressTrackingFile = item.GetPath(); if (item.HasVideoInfoTag() && StringUtils::StartsWith(item.GetVideoInfoTag()->m_strFileNameAndPath, "removable://")) progressTrackingFile = item.GetVideoInfoTag()->m_strFileNameAndPath; // this variable contains removable:// suffixed by disc label+uniqueid or is empty if label not uniquely identified else if (item.HasProperty("original_listitem_url")) { // only use original_listitem_url for Python, UPnP and Bluray sources std::string original = item.GetProperty("original_listitem_url").asString(); if (URIUtils::IsPlugin(original) || URIUtils::IsUPnP(original) || URIUtils::IsBluray(item.GetPath())) progressTrackingFile = original; } if (!progressTrackingFile.empty()) { #ifdef HAS_UPNP // checks if UPnP server of this file is available and supports updating if (URIUtils::IsUPnP(progressTrackingFile) && UPNP::CUPnP::SaveFileState(item, bookmark, updatePlayCount)) { return; } #endif if (item.IsVideo()) { std::string redactPath = CURL::GetRedacted(progressTrackingFile); CLog::Log(LOGDEBUG, "%s - Saving file state for video item %s", __FUNCTION__, redactPath.c_str()); CVideoDatabase videodatabase; if (!videodatabase.Open()) { CLog::Log(LOGWARNING, "%s - Unable to open video database. Can not save file state!", __FUNCTION__); } else { if (URIUtils::IsPlugin(progressTrackingFile) && !(item.HasVideoInfoTag() && item.GetVideoInfoTag()->m_iDbId >= 0)) { // FileItem from plugin can lack information, make sure all needed fields are set CVideoInfoTag *tag = item.GetVideoInfoTag(); CStreamDetails streams = tag->m_streamDetails; if (videodatabase.LoadVideoInfo(progressTrackingFile, *tag)) { item.SetPath(progressTrackingFile); item.ClearProperty("original_listitem_url"); tag->m_streamDetails = streams; } } bool updateListing = false; // No resume & watched status for livetv if (!item.IsLiveTV()) { if (updatePlayCount) { // no watched for not yet finished pvr recordings if (!item.IsInProgressPVRRecording()) { CLog::Log(LOGDEBUG, "%s - Marking video item %s as watched", __FUNCTION__, redactPath.c_str()); // consider this item as played videodatabase.IncrementPlayCount(item); item.GetVideoInfoTag()->IncrementPlayCount(); item.SetOverlayImage(CGUIListItem::ICON_OVERLAY_UNWATCHED, true); updateListing = true; if (item.HasVideoInfoTag()) { CVariant data; data["id"] = item.GetVideoInfoTag()->m_iDbId; data["type"] = item.GetVideoInfoTag()->m_type; ANNOUNCEMENT::CAnnouncementManager::GetInstance().Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnUpdate", data); } } } else videodatabase.UpdateLastPlayed(item); if (!item.HasVideoInfoTag() || item.GetVideoInfoTag()->GetResumePoint().timeInSeconds != bookmark.timeInSeconds) { if (bookmark.timeInSeconds <= 0.0f) videodatabase.ClearBookMarksOfFile(progressTrackingFile, CBookmark::RESUME); else videodatabase.AddBookMarkToFile(progressTrackingFile, bookmark, CBookmark::RESUME); if (item.HasVideoInfoTag()) item.GetVideoInfoTag()->SetResumePoint(bookmark); // UPnP announce resume point changes to clients // however not if playcount is modified as that already announces if (item.HasVideoInfoTag() && !updatePlayCount) { CVariant data; data["id"] = item.GetVideoInfoTag()->m_iDbId; data["type"] = item.GetVideoInfoTag()->m_type; ANNOUNCEMENT::CAnnouncementManager::GetInstance().Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnUpdate", data); } updateListing = true; } } if (item.HasVideoInfoTag() && item.GetVideoInfoTag()->HasStreamDetails()) { CFileItem dbItem(item); // Check whether the item's db streamdetails need updating if (!videodatabase.GetStreamDetails(dbItem) || dbItem.GetVideoInfoTag()->m_streamDetails != item.GetVideoInfoTag()->m_streamDetails) { videodatabase.SetStreamDetailsForFile(item.GetVideoInfoTag()->m_streamDetails, progressTrackingFile); updateListing = true; } } // Could be part of an ISO stack. In this case the bookmark is saved onto the part. // In order to properly update the list, we need to refresh the stack's resume point CApplicationStackHelper& stackHelper = g_application.GetAppStackHelper(); if (stackHelper.HasRegisteredStack(item) && stackHelper.GetRegisteredStackTotalTimeMs(item) == 0) videodatabase.GetResumePoint(*(stackHelper.GetRegisteredStack(item)->GetVideoInfoTag())); videodatabase.Close(); if (updateListing) { CUtil::DeleteVideoDatabaseDirectoryCache(); CFileItemPtr msgItem(new CFileItem(item)); if (item.HasProperty("original_listitem_url")) msgItem->SetPath(item.GetProperty("original_listitem_url").asString()); CGUIMessage message(GUI_MSG_NOTIFY_ALL, CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow(), 0, GUI_MSG_UPDATE_ITEM, 0, msgItem); CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(message); } } } if (item.IsAudio()) { std::string redactPath = CURL::GetRedacted(progressTrackingFile); CLog::Log(LOGDEBUG, "%s - Saving file state for audio item %s", __FUNCTION__, redactPath.c_str()); CMusicDatabase musicdatabase; if (updatePlayCount) { if (!musicdatabase.Open()) { CLog::Log(LOGWARNING, "%s - Unable to open music database. Can not save file state!", __FUNCTION__); } else { // consider this item as played CLog::Log(LOGDEBUG, "%s - Marking audio item %s as listened", __FUNCTION__, redactPath.c_str()); musicdatabase.IncrementPlayCount(item); musicdatabase.Close(); // UPnP announce resume point changes to clients // however not if playcount is modified as that already announces if (item.IsMusicDb()) { CVariant data; data["id"] = item.GetMusicInfoTag()->GetDatabaseId(); data["type"] = item.GetMusicInfoTag()->GetType(); ANNOUNCEMENT::CAnnouncementManager::GetInstance().Announce(ANNOUNCEMENT::AudioLibrary, "xbmc", "OnUpdate", data); } } } if (item.IsAudioBook()) { musicdatabase.Open(); musicdatabase.SetResumeBookmarkForAudioBook(item, item.m_lStartOffset + CUtil::ConvertSecsToMilliSecs(bookmark.timeInSeconds)); musicdatabase.Close(); } } } }
void CPlayerCoreFactory::GetPlayers( const CFileItem& item, VECPLAYERCORES &vecCores) { CURL url(item.m_strPath); CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers(%s)", item.m_strPath.c_str()); // ugly hack for ReplayTV. our filesystem is broken against real ReplayTV's (not the psuedo DVArchive) // it breaks down for small requests. As we can't allow truncated reads for all emulated dll file functions // we are often forced to do small reads to fill up the full buffer size wich seems gives garbage back if (url.GetProtocol().Equals("rtv")) { vecCores.push_back(EPC_MPLAYER); // vecCores.push_back(EPC_DVDPLAYER); } if (url.GetProtocol().Equals("hdhomerun") || url.GetProtocol().Equals("myth") || url.GetProtocol().Equals("cmyth") || url.GetProtocol().Equals("rtmp")) { vecCores.push_back(EPC_DVDPLAYER); } if (url.GetProtocol().Equals("lastfm") || url.GetProtocol().Equals("shout")) { vecCores.push_back(EPC_PAPLAYER); } if (url.GetProtocol().Equals("mms")) { vecCores.push_back(EPC_DVDPLAYER); } // dvdplayer can play standard rtsp streams if (url.GetProtocol().Equals("rtsp") && !url.GetFileType().Equals("rm") && !url.GetFileType().Equals("ra")) { vecCores.push_back(EPC_DVDPLAYER); } // Special care in case it's an internet stream if (item.IsInternetStream()) { CStdString content = item.GetContentType(); CLog::Log(LOGDEBUG, "%s - Item is an internet stream, content-type=%s", __FUNCTION__, content.c_str()); if (content == "video/x-flv" || content == "video/flv") { vecCores.push_back(EPC_DVDPLAYER); } else if (content == "audio/aacp") { vecCores.push_back(EPC_DVDPLAYER); } else if (content == "application/sdp") { vecCores.push_back(EPC_DVDPLAYER); } else if (content == "application/octet-stream") { //unknown contenttype, send mp2 to pap if( url.GetFileType() == "mp2") vecCores.push_back(EPC_PAPLAYER); } } if (item.IsDVD() || item.IsDVDFile() || item.IsDVDImage()) { if ( g_advancedSettings.m_videoDefaultDVDPlayer == "externalplayer" ) { vecCores.push_back(EPC_EXTPLAYER); vecCores.push_back(EPC_DVDPLAYER); } else { vecCores.push_back(EPC_DVDPLAYER); vecCores.push_back(EPC_EXTPLAYER); } } // only dvdplayer can handle these normally if (url.GetFileType().Equals("sdp") || url.GetFileType().Equals("asf")) { vecCores.push_back(EPC_DVDPLAYER); } // Set video default player. Check whether it's video first (overrule audio check) // Also push these players in case it is NOT audio either if (item.IsVideo() || !item.IsAudio()) { if ( g_advancedSettings.m_videoDefaultPlayer == "externalplayer" ) { vecCores.push_back(EPC_EXTPLAYER); vecCores.push_back(EPC_DVDPLAYER); } else { vecCores.push_back(EPC_DVDPLAYER); vecCores.push_back(EPC_EXTPLAYER); } } if( PAPlayer::HandlesType(url.GetFileType()) ) { // We no longer force PAPlayer as our default audio player (used to be true): bool bAdd = false; if (url.GetProtocol().Equals("mms")) { bAdd = false; } else if (item.IsType(".wma")) { bAdd = true; DVDPlayerCodec codec; if (!codec.Init(item.m_strPath,2048)) bAdd = false; codec.DeInit(); } if (bAdd) { if( g_guiSettings.GetInt("audiooutput.mode") == AUDIO_ANALOG ) { vecCores.push_back(EPC_PAPLAYER); } else if ((url.GetFileType().Equals("ac3") && g_audioConfig.GetAC3Enabled()) || (url.GetFileType().Equals("dts") && g_audioConfig.GetDTSEnabled())) { vecCores.push_back(EPC_DVDPLAYER); } else { vecCores.push_back(EPC_PAPLAYER); } } } // Set audio default player // Pushback all audio players in case we don't know the type if( item.IsAudio()) { if ( g_advancedSettings.m_audioDefaultPlayer == "dvdplayer" ) { vecCores.push_back(EPC_DVDPLAYER); vecCores.push_back(EPC_PAPLAYER); vecCores.push_back(EPC_EXTPLAYER); } else if ( g_advancedSettings.m_audioDefaultPlayer == "externalplayer" ) { vecCores.push_back(EPC_EXTPLAYER); vecCores.push_back(EPC_PAPLAYER); vecCores.push_back(EPC_DVDPLAYER); } else { // default to paplayer vecCores.push_back(EPC_PAPLAYER); vecCores.push_back(EPC_DVDPLAYER); vecCores.push_back(EPC_EXTPLAYER); } } // Always pushback DVDplayer as it can do both audio & video // vecCores.push_back(EPC_DVDPLAYER); /* make our list unique, preserving first added players */ unique(vecCores); }
void CPlayerSelectionRule::GetPlayers(const CFileItem& item, std::vector<std::string>&validPlayers, std::vector<std::string>&players) { CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: considering rule: %s", m_name.c_str()); if (m_bStreamDetails && !item.HasVideoInfoTag()) return; if (m_tAudio >= 0 && (m_tAudio > 0) != item.IsAudio()) return; if (m_tVideo >= 0 && (m_tVideo > 0) != item.IsVideo()) return; if (m_tInternetStream >= 0 && (m_tInternetStream > 0) != item.IsInternetStream()) return; if (m_tRemote >= 0 && (m_tRemote > 0) != item.IsRemote()) return; if (m_tBD >= 0 && (m_tBD > 0) != (item.IsBDFile() && item.IsOnDVD())) return; if (m_tDVD >= 0 && (m_tDVD > 0) != item.IsDVD()) return; if (m_tDVDFile >= 0 && (m_tDVDFile > 0) != item.IsDVDFile()) return; if (m_tDVDImage >= 0 && (m_tDVDImage > 0) != item.IsDiscImage()) return; CRegExp regExp(false, CRegExp::autoUtf8); if (m_bStreamDetails) { if (!item.GetVideoInfoTag()->HasStreamDetails()) { CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: cannot check rule: %s, no StreamDetails", m_name.c_str()); return; } CStreamDetails streamDetails = item.GetVideoInfoTag()->m_streamDetails; if (CompileRegExp(m_audioCodec, regExp) && !MatchesRegExp(streamDetails.GetAudioCodec(), regExp)) return; std::stringstream itoa; itoa << streamDetails.GetAudioChannels(); std::string audioChannelsstr = itoa.str(); if (CompileRegExp(m_audioChannels, regExp) && !MatchesRegExp(audioChannelsstr, regExp)) return; if (CompileRegExp(m_videoCodec, regExp) && !MatchesRegExp(streamDetails.GetVideoCodec(), regExp)) return; if (CompileRegExp(m_videoResolution, regExp) && !MatchesRegExp(CStreamDetails::VideoDimsToResolutionDescription(streamDetails.GetVideoWidth(), streamDetails.GetVideoHeight()), regExp)) return; if (CompileRegExp(m_videoAspect, regExp) && !MatchesRegExp(CStreamDetails::VideoAspectToAspectDescription(streamDetails.GetVideoAspect()), regExp)) return; } CURL url(item.GetPath()); if (CompileRegExp(m_fileTypes, regExp) && !MatchesRegExp(url.GetFileType(), regExp)) return; if (CompileRegExp(m_protocols, regExp) && !MatchesRegExp(url.GetProtocol(), regExp)) return; if (CompileRegExp(m_mimeTypes, regExp) && !MatchesRegExp(item.GetMimeType(), regExp)) return; if (CompileRegExp(m_fileName, regExp) && !MatchesRegExp(item.GetPath(), regExp)) return; CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: matches rule: %s", m_name.c_str()); for (unsigned int i = 0; i < vecSubRules.size(); i++) vecSubRules[i]->GetPlayers(item, validPlayers, players); if (std::find(validPlayers.begin(), validPlayers.end(), m_playerName) != validPlayers.end()) { CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: adding player: %s for rule: %s", m_playerName.c_str(), m_name.c_str()); players.push_back(m_playerName); } }
void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CGUIWindowMusicBase::GetContextButtons(itemNumber, buttons); CGUIDialogMusicScan *musicScan = (CGUIDialogMusicScan *)m_gWindowManager.GetWindow(WINDOW_DIALOG_MUSIC_SCAN); CFileItem *item = (itemNumber >= 0 && itemNumber < m_vecItems->Size()) ? m_vecItems->Get(itemNumber) : NULL; if (item && (item->GetExtraInfo().Find("lastfm") < 0)) { // are we in the playlists location? bool inPlaylists = m_vecItems->m_strPath.Equals(CUtil::MusicPlaylistsLocation()) || m_vecItems->m_strPath.Equals("special://musicplaylists/"); CMusicDatabaseDirectory dir; SScraperInfo info; m_musicdatabase.GetScraperForPath(item->m_strPath,info); // enable music info button on an album or on a song. if (item->IsAudio() && !item->IsPlayList() && !item->IsSmartPlayList() && !item->IsLastFM() && !item->IsShoutCast()) { buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658); } else if (item->IsVideoDb()) { if (!item->m_bIsFolder) // music video buttons.Add(CONTEXT_BUTTON_INFO, 20393); if (item->m_strPath.Left(14).Equals("videodb://3/4/") && item->m_strPath.size() > 14 && item->m_bIsFolder) { long idArtist = m_musicdatabase.GetArtistByName(m_vecItems->Get(itemNumber)->GetLabel()); if (idArtist > - 1) buttons.Add(CONTEXT_BUTTON_INFO,21891); } } else if (!inPlaylists && (dir.HasAlbumInfo(item->m_strPath)|| dir.IsArtistDir(item->m_strPath) ) && !dir.IsAllItem(item->m_strPath) && !item->IsParentFolder() && !item->IsLastFM() && !item->IsShoutCast() && !item->m_strPath.Left(14).Equals("musicsearch://")) { if (dir.IsArtistDir(item->m_strPath)) buttons.Add(CONTEXT_BUTTON_INFO, 21891); else buttons.Add(CONTEXT_BUTTON_INFO, 13351); } // enable query all albums button only in album view if (dir.HasAlbumInfo(item->m_strPath) && !dir.IsAllItem(item->m_strPath) && item->m_bIsFolder && !item->IsVideoDb() && !item->IsParentFolder() && !item->IsLastFM() && !item->IsShoutCast() && !item->m_strPath.Left(14).Equals("musicsearch://")) { buttons.Add(CONTEXT_BUTTON_INFO_ALL, 20059); } // enable query all artist button only in album view if (dir.IsArtistDir(item->m_strPath) && !dir.IsAllItem(item->m_strPath) && item->m_bIsFolder && !item->IsVideoDb() && !info.strContent.IsEmpty()) { buttons.Add(CONTEXT_BUTTON_INFO_ALL, 21884); } // turn off set artist image if not at artist listing. if (dir.IsArtistDir(item->m_strPath) && !dir.IsAllItem(item->m_strPath) || (item->m_strPath.Left(14).Equals("videodb://3/4/") && item->m_strPath.size() > 14 && item->m_bIsFolder)) { buttons.Add(CONTEXT_BUTTON_SET_ARTIST_THUMB, 13359); } if (m_vecItems->m_strPath.Equals("plugin://music/")) buttons.Add(CONTEXT_BUTTON_SET_PLUGIN_THUMB, 1044); //Set default or clear default NODE_TYPE nodetype = dir.GetDirectoryType(item->m_strPath); if (!item->IsParentFolder() && !inPlaylists && (nodetype == NODE_TYPE_ROOT || nodetype == NODE_TYPE_OVERVIEW || nodetype == NODE_TYPE_TOP100)) { if (!item->m_strPath.Equals(g_settings.m_defaultMusicLibSource)) buttons.Add(CONTEXT_BUTTON_SET_DEFAULT, 13335); // set default if (strcmp(g_settings.m_defaultMusicLibSource, "")) buttons.Add(CONTEXT_BUTTON_CLEAR_DEFAULT, 13403); // clear default } NODE_TYPE childtype = dir.GetDirectoryChildType(item->m_strPath); if (childtype == NODE_TYPE_ALBUM || childtype == NODE_TYPE_ARTIST || nodetype == NODE_TYPE_GENRE || nodetype == NODE_TYPE_ALBUM) { // we allow the user to set content for // 1. general artist and album nodes // 2. specific per genre // 3. specific per artist // 4. specific per album buttons.Add(CONTEXT_BUTTON_SET_CONTENT,20195); } if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetArtist().size() > 0) { CVideoDatabase database; database.Open(); if (database.GetMusicVideoArtistByName(item->GetMusicInfoTag()->GetArtist()) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20400); } if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetArtist().size() > 0 && item->GetMusicInfoTag()->GetAlbum().size() > 0 && item->GetMusicInfoTag()->GetTitle().size() > 0) { CVideoDatabase database; database.Open(); if (database.GetMusicVideoByArtistAndAlbumAndTitle(item->GetMusicInfoTag()->GetArtist(),item->GetMusicInfoTag()->GetAlbum(),item->GetMusicInfoTag()->GetTitle()) > -1) buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20401); } if (item->HasVideoInfoTag() && !item->m_bIsFolder) { if (item->GetVideoInfoTag()->m_bWatched) buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched else buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched if (g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].canWriteDatabases() || g_passwordManager.bMasterUser) { buttons.Add(CONTEXT_BUTTON_RENAME, 16105); buttons.Add(CONTEXT_BUTTON_DELETE, 646); } } } // noncontextual buttons if (musicScan && musicScan->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning else if (musicScan) buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); CGUIWindowMusicBase::GetNonContextButtons(buttons); }
bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAddedToPlaylist, bool bRoot, bool bypassSettings /* = false */) { bool bPlaying(false); CFileItemList vecItems; char szSlash = '\\'; if (strDrive.Find("iso9660") != -1) szSlash = '/'; if ( !pDir->GetDirectory( strDrive, vecItems ) ) { return false; } bool bAllowVideo = true; bool bAllowPictures = true; bool bAllowMusic = true; if (!g_passwordManager.IsMasterLockUnlocked(false)) { bAllowVideo = !g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].videoLocked(); bAllowPictures = !g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].picturesLocked(); bAllowMusic = !g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].musicLocked(); } if( bRoot ) { // check root folders first, for normal structured dvd's for (int i = 0; i < vecItems.Size(); i++) { CFileItem* pItem = vecItems[i]; if (pItem->m_bIsFolder && pItem->m_strPath != "." && pItem->m_strPath != "..") { if (pItem->m_strPath.Find( "VIDEO_TS" ) != -1 && bAllowVideo && (bypassSettings || g_guiSettings.GetBool("autorun.dvd"))) { CUtil::PlayDVD(); bPlaying = true; return true; } else if (pItem->m_strPath.Find("MPEGAV") != -1 && bAllowVideo && (bypassSettings || g_guiSettings.GetBool("autorun.vcd"))) { CFileItemList items; CDirectory::GetDirectory(pItem->m_strPath, items, ".dat"); if (items.Size()) { items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC); g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Add(PLAYLIST_VIDEO, items); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Play(0); bPlaying = true; return true; } } else if (pItem->m_strPath.Find("MPEG2") != -1 && bAllowVideo && (bypassSettings || g_guiSettings.GetBool("autorun.vcd"))) { CFileItemList items; CDirectory::GetDirectory(pItem->m_strPath, items, ".mpg"); if (items.Size()) { items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC); g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Add(PLAYLIST_VIDEO, items); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Play(0); bPlaying = true; return true; } } else if (pItem->m_strPath.Find("PICTURES") != -1 && bAllowPictures && (bypassSettings || g_guiSettings.GetBool("autorun.pictures"))) { bPlaying = true; CStdString strExec; strExec.Format("XBMC.RecursiveSlideShow(%s)", pItem->m_strPath.c_str()); CUtil::ExecBuiltIn(strExec); return true; } } } } // check video first if (!nAddedToPlaylist && !bPlaying && (bypassSettings || g_guiSettings.GetBool("autorun.video"))) { // stack video files CFileItemList tempItems; tempItems.Append(vecItems); tempItems.Stack(); CFileItemList itemlist; for (int i = 0; i < tempItems.Size(); i++) { CFileItem *pItem = tempItems[i]; if (!pItem->m_bIsFolder && pItem->IsVideo()) { bPlaying = true; if (pItem->IsStack()) { // TODO: remove this once the app/player is capable of handling stacks immediately CStackDirectory dir; CFileItemList items; dir.GetDirectory(pItem->m_strPath, items); for (int i = 0; i < items.Size(); i++) { itemlist.Add(new CFileItem(*items[i])); } } else itemlist.Add(new CFileItem(*pItem)); } } if (itemlist.Size()) { if (!bAllowVideo) { if (!bypassSettings) return false; if (m_gWindowManager.GetActiveWindow() != WINDOW_VIDEO_FILES) if (!g_passwordManager.IsMasterLockUnlocked(true)) return false; } g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Add(PLAYLIST_VIDEO, itemlist); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Play(0); } } // then music if (!bPlaying && (bypassSettings || g_guiSettings.GetBool("autorun.music")) && bAllowMusic) { for (int i = 0; i < vecItems.Size(); i++) { CFileItem *pItem = vecItems[i]; if (!pItem->m_bIsFolder && pItem->IsAudio()) { nAddedToPlaylist++; g_playlistPlayer.Add(PLAYLIST_MUSIC, pItem); } } } // and finally pictures if (!nAddedToPlaylist && !bPlaying && (bypassSettings || g_guiSettings.GetBool("autorun.pictures")) && bAllowPictures) { for (int i = 0; i < vecItems.Size(); i++) { CFileItem *pItem = vecItems[i]; if (!pItem->m_bIsFolder && pItem->IsPicture()) { bPlaying = true; CStdString strExec; strExec.Format("XBMC.RecursiveSlideShow(%s)", strDrive.c_str()); CUtil::ExecBuiltIn(strExec); break; } } } // check subdirs if we are not playing yet if (!bPlaying) { for (int i = 0; i < vecItems.Size(); i++) { CFileItem* pItem = vecItems[i]; if (pItem->m_bIsFolder) { if (pItem->m_strPath != "." && pItem->m_strPath != ".." ) { if (RunDisc(pDir, pItem->m_strPath, nAddedToPlaylist, false, bypassSettings)) { bPlaying = true; break; } } } } } return bPlaying; }
void CPlayerCoreFactory::GetPlayers( const CFileItem& item, VECPLAYERCORES &vecCores) { CURL url(item.m_strPath); CLog::Log(LOGDEBUG,"CPlayerCoreFactor::GetPlayers(%s)",item.m_strPath.c_str()); // Plex media server streams. if (url.GetProtocol().Equals("plex", false)) vecCores.push_back(EPC_PMSPLAYER); // Play audio files with iTunes DRM using QuickTime if (url.GetFileType().Equals("m4p") || url.GetFileType().Equals("m4b")) { vecCores.push_back(EPC_QTPLAYER); CLog::Log(LOGDEBUG,"CPlayerCoreFactor::GetPlayers(%s) - matched M4P file",item.m_strPath.c_str()); } // ugly hack for ReplayTV. our filesystem is broken against real ReplayTV's (not the psuevdo DVArchive) // it breaks down for small requests. As we can't allow truncated reads for all emulated dll file functions // we are often forced to do small reads to fill up the full buffer size wich seems gives garbage back if (url.GetProtocol().Equals("rtv")) vecCores.push_back(EPC_MPLAYER); // vecCores.push_back(EPC_DVDPLAYER); if (url.GetProtocol().Equals("hdhomerun") || url.GetProtocol().Equals("myth") || url.GetProtocol().Equals("cmyth") || url.GetProtocol().Equals("rtmp")) vecCores.push_back(EPC_DVDPLAYER); if (url.GetProtocol().Equals("lastfm") || url.GetProtocol().Equals("shout")) { vecCores.push_back(EPC_PAPLAYER); } if (url.GetProtocol().Equals("mms")) { vecCores.push_back(EPC_DVDPLAYER); } // dvdplayer can play standard rtsp streams if (url.GetProtocol().Equals("rtsp") && !url.GetFileType().Equals("rm") && !url.GetFileType().Equals("ra")) vecCores.push_back(EPC_DVDPLAYER); // only dvdplayer can handle these normally if (url.GetFileType().Equals("sdp") || url.GetFileType().Equals("asf")) vecCores.push_back(EPC_DVDPLAYER); if ( item.IsInternetStream() ) { CStdString content = item.GetContentType(); if (content == "video/x-flv" || content == "video/flv") vecCores.push_back(EPC_DVDPLAYER); else if (content == "audio/aacp") vecCores.push_back(EPC_DVDPLAYER); else if (content == "application/sdp") vecCores.push_back(EPC_DVDPLAYER); else if (content == "application/octet-stream") { //unknown contenttype, send mp2 to pap if( url.GetFileType() == "mp2") vecCores.push_back(EPC_PAPLAYER); } } if (((item.IsDVD()) || item.IsDVDFile() || item.IsDVDImage())) { vecCores.push_back(EPC_DVDPLAYER); } if( PAPlayer::HandlesType(url.GetFileType()) ) { bool bAdd = true; if (url.GetProtocol().Equals("mms")) { bAdd = false; } else if (item.IsType(".wma")) { DVDPlayerCodec codec; if (!codec.Init(item.m_strPath,2048)) bAdd = false; codec.DeInit(); } if (bAdd) { if(!g_audioConfig.UseDigitalOutput()) { vecCores.push_back(EPC_PAPLAYER); } //else if( ( url.GetFileType().Equals("ac3") && g_audioConfig.GetAC3Enabled() ) // || ( url.GetFileType().Equals("dts") && g_audioConfig.GetDTSEnabled() ) ) //{ // vecCores.push_back(EPC_DVDPLAYER); //} //else { vecCores.push_back(EPC_PAPLAYER); } } } //Add all normal players last so you can force them, should you want to if ( item.IsAudio() ) vecCores.push_back(EPC_PAPLAYER); vecCores.push_back(EPC_DVDPLAYER); /* make our list unique, presevering first added players */ unique(vecCores); }
void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg) { switch (pMsg->dwMessage) { case TMSG_SHUTDOWN: { switch (g_guiSettings.GetInt("system.shutdownstate")) { case POWERSTATE_SHUTDOWN: Powerdown(); break; case POWERSTATE_SUSPEND: Suspend(); break; case POWERSTATE_HIBERNATE: Hibernate(); break; case POWERSTATE_QUIT: Quit(); break; case POWERSTATE_MINIMIZE: Minimize(); break; } } break; case TMSG_POWERDOWN: { g_application.Stop(); Sleep(200); g_Windowing.DestroyWindow(); g_powerManager.Powerdown(); #ifdef HAS_EMBEDDED CHalServicesFactory::GetInstance().Shutdown(); #endif exit(64); } break; case TMSG_QUIT: { g_application.Stop(); Sleep(200); g_Windowing.DestroyWindow(); exit(0); } break; case TMSG_HIBERNATE: { g_powerManager.Hibernate(); } break; case TMSG_SUSPEND: { g_powerManager.Suspend(); MediaStop(); } break; case TMSG_LOGOUT: { CLog::Log(LOGDEBUG,"CApplicationMessenger::ProcessMessage - Enter TMSG_LOGOUT case. Going to call BoxeeLoginManager::Logout() (logout)"); g_application.GetBoxeeLoginManager().Logout(); } break; case TMSG_RESTART: { g_application.Stop(); Sleep(200); g_Windowing.DestroyWindow(); g_powerManager.Reboot(); exit(66); } break; case TMSG_RESET: { g_application.Stop(); Sleep(200); g_Windowing.DestroyWindow(); g_powerManager.Reboot(); exit(66); } break; case TMSG_RESTARTAPP: { #ifdef _WIN32 g_application.Stop(); Sleep(200); #endif exit(65); // TODO //char szXBEFileName[1024]; //CIoSupport::GetXbePath(szXBEFileName); //CUtil::RunXBE(szXBEFileName); } break; case TMSG_MEDIA_PLAY: { // first check if we were called from the PlayFile() function if (pMsg->lpVoid && pMsg->dwParam2 == 0) { CFileItem *item = (CFileItem *)pMsg->lpVoid; g_application.PlayFile(*item, pMsg->dwParam1 != 0); delete item; return; } // restore to previous window if needed if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW || g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO || g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION) g_windowManager.PreviousWindow(); g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); //g_application.StopPlaying(); // play file CFileItem *item; if (pMsg->lpVoid && pMsg->dwParam2 == 1) { item = (CFileItem *)pMsg->lpVoid; } else { item = new CFileItem(pMsg->strParam, false); } if (item->IsAudio()) item->SetMusicThumb(); else item->SetVideoThumb(); item->FillInDefaultIcon(); g_application.PlayMedia(*item, item->IsAudio() ? PLAYLIST_MUSIC : PLAYLIST_VIDEO); //Note: this will play playlists always in the temp music playlist (default 2nd parameter), maybe needs some tweaking. delete item; } break; case TMSG_MEDIA_RESTART: g_application.Restart(true); break; case TMSG_MEDIA_QUEUE_NEXT_ITEM: { CFileItem *item = (CFileItem *)pMsg->lpVoid; //g_application.QueueNextMedia(*item); delete item; return; } case TMSG_MEDIA_UPDATE_ITEM: { CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_ITEM, 0); msg.SetItem(CFileItemPtr((CFileItem*)pMsg->lpVoid)); g_windowManager.SendMessage(msg); return; } case TMSG_PICTURE_SHOW: { CGUIWindowSlideShow *pSlideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW); if (!pSlideShow) return ; // stop playing file if (g_application.IsPlayingVideo()) g_application.StopPlaying(); if (g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO) g_windowManager.PreviousWindow(); g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); g_graphicsContext.Lock(); pSlideShow->Reset(); if (g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW) g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); if (CUtil::IsZIP(pMsg->strParam) || CUtil::IsRAR(pMsg->strParam)) // actually a cbz/cbr { CFileItemList items; CStdString strPath; if (CUtil::IsZIP(pMsg->strParam)) CUtil::CreateArchivePath(strPath, "zip", pMsg->strParam.c_str(), ""); else CUtil::CreateArchivePath(strPath, "rar", pMsg->strParam.c_str(), ""); CUtil::GetRecursiveListing(strPath, items, g_stSettings.m_pictureExtensions); if (items.Size() > 0) { for (int i=0;i<items.Size();++i) { pSlideShow->Add(items[i].get()); } pSlideShow->Select(items[0]->m_strPath); } } else { CFileItem item(pMsg->strParam, false); pSlideShow->Add(&item); pSlideShow->Select(pMsg->strParam); } g_graphicsContext.Unlock(); } break; case TMSG_SLIDESHOW_SCREENSAVER: case TMSG_PICTURE_SLIDESHOW: { CGUIWindowSlideShow *pSlideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW); if (!pSlideShow) return ; g_graphicsContext.Lock(); pSlideShow->Reset(); CFileItemList items; CStdString strPath = pMsg->strParam; if (pMsg->dwMessage == TMSG_SLIDESHOW_SCREENSAVER && g_guiSettings.GetString("screensaver.mode").Equals("Fanart Slideshow")) { CUtil::GetRecursiveListing(g_settings.GetVideoFanartFolder(), items, ".tbn"); CUtil::GetRecursiveListing(g_settings.GetMusicFanartFolder(), items, ".tbn"); } else CUtil::GetRecursiveListing(strPath, items, g_stSettings.m_pictureExtensions); if (items.Size() > 0) { for (int i=0;i<items.Size();++i) pSlideShow->Add(items[i].get()); pSlideShow->StartSlideShow(pMsg->dwMessage == TMSG_SLIDESHOW_SCREENSAVER); //Start the slideshow! } if (pMsg->dwMessage == TMSG_SLIDESHOW_SCREENSAVER) pSlideShow->Shuffle(); if (g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW) g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); g_graphicsContext.Unlock(); } break; case TMSG_MEDIA_STOP: { // This check ensures we actually need to switch to the previous window, set by FlashVideoPlayer if (pMsg->dwParam1 != 1) { // restore to previous window if needed if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW || g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO || g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION) g_windowManager.PreviousWindow(); } g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); // stop playing file if (g_application.IsPlaying()) g_application.StopPlaying(); } break; case TMSG_MEDIA_PAUSE: if (g_application.m_pPlayer) { g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); g_application.m_pPlayer->Pause(); } break; case TMSG_SWITCHTOFULLSCREEN: if( g_windowManager.GetActiveWindow() != WINDOW_FULLSCREEN_VIDEO && g_windowManager.GetActiveWindow() != WINDOW_KARAOKELYRICS) g_application.SwitchToFullScreen(); break; case TMSG_MINIMIZE: g_application.Minimize(); break; case TMSG_EXECUTE_OS: #if defined( _LINUX) && !defined(__APPLE__) CUtil::RunCommandLine(pMsg->strParam.c_str(), (pMsg->dwParam1 == 1)); #elif defined(_WIN32) CWIN32Util::XBMCShellExecute(pMsg->strParam.c_str(), (pMsg->dwParam1 == 1)); #endif break; case TMSG_HTTPAPI: { #ifdef HAS_WEB_SERVER if (!m_pXbmcHttp) { CSectionLoader::Load("LIBHTTP"); m_pXbmcHttp = new CXbmcHttp(); } switch (m_pXbmcHttp->xbmcCommand(pMsg->strParam)) { case 1: g_application.getApplicationMessenger().Restart(); break; case 2: g_application.getApplicationMessenger().Shutdown(); break; case 3: g_application.getApplicationMessenger().RebootToDashBoard(); break; case 4: g_application.getApplicationMessenger().Reset(); break; case 5: g_application.getApplicationMessenger().RestartApp(); break; } #endif } break; case TMSG_EXECUTE_SCRIPT: #ifdef HAS_PYTHON g_pythonParser.evalFile(pMsg->strParam.c_str()); #endif break; case TMSG_EXECUTE_BUILT_IN: CBuiltins::Execute(pMsg->strParam.c_str()); break; case TMSG_PLAYLISTPLAYER_PLAY: if (pMsg->dwParam1 != (DWORD) -1) g_playlistPlayer.Play(pMsg->dwParam1); else g_playlistPlayer.Play(); break; case TMSG_PLAYLISTPLAYER_NEXT: g_playlistPlayer.PlayNext(); break; case TMSG_PLAYLISTPLAYER_PREV: g_playlistPlayer.PlayPrevious(); break; // Window messages below here... case TMSG_DIALOG_DOMODAL: //doModel of window { CGUIDialog* pDialog = (CGUIDialog*)g_windowManager.GetWindow(pMsg->dwParam1); if (!pDialog) return ; pDialog->DoModal(); } break; case TMSG_DIALOG_PROGRESS_SHOWMODAL: { CGUIDialogProgress* pDialog = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); if (!pDialog) return ; pDialog->StartModal(); } break; case TMSG_WRITE_SCRIPT_OUTPUT: { //send message to window 2004 (CGUIWindowScriptsInfo) CGUIMessage msg(GUI_MSG_USER, 0, 0); msg.SetLabel(pMsg->strParam); CGUIWindow* pWindowScripts = g_windowManager.GetWindow(WINDOW_SCRIPTS_INFO); if (pWindowScripts) pWindowScripts->OnMessage(msg); } break; case TMSG_NETWORKMESSAGE: { g_application.getNetwork().NetworkMessage((CNetwork::EMESSAGE)pMsg->dwParam1, (int)pMsg->dwParam2); } break; case TMSG_GUI_DO_MODAL: { CGUIDialog *pDialog = (CGUIDialog *)pMsg->lpVoid; if (pDialog) pDialog->DoModal_Internal((int)pMsg->dwParam1, pMsg->strParam); } break; case TMSG_GUI_SHOW: { CGUIDialog *pDialog = (CGUIDialog *)pMsg->lpVoid; if (pDialog) pDialog->Show_Internal(); } break; case TMSG_GUI_ACTION: { if (pMsg->lpVoid) { if (pMsg->dwParam1 == WINDOW_INVALID) g_application.OnAction(*(CAction *)pMsg->lpVoid); else { CGUIWindow *pWindow = g_windowManager.GetWindow(pMsg->dwParam1); if (pWindow) pWindow->OnAction(*(CAction *)pMsg->lpVoid); else CLog::Log(LOGWARNING, "Failed to get window with ID %i to send an action to", pMsg->dwParam1); } } } break; case TMSG_GUI_INFOLABEL: { if (pMsg->lpVoid) { vector<CStdString> *infoLabels = (vector<CStdString> *)pMsg->lpVoid; for (unsigned int i = 0; i < pMsg->params.size(); i++) infoLabels->push_back(g_infoManager.GetLabel(g_infoManager.TranslateString(pMsg->params[i]))); } } break; case TMSG_GUI_INFOBOOL: { if (pMsg->lpVoid) { vector<bool> *infoLabels = (vector<bool> *)pMsg->lpVoid; for (unsigned int i = 0; i < pMsg->params.size(); i++) infoLabels->push_back(g_infoManager.GetBool(g_infoManager.TranslateString(pMsg->params[i]))); } } break; case TMSG_LOAD_STRINGS: g_localizeStrings.Load(pMsg->strParam, pMsg->strParam2); break; case TMSG_GUI_ACTIVATE_WINDOW: { g_windowManager.ActivateWindow(pMsg->dwParam1, pMsg->params, pMsg->dwParam2 > 0); } break; case TMSG_GUI_WIN_MANAGER_PROCESS: g_windowManager.Process_Internal(0 != pMsg->dwParam1); break; case TMSG_GUI_WIN_MANAGER_RENDER: g_windowManager.Render_Internal(); break; #ifdef HAS_DVD_DRIVE case TMSG_OPTICAL_MOUNT: { /* CMediaSource share; share.strStatus = g_mediaManager.GetDiskLabel(share.strPath); share.strPath = pMsg->strParam; if(g_mediaManager.IsAudio(share.strPath)) share.strStatus = "Audio-CD"; else if(share.strStatus == "") share.strStatus = g_localizeStrings.Get(446); share.strName = share.strPath; share.m_ignore = true; share.m_iDriveType = CMediaSource::SOURCE_TYPE_DVD; g_mediaManager.AddAutoSource(share, pMsg->dwParam1 != 0); */ if (pMsg->dwParam1 != 0) { MEDIA_DETECT::CAutorun::ExecuteAutorun(); } } break; case TMSG_OPTICAL_UNMOUNT: { /* CMediaSource share; share.strPath = pMsg->strParam; share.strName = share.strPath; g_mediaManager.RemoveAutoSource(share); */ g_mediaManager.RemoveCdInfo(g_mediaManager.TranslateDevicePath(pMsg->strParam, true)); } break; #endif //Boxee case TMSG_INIT_WINDOW: { CGUIWindow *pWindow = (CGUIWindow *)pMsg->lpVoid; if (pWindow) pMsg->dwParam1 = pWindow->Initialize(); } break; case TMSG_LOAD_LANG_INFO: { pMsg->dwParam1 = g_langInfo.Load(pMsg->strParam); break; } break; case TMSG_DELETE_BG_LOADER: { CBackgroundInfoLoader *pLoader = (CBackgroundInfoLoader *)pMsg->lpVoid; if (pLoader) delete pLoader; } break; case TMSG_GENERAL_MESSAGE: { CGUIMessage *msg = (CGUIMessage *)pMsg->lpVoid; if (msg) { CGUIWindow* pWindow = g_windowManager.GetWindow(pMsg->dwParam1); if (pWindow) pWindow->OnMessage(*msg); if (!pMsg->hWaitEvent) // no one waits for this message to return. delete msg; } } break; case TMSG_SET_CONTROL_LABEL: { CGUIWindow* pWindow = g_windowManager.GetWindow(pMsg->dwParam1); if (pWindow) { CGUIControl *control = (CGUIControl *)pWindow->GetControl(pMsg->dwParam2); if (control) { CGUIMessage msg(GUI_MSG_LABEL_SET, pMsg->dwParam1, pMsg->dwParam2); msg.SetLabel(pMsg->strParam); control->OnMessage(msg); } } } break; case TMSG_CLOSE_DIALOG: { CGUIDialog *dlg = (CGUIDialog *)pMsg->lpVoid; bool bForce = (bool)pMsg->dwParam1; if (dlg) dlg->Close(bForce); } break; case TMSG_PREVIOUS_WINDOW: { g_windowManager.PreviousWindow(); } break; case TMSG_TOGGLEFULLSCREEN: { CAction action; action.id = ACTION_TOGGLE_FULLSCREEN; g_application.OnAction(action); } break; case TMSG_FREE_WINDOW_RESOURCES: { CGUIWindow *win = (CGUIWindow *)pMsg->lpVoid; if (win) win->FreeResources(); } break; case TMSG_FREE_TEXTURE: { CGUITextureBase *t = (CGUITextureBase *)pMsg->lpVoid; if (t) t->FreeResources(!!pMsg->dwParam1); } break; case TMSG_VIDEO_RENDERER_PREINIT: { pMsg->dwParam1 = g_renderManager.PreInit(); break; } case TMSG_VIDEO_RENDERER_UNINIT: { g_renderManager.UnInit(); break; } case TMSG_CLOSE_SLIDESHOWPIC: { CSlideShowPic *t = (CSlideShowPic *)pMsg->lpVoid; if (t) t->Close(); break; } case TMSG_SHOW_POST_PLAY_DIALOG: { CFileItem *item = (CFileItem *)pMsg->lpVoid; CGUIDialogBoxeePostPlay *dlg = (CGUIDialogBoxeePostPlay *)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_POST_PLAY); dlg->SetItem(item); dlg->DoModal(); dlg->Reset(); delete item; break; } case TMSG_SHOW_BOXEE_DEVICE_PAIR_DIALOG: { CBoxeeDeviceItem* deviceItem = (CBoxeeDeviceItem*)pMsg->lpVoid; CGUIDialogBoxeePair* dlg = (CGUIDialogBoxeePair*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_PAIR); dlg->SetDeviceItem(deviceItem); dlg->DoModal(); dlg->Reset(); delete deviceItem; } break; case TMSG_SEND_KEY: { CKey key(pMsg->dwParam1); g_application.OnKey(key); } break; case TMSG_SEND_MOVE: { CPoint p = g_Mouse.GetLocation(); XBMC_Event newEvent; newEvent.type = XBMC_MOUSEMOTION; RESOLUTION iRes = g_graphicsContext.GetVideoResolution(); int m_screenX1 = g_settings.m_ResInfo[iRes].Overscan.left; int m_screenY1 = g_settings.m_ResInfo[iRes].Overscan.top; int m_screenX2 = g_settings.m_ResInfo[iRes].Overscan.right; int m_screenY2 = g_settings.m_ResInfo[iRes].Overscan.bottom; newEvent.motion.x = std::max(m_screenX1, std::min(m_screenX2 - 10, (int)(p.x + (int)pMsg->dwParam1))); newEvent.motion.y = std::max(m_screenY1, std::min(m_screenY2 - 10, (int)(p.y + (int)pMsg->dwParam2))); g_Mouse.HandleEvent(newEvent); } break; case TMSG_SHOW_PLAY_ERROR: { CGUIDialogOK2::ShowAndGetInput(g_localizeStrings.Get(257), pMsg->strParam); break; } case TMSG_EXECUTE_ON_MAIN_THREAD: { IGUIThreadTask *t = (IGUIThreadTask *)(pMsg->lpVoid); if (t) { t->DoWork(); if (pMsg->dwParam1 == 1) delete t; } break; } case TMSG_DELETE_PLAYER: { IPlayer *player = (IPlayer *)pMsg->lpVoid; printf("deleting player %p\n", player); if (player) delete player; } break; case TMSG_APP_HANDLE: { std::vector<CStdString> vecParams = pMsg->params; CStdString strContext = vecParams[0]; CStdString strHandler = vecParams[1]; CStdString strParam = vecParams[2]; if(g_application.OnAppMessage(strHandler, strParam) == true) { break; } CLog::Log(LOGDEBUG, "TMSG_APP_HANDLE received for application %s, handler = %s, param = %s (apphandle)", strContext.c_str(), strHandler.c_str(), strParam.c_str()); CStdString targetPath = _P("special://home/apps/"); targetPath += strContext; CStdString partnerId = CAppManager::GetInstance().GetDescriptor(strContext).GetPartnerId(); CStdString globalHandler = CAppManager::GetInstance().GetDescriptor(strContext).GetGlobalHandler(); char* argv[2]; argv[0] = new char[strHandler.size() + 1]; strncpy(argv[0], strHandler.c_str(), strHandler.size()); argv[1] = new char[strParam.size() + 1]; strncpy(argv[1], strParam.c_str(), strParam.size()); std::vector<CStdString> params; params.push_back(strHandler); params.push_back(strParam); #ifdef HAS_PYTHON g_pythonParser.evalStringInContext(globalHandler, targetPath, strContext, partnerId, params); #endif delete argv[0]; delete argv[1]; } break; case TMSG_GUI_INVOKE_FROM_BROWSER: { IPlayer* player = static_cast<IPlayer*> (pMsg->lpVoid); player->ProcessExternalMessage(pMsg); } break; //end Boxee } }