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 } }
void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg) { switch (pMsg->dwMessage) { case TMSG_SHUTDOWN: { switch (CSettings::Get().GetInt("powermanagement.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; case TMSG_RENDERER_FLUSH: g_renderManager.Flush(); break; } } break; case TMSG_POWERDOWN: { g_application.Stop(EXITCODE_POWERDOWN); g_powerManager.Powerdown(); } break; case TMSG_QUIT: { g_application.Stop(EXITCODE_QUIT); } break; case TMSG_HIBERNATE: { g_PVRManager.SetWakeupCommand(); g_powerManager.Hibernate(); } break; case TMSG_SUSPEND: { g_PVRManager.SetWakeupCommand(); g_powerManager.Suspend(); } break; case TMSG_RESTART: case TMSG_RESET: { g_application.Stop(EXITCODE_REBOOT); g_powerManager.Reboot(); } break; case TMSG_RESTARTAPP: { #if defined(TARGET_WINDOWS) || defined(TARGET_LINUX) g_application.Stop(EXITCODE_RESTARTAPP); #endif } break; case TMSG_INHIBITIDLESHUTDOWN: { g_application.InhibitIdleShutdown(pMsg->param1 != 0); } break; case TMSG_ACTIVATESCREENSAVER: { g_application.ActivateScreenSaver(); } break; case TMSG_MEDIA_PLAY: { // first check if we were called from the PlayFile() function if (pMsg->lpVoid && pMsg->param2 == 0) { CFileItem *item = (CFileItem *)pMsg->lpVoid; g_application.PlayFile(*item, pMsg->param1 != 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 if(pMsg->lpVoid) { CFileItemList *list = (CFileItemList *)pMsg->lpVoid; if (list->Size() > 0) { int playlist = PLAYLIST_MUSIC; for (int i = 0; i < list->Size(); i++) { if ((*list)[i]->IsVideo()) { playlist = PLAYLIST_VIDEO; break; } } g_playlistPlayer.ClearPlaylist(playlist); g_playlistPlayer.SetCurrentPlaylist(playlist); //For single item lists try PlayMedia. This covers some more cases where a playlist is not appropriate //It will fall through to PlayFile if (list->Size() == 1 && !(*list)[0]->IsPlayList()) g_application.PlayMedia(*((*list)[0]), playlist); else { // Handle "shuffled" option if present if (list->HasProperty("shuffled") && list->GetProperty("shuffled").isBoolean()) g_playlistPlayer.SetShuffle(playlist, list->GetProperty("shuffled").asBoolean(), false); // Handle "repeat" option if present if (list->HasProperty("repeat") && list->GetProperty("repeat").isInteger()) g_playlistPlayer.SetRepeat(playlist, (PLAYLIST::REPEAT_STATE)list->GetProperty("repeat").asInteger(), false); g_playlistPlayer.Add(playlist, (*list)); g_playlistPlayer.Play(pMsg->param1); } } delete list; } else if (pMsg->param1 == PLAYLIST_MUSIC || pMsg->param1 == PLAYLIST_VIDEO) { if (g_playlistPlayer.GetCurrentPlaylist() != pMsg->param1) g_playlistPlayer.SetCurrentPlaylist(pMsg->param1); PlayListPlayerPlay(pMsg->param2); } } break; case TMSG_MEDIA_RESTART: g_application.Restart(true); break; case TMSG_PICTURE_SHOW: { CGUIWindowSlideShow *pSlideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW); if (!pSlideShow) return ; // stop playing file if (g_application.m_pPlayer->IsPlayingVideo()) g_application.StopPlaying(); if (g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO) g_windowManager.PreviousWindow(); g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); g_graphicsContext.Lock(); if (g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW) g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); if (URIUtils::IsZIP(pMsg->strParam) || URIUtils::IsRAR(pMsg->strParam)) // actually a cbz/cbr { CFileItemList items; CURL pathToUrl; if (URIUtils::IsZIP(pMsg->strParam)) pathToUrl = URIUtils::CreateArchivePath("zip", CURL(pMsg->strParam), ""); else pathToUrl = URIUtils::CreateArchivePath("rar", CURL(pMsg->strParam), ""); CUtil::GetRecursiveListing(pathToUrl.Get(), items, g_advancedSettings.m_pictureExtensions, XFILE::DIR_FLAG_NO_FILE_DIRS); if (items.Size() > 0) { pSlideShow->Reset(); for (int i=0;i<items.Size();++i) { pSlideShow->Add(items[i].get()); } pSlideShow->Select(items[0]->GetPath()); } } else { CFileItem item(pMsg->strParam, false); pSlideShow->Reset(); pSlideShow->Add(&item); pSlideShow->Select(pMsg->strParam); } g_graphicsContext.Unlock(); } break; case TMSG_PICTURE_SLIDESHOW: { CGUIWindowSlideShow *pSlideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW); if (!pSlideShow) return ; if (g_application.m_pPlayer->IsPlayingVideo()) g_application.StopPlaying(); g_graphicsContext.Lock(); pSlideShow->Reset(); CFileItemList items; std::string strPath = pMsg->strParam; std::string extensions = g_advancedSettings.m_pictureExtensions; if (pMsg->param1) extensions += "|.tbn"; CUtil::GetRecursiveListing(strPath, items, extensions); if (items.Size() > 0) { for (int i=0;i<items.Size();++i) pSlideShow->Add(items[i].get()); pSlideShow->StartSlideShow(); //Start the slideshow! } if (g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW) { if(items.Size() == 0) { CSettings::Get().SetString("screensaver.mode", "screensaver.xbmc.builtin.dim"); g_application.ActivateScreenSaver(); } else g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); } g_graphicsContext.Unlock(); } break; case TMSG_SETLANGUAGE: g_application.SetLanguage(pMsg->strParam); break; case TMSG_MEDIA_STOP: { // restore to previous window if needed bool stopSlideshow = true; bool stopVideo = true; bool stopMusic = true; if (pMsg->param1 >= PLAYLIST_MUSIC && pMsg->param1 <= PLAYLIST_PICTURE) { stopSlideshow = (pMsg->param1 == PLAYLIST_PICTURE); stopVideo = (pMsg->param1 == PLAYLIST_VIDEO); stopMusic = (pMsg->param1 == PLAYLIST_MUSIC); } if ((stopSlideshow && g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) || (stopVideo && g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO) || (stopMusic && g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION)) g_windowManager.PreviousWindow(); g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); // stop playing file if (g_application.m_pPlayer->IsPlaying()) g_application.StopPlaying(); } break; case TMSG_MEDIA_PAUSE: if (g_application.m_pPlayer->HasPlayer()) { g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); g_application.m_pPlayer->Pause(); } break; case TMSG_MEDIA_UNPAUSE: if (g_application.m_pPlayer->IsPausedPlayback()) { g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); g_application.m_pPlayer->Pause(); } break; case TMSG_MEDIA_PAUSE_IF_PLAYING: if (g_application.m_pPlayer->IsPlaying() && !g_application.m_pPlayer->IsPaused()) { g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); g_application.m_pPlayer->Pause(); } break; case TMSG_SWITCHTOFULLSCREEN: if(g_windowManager.GetActiveWindow() != WINDOW_FULLSCREEN_VIDEO) g_application.SwitchToFullScreen(true); break; case TMSG_SETVIDEORESOLUTION: { RESOLUTION res = (RESOLUTION)pMsg->param1; bool forceUpdate = pMsg->param2 == 1 ? true : false; g_graphicsContext.SetVideoResolution(res, forceUpdate); } break; case TMSG_VIDEORESIZE: { XBMC_Event newEvent; memset(&newEvent, 0, sizeof(newEvent)); newEvent.type = XBMC_VIDEORESIZE; newEvent.resize.w = pMsg->param1; newEvent.resize.h = pMsg->param2; g_application.OnEvent(newEvent); g_windowManager.MarkDirty(); } break; case TMSG_TOGGLEFULLSCREEN: g_graphicsContext.Lock(); g_graphicsContext.ToggleFullScreenRoot(); g_graphicsContext.Unlock(); break; case TMSG_MINIMIZE: g_application.Minimize(); break; case TMSG_EXECUTE_OS: /* Suspend AE temporarily so exclusive or hog-mode sinks */ /* don't block external player's access to audio device */ if (!CAEFactory::Suspend()) { CLog::Log(LOGNOTICE, "%s: Failed to suspend AudioEngine before launching external program",__FUNCTION__); } #if defined( TARGET_POSIX) && !defined(TARGET_DARWIN) CUtil::RunCommandLine(pMsg->strParam.c_str(), (pMsg->param1 == 1)); #elif defined(TARGET_WINDOWS) CWIN32Util::XBMCShellExecute(pMsg->strParam.c_str(), (pMsg->param1 == 1)); #endif /* Resume AE processing of XBMC native audio */ if (!CAEFactory::Resume()) { CLog::Log(LOGFATAL, "%s: Failed to restart AudioEngine after return from external player",__FUNCTION__); } break; case TMSG_EXECUTE_SCRIPT: CScriptInvocationManager::Get().ExecuteAsync(pMsg->strParam); break; case TMSG_EXECUTE_BUILT_IN: CBuiltins::Execute(pMsg->strParam.c_str()); break; case TMSG_PLAYLISTPLAYER_PLAY: if (pMsg->param1 != -1) g_playlistPlayer.Play(pMsg->param1); else g_playlistPlayer.Play(); break; case TMSG_PLAYLISTPLAYER_PLAY_SONG_ID: if (pMsg->param1 != -1) { bool *result = (bool*)pMsg->lpVoid; *result = g_playlistPlayer.PlaySongId(pMsg->param1); } else g_playlistPlayer.Play(); break; case TMSG_PLAYLISTPLAYER_NEXT: g_playlistPlayer.PlayNext(); break; case TMSG_PLAYLISTPLAYER_PREV: g_playlistPlayer.PlayPrevious(); break; case TMSG_PLAYLISTPLAYER_ADD: if(pMsg->lpVoid) { CFileItemList *list = (CFileItemList *)pMsg->lpVoid; g_playlistPlayer.Add(pMsg->param1, (*list)); delete list; } break; case TMSG_PLAYLISTPLAYER_INSERT: if (pMsg->lpVoid) { CFileItemList *list = (CFileItemList *)pMsg->lpVoid; g_playlistPlayer.Insert(pMsg->param1, (*list), pMsg->param2); delete list; } break; case TMSG_PLAYLISTPLAYER_REMOVE: if (pMsg->param1 != -1) g_playlistPlayer.Remove(pMsg->param1,pMsg->param2); break; case TMSG_PLAYLISTPLAYER_CLEAR: g_playlistPlayer.ClearPlaylist(pMsg->param1); break; case TMSG_PLAYLISTPLAYER_SHUFFLE: g_playlistPlayer.SetShuffle(pMsg->param1, pMsg->param2 > 0); break; case TMSG_PLAYLISTPLAYER_REPEAT: g_playlistPlayer.SetRepeat(pMsg->param1, (PLAYLIST::REPEAT_STATE)pMsg->param2); break; case TMSG_PLAYLISTPLAYER_GET_ITEMS: if (pMsg->lpVoid) { PLAYLIST::CPlayList playlist = g_playlistPlayer.GetPlaylist(pMsg->param1); CFileItemList *list = (CFileItemList *)pMsg->lpVoid; for (int i = 0; i < playlist.size(); i++) list->Add(CFileItemPtr(new CFileItem(*playlist[i]))); } break; case TMSG_PLAYLISTPLAYER_SWAP: if (pMsg->lpVoid) { vector<int> *indexes = (vector<int> *)pMsg->lpVoid; if (indexes->size() == 2) g_playlistPlayer.Swap(pMsg->param1, indexes->at(0), indexes->at(1)); delete indexes; } break; // Window messages below here... case TMSG_DIALOG_DOMODAL: //doModel of window { CGUIDialog* pDialog = (CGUIDialog*)g_windowManager.GetWindow(pMsg->param1); if (!pDialog) return ; pDialog->DoModal(); } break; case TMSG_NETWORKMESSAGE: { g_application.getNetwork().NetworkMessage((CNetwork::EMESSAGE)pMsg->param1, pMsg->param2); } break; case TMSG_GUI_DO_MODAL: { CGUIDialog *pDialog = (CGUIDialog *)pMsg->lpVoid; if (pDialog) pDialog->DoModal(pMsg->param1, pMsg->strParam); } break; case TMSG_GUI_SHOW: { CGUIDialog *pDialog = (CGUIDialog *)pMsg->lpVoid; if (pDialog) pDialog->Show(); } break; case TMSG_GUI_WINDOW_CLOSE: { CGUIWindow *window = (CGUIWindow *)pMsg->lpVoid; if (window) window->Close(pMsg->param2 & 0x1 ? true : false, pMsg->param1, pMsg->param2 & 0x2 ? true : false); } break; case TMSG_GUI_ACTIVATE_WINDOW: { g_windowManager.ActivateWindow(pMsg->param1, pMsg->params, pMsg->param2 & 0x1 ? true : false, pMsg->param2 & 0x2 ? true : false); } break; case TMSG_GUI_ADDON_DIALOG: { if (pMsg->lpVoid) { // TODO: This is ugly - really these python dialogs should just be normal XBMC dialogs ((ADDON::CGUIAddonWindowDialog *) pMsg->lpVoid)->Show_Internal(pMsg->param2 > 0); } } break; #ifdef HAS_PYTHON case TMSG_GUI_PYTHON_DIALOG: { // This hack is not much better but at least I don't need to make ApplicationMessenger // know about Addon (Python) specific classes. CAction caction(pMsg->param1); ((CGUIWindow*)pMsg->lpVoid)->OnAction(caction); } break; #endif case TMSG_GUI_ACTION: { if (pMsg->lpVoid) { CAction *action = (CAction *)pMsg->lpVoid; if (pMsg->param1 == WINDOW_INVALID) g_application.OnAction(*action); else { CGUIWindow *pWindow = g_windowManager.GetWindow(pMsg->param1); if (pWindow) pWindow->OnAction(*action); else CLog::Log(LOGWARNING, "Failed to get window with ID %i to send an action to", pMsg->param1); } delete action; } } break; case TMSG_GUI_MESSAGE: { if (pMsg->lpVoid) { CGUIMessage *message = (CGUIMessage *)pMsg->lpVoid; g_windowManager.SendMessage(*message, pMsg->param1); delete message; } } break; case TMSG_GUI_INFOLABEL: { if (pMsg->lpVoid) { vector<string> *infoLabels = (vector<string> *)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.EvaluateBool(pMsg->params[i])); } } break; case TMSG_CALLBACK: { ThreadMessageCallback *callback = (ThreadMessageCallback*)pMsg->lpVoid; callback->callback(callback->userptr); } break; case TMSG_VOLUME_SHOW: { CAction action(pMsg->param1); g_application.ShowVolumeBar(&action); } break; case TMSG_SPLASH_MESSAGE: { if (g_application.GetSplash()) g_application.GetSplash()->Show(pMsg->strParam); } break; case TMSG_DISPLAY_SETUP: { *((bool*)pMsg->lpVoid) = g_application.InitWindow(); g_application.SetRenderGUI(true); } break; case TMSG_DISPLAY_DESTROY: { *((bool*)pMsg->lpVoid) = g_application.DestroyWindow(); g_application.SetRenderGUI(false); } break; case TMSG_UPDATE_CURRENT_ITEM: { CFileItem* item = (CFileItem*)pMsg->lpVoid; if (!item) return; if (pMsg->param1 == 1 && item->HasMusicInfoTag()) // only grab music tag g_infoManager.SetCurrentSongTag(*item->GetMusicInfoTag()); else if (pMsg->param1 == 2 && item->HasVideoInfoTag()) // only grab video tag g_infoManager.SetCurrentVideoTag(*item->GetVideoInfoTag()); else g_infoManager.SetCurrentItem(*item); delete item; break; } case TMSG_LOADPROFILE: { CGUIWindowLoginScreen::LoadProfile(pMsg->param1); break; } case TMSG_CECTOGGLESTATE: { *((bool*)pMsg->lpVoid) = g_peripherals.ToggleDeviceState(STATE_SWITCH_TOGGLE); break; } case TMSG_CECACTIVATESOURCE: { g_peripherals.ToggleDeviceState(STATE_ACTIVATE_SOURCE); break; } case TMSG_CECSTANDBY: { g_peripherals.ToggleDeviceState(STATE_STANDBY); break; } case TMSG_START_ANDROID_ACTIVITY: { #if defined(TARGET_ANDROID) if (pMsg->params.size()) { CXBMCApp::StartActivity(pMsg->params[0], pMsg->params.size() > 1 ? pMsg->params[1] : "", pMsg->params.size() > 2 ? pMsg->params[2] : "", pMsg->params.size() > 3 ? pMsg->params[3] : ""); } #endif break; } case TMSG_SETPVRMANAGERSTATE: { if (pMsg->param1 != 0) g_application.StartPVRManager(); else g_application.StopPVRManager(); } } }
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; }
int CUPnPPlayer::PlayFile(const CFileItem& file, const CPlayerOptions& options, CGUIDialogBusy*& dialog, XbmcThreads::EndTime& timeout) { CFileItem item(file); NPT_Reference<CThumbLoader> thumb_loader; NPT_Reference<PLT_MediaObject> obj; NPT_String path(file.GetPath().c_str()); NPT_String tmp, resource; EMediaControllerQuirks quirks = EMEDIACONTROLLERQUIRKS_NONE; NPT_CHECK_POINTER_LABEL_SEVERE(m_delegate, failed); if (file.IsVideoDb()) thumb_loader = NPT_Reference<CThumbLoader>(new CVideoThumbLoader()); else if (item.IsMusicDb()) thumb_loader = NPT_Reference<CThumbLoader>(new CMusicThumbLoader()); obj = BuildObject(item, path, false, thumb_loader, NULL, CUPnP::GetServer(), UPnPPlayer); if(obj.IsNull()) goto failed; NPT_CHECK_LABEL_SEVERE(PLT_Didl::ToDidl(*obj, "", tmp), failed_todidl); tmp.Insert(didl_header, 0); tmp.Append(didl_footer); quirks = GetMediaControllerQuirks(m_delegate->m_device.AsPointer()); if (quirks & EMEDIACONTROLLERQUIRKS_X_MKV) { for (NPT_Cardinal i=0; i< obj->m_Resources.GetItemCount(); i++) { if (obj->m_Resources[i].m_ProtocolInfo.GetContentType().Compare("video/x-matroska") == 0) { CLog::Log(LOGDEBUG, "CUPnPPlayer::PlayFile(%s): applying video/x-mkv quirk", file.GetPath().c_str()); NPT_String protocolInfo = obj->m_Resources[i].m_ProtocolInfo.ToString(); protocolInfo.Replace(":video/x-matroska:", ":video/x-mkv:"); obj->m_Resources[i].m_ProtocolInfo = PLT_ProtocolInfo(protocolInfo); } } } /* The resource uri's are stored in the Didl. We must choose the best resource * for the playback device */ NPT_Cardinal res_index; NPT_CHECK_LABEL_SEVERE(m_control->FindBestResource(m_delegate->m_device, *obj, res_index), failed_findbestresource); // get the transport info to evaluate the TransportState to be able to // determine whether we first need to call Stop() timeout.Set(timeout.GetInitialTimeoutValue()); NPT_CHECK_LABEL_SEVERE(m_control->GetTransportInfo(m_delegate->m_device , m_delegate->m_instance , m_delegate), failed_gettransportinfo); NPT_CHECK_LABEL_SEVERE(WaitOnEvent(m_delegate->m_traevnt, timeout, dialog), failed_gettransportinfo); if (m_delegate->m_trainfo.cur_transport_state != "NO_MEDIA_PRESENT" && m_delegate->m_trainfo.cur_transport_state != "STOPPED") { timeout.Set(timeout.GetInitialTimeoutValue()); NPT_CHECK_LABEL_SEVERE(m_control->Stop(m_delegate->m_device , m_delegate->m_instance , m_delegate), failed_stop); NPT_CHECK_LABEL_SEVERE(WaitOnEvent(m_delegate->m_resevent, timeout, dialog), failed_stop); NPT_CHECK_LABEL_SEVERE(m_delegate->m_resstatus, failed_stop); } timeout.Set(timeout.GetInitialTimeoutValue()); NPT_CHECK_LABEL_SEVERE(m_control->SetAVTransportURI(m_delegate->m_device , m_delegate->m_instance , obj->m_Resources[res_index].m_Uri , (const char*)tmp , m_delegate), failed_setavtransporturi); NPT_CHECK_LABEL_SEVERE(WaitOnEvent(m_delegate->m_resevent, timeout, dialog), failed_setavtransporturi); NPT_CHECK_LABEL_SEVERE(m_delegate->m_resstatus, failed_setavtransporturi); timeout.Set(timeout.GetInitialTimeoutValue()); NPT_CHECK_LABEL_SEVERE(m_control->Play(m_delegate->m_device , m_delegate->m_instance , "1" , m_delegate), failed_play); NPT_CHECK_LABEL_SEVERE(WaitOnEvent(m_delegate->m_resevent, timeout, dialog), failed_play); NPT_CHECK_LABEL_SEVERE(m_delegate->m_resstatus, failed_play); /* wait for PLAYING state */ timeout.Set(timeout.GetInitialTimeoutValue()); do { NPT_CHECK_LABEL_SEVERE(m_control->GetTransportInfo(m_delegate->m_device , m_delegate->m_instance , m_delegate), failed_waitplaying); { CSingleLock lock(m_delegate->m_section); if(m_delegate->m_trainfo.cur_transport_state == "PLAYING" || m_delegate->m_trainfo.cur_transport_state == "PAUSED_PLAYBACK") break; if(m_delegate->m_trainfo.cur_transport_state == "STOPPED" && m_delegate->m_trainfo.cur_transport_status != "OK") { CLog::Log(LOGERROR, "UPNP: CUPnPPlayer::OpenFile - remote player signalled error %s", file.GetPath().c_str()); return NPT_FAILURE; } } NPT_CHECK_LABEL_SEVERE(WaitOnEvent(m_delegate->m_traevnt, timeout, dialog), failed_waitplaying); } while(!timeout.IsTimePast()); if(options.starttime > 0) { /* many upnp units won't load file properly until after play (including xbmc) */ NPT_CHECK_LABEL(m_control->Seek(m_delegate->m_device , m_delegate->m_instance , "REL_TIME" , PLT_Didl::FormatTimeStamp((NPT_UInt32)options.starttime) , m_delegate), failed_seek); } return NPT_SUCCESS; failed_todidl: CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s) failed to serialize item into DIDL-Lite", file.GetPath().c_str()); return NPT_FAILURE; failed_findbestresource: CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s) failed to find a matching resource", file.GetPath().c_str()); return NPT_FAILURE; failed_gettransportinfo: CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s): call to GetTransportInfo failed", file.GetPath().c_str()); return NPT_FAILURE; failed_stop: CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s) failed to stop current playback", file.GetPath().c_str()); return NPT_FAILURE; failed_setavtransporturi: CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s) failed to set the playback URI", file.GetPath().c_str()); return NPT_FAILURE; failed_play: CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s) failed to start playback", file.GetPath().c_str()); return NPT_FAILURE; failed_waitplaying: CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s) failed to wait for PLAYING state", file.GetPath().c_str()); return NPT_FAILURE; failed_seek: CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s) failed to seek to start offset", file.GetPath().c_str()); return NPT_FAILURE; failed: CLog::Log(LOGERROR, "CUPnPPlayer::PlayFile(%s) failed", file.GetPath().c_str()); return NPT_FAILURE; }
/*! \brief Run a script, plugin or game add-on. * \param params The parameters. * \details params[0] = add-on id. * params[1] is blank for no add-on parameters * or * params[1] = add-on parameters in url format * or * params[1,...] = additional parameters in format param=value. */ static int RunAddon(const std::vector<std::string>& params) { if (params.size()) { const std::string& addonid = params[0]; AddonPtr addon; if (CAddonMgr::GetInstance().GetAddon(addonid, addon, ADDON_PLUGIN)) { PluginPtr plugin = std::dynamic_pointer_cast<CPluginSource>(addon); std::string urlParameters; std::vector<std::string> parameters; if (params.size() == 2 && (StringUtils::StartsWith(params[1], "/") || StringUtils::StartsWith(params[1], "?"))) urlParameters = params[1]; else if (params.size() > 1) { parameters.insert(parameters.begin(), params.begin() + 1, params.end()); urlParameters = "?" + StringUtils::Join(parameters, "&"); } else { // Add '/' if addon is run without params (will be removed later so it's safe) // Otherwise there are 2 entries for the same plugin in ViewModesX.db urlParameters = "/"; } std::string cmd; if (plugin->Provides(CPluginSource::VIDEO)) cmd = StringUtils::Format("ActivateWindow(Videos,plugin://%s%s,return)", addonid.c_str(), urlParameters.c_str()); else if (plugin->Provides(CPluginSource::AUDIO)) cmd = StringUtils::Format("ActivateWindow(Music,plugin://%s%s,return)", addonid.c_str(), urlParameters.c_str()); else if (plugin->Provides(CPluginSource::EXECUTABLE)) cmd = StringUtils::Format("ActivateWindow(Programs,plugin://%s%s,return)", addonid.c_str(), urlParameters.c_str()); else if (plugin->Provides(CPluginSource::IMAGE)) cmd = StringUtils::Format("ActivateWindow(Pictures,plugin://%s%s,return)", addonid.c_str(), urlParameters.c_str()); else if (plugin->Provides(CPluginSource::GAME)) cmd = StringUtils::Format("ActivateWindow(Games,plugin://%s%s,return)", addonid.c_str(), urlParameters.c_str()); else // Pass the script name (addonid) and all the parameters // (params[1] ... params[x]) separated by a comma to RunPlugin cmd = StringUtils::Format("RunPlugin(%s)", StringUtils::Join(params, ",").c_str()); CBuiltins::GetInstance().Execute(cmd); } else if (CAddonMgr::GetInstance().GetAddon(addonid, addon, ADDON_SCRIPT) || CAddonMgr::GetInstance().GetAddon(addonid, addon, ADDON_SCRIPT_WEATHER) || CAddonMgr::GetInstance().GetAddon(addonid, addon, ADDON_SCRIPT_LYRICS) || CAddonMgr::GetInstance().GetAddon(addonid, addon, ADDON_SCRIPT_LIBRARY)) { // Pass the script name (addonid) and all the parameters // (params[1] ... params[x]) separated by a comma to RunScript CBuiltins::GetInstance().Execute(StringUtils::Format("RunScript(%s)", StringUtils::Join(params, ",").c_str())); } else if (CAddonMgr::GetInstance().GetAddon(addonid, addon, ADDON_GAMEDLL)) { CFileItem item; if (params.size() >= 2) { item = CFileItem(params[1], false); item.GetGameInfoTag()->SetGameClient(addonid); } else item = CFileItem(addon); if (!g_application.PlayMedia(item, "", PLAYLIST_NONE)) { CLog::Log(LOGERROR, "RunAddon could not start %s", addonid.c_str()); return false; } } else CLog::Log(LOGERROR, "RunAddon: unknown add-on id '%s', or unexpected add-on type (not a script or plugin).", addonid.c_str()); } else { CLog::Log(LOGERROR, "RunAddon called with no arguments."); } return 0; }
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); CPVRChannelPtr channelTag(item.GetPVRChannelInfoTag()); CEpgInfoTagPtr epgTagNow(channelTag->GetEPGNow()); if (channelTag->IsRadio()) { CMusicInfoTag* musictag = item.GetMusicInfoTag(); if (musictag) { musictag->SetTitle(epgTagNow ? epgTagNow->Title() : CSettings::GetInstance().GetBool(CSettings::SETTING_EPG_HIDENOINFOAVAILABLE) ? "" : g_localizeStrings.Get(19055)); // no information available if (epgTagNow) musictag->SetGenre(epgTagNow->Genre()); musictag->SetDuration(epgTagNow ? epgTagNow->GetDuration() : 3600); musictag->SetURL(channelTag->Path()); musictag->SetArtist(channelTag->ChannelName()); musictag->SetAlbumArtist(channelTag->ChannelName()); musictag->SetLoaded(true); musictag->SetComment(""); musictag->SetLyrics(""); } } else { CVideoInfoTag *videotag = item.GetVideoInfoTag(); if (videotag) { videotag->m_strTitle = epgTagNow ? epgTagNow->Title() : CSettings::GetInstance().GetBool(CSettings::SETTING_EPG_HIDENOINFOAVAILABLE) ? "" : g_localizeStrings.Get(19055); // no information available if (epgTagNow) videotag->m_genre = epgTagNow->Genre(); videotag->m_strPath = channelTag->Path(); videotag->m_strFileNameAndPath = channelTag->Path(); videotag->m_strPlot = epgTagNow ? epgTagNow->Plot() : ""; videotag->m_strPlotOutline = epgTagNow ? epgTagNow->PlotOutline() : ""; videotag->m_iEpisode = epgTagNow ? epgTagNow->EpisodeNumber() : 0; } } return false; }
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 ) { 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()); }
wxString CQueueViewBase::OnGetItemText(CQueueItem* pItem, ColumnId column) const { switch (pItem->GetType()) { case QueueItemType::Server: { CServerItem* pServerItem = reinterpret_cast<CServerItem*>(pItem); if (!column) return pServerItem->GetName(); } break; case QueueItemType::File: { CFileItem* pFileItem = reinterpret_cast<CFileItem*>(pItem); switch (column) { case colLocalName: return pFileItem->GetIndent() + pFileItem->GetLocalPath().GetPath() + pFileItem->GetLocalFile(); case colDirection: if (pFileItem->Download()) if (pFileItem->queued()) return _T("<--"); else return _T("<<--"); else if (pFileItem->queued()) return _T("-->"); else return _T("-->>"); break; case colRemoteName: return pFileItem->GetRemotePath().FormatFilename(pFileItem->GetRemoteFile()); case colSize: { const wxLongLong& size = pFileItem->GetSize(); if (size >= 0) return CSizeFormat::Format(size); else return _T("?"); } case colPriority: switch (pFileItem->GetPriority()) { case QueuePriority::lowest: return _("Lowest"); case QueuePriority::low: return _("Low"); default: case QueuePriority::normal: return _("Normal"); case QueuePriority::high: return _("High"); case QueuePriority::highest: return _("Highest"); } break; case colTransferStatus: case colErrorReason: return pFileItem->m_statusMessage; case colTime: return CTimeFormat::FormatDateTime(pItem->GetTime()); default: break; } } break; case QueueItemType::FolderScan: { CFolderScanItem* pFolderItem = reinterpret_cast<CFolderScanItem*>(pItem); switch (column) { case colLocalName: return _T(" ") + pFolderItem->GetLocalPath().GetPath(); case colDirection: if (pFolderItem->Download()) if (pFolderItem->queued()) return _T("<--"); else return _T("<<--"); else if (pFolderItem->queued()) return _T("-->"); else return _T("-->>"); break; case colRemoteName: return pFolderItem->GetRemotePath().GetPath(); case colTransferStatus: case colErrorReason: return pFolderItem->m_statusMessage; case colTime: return CTimeFormat::FormatDateTime(pItem->GetTime()); default: break; } } break; case QueueItemType::Folder: { CFileItem* pFolderItem = reinterpret_cast<CFolderItem*>(pItem); switch (column) { case colLocalName: if (pFolderItem->Download()) return pFolderItem->GetIndent() + pFolderItem->GetLocalPath().GetPath() + pFolderItem->GetLocalFile(); break; case colDirection: if (pFolderItem->Download()) if (pFolderItem->queued()) return _T("<--"); else return _T("<<--"); else if (pFolderItem->queued()) return _T("-->"); else return _T("-->>"); break; case colRemoteName: if (!pFolderItem->Download()) { if (pFolderItem->GetRemoteFile().empty()) return pFolderItem->GetRemotePath().GetPath(); else return pFolderItem->GetRemotePath().FormatFilename(pFolderItem->GetRemoteFile()); } break; case colPriority: switch (pFolderItem->GetPriority()) { case QueuePriority::lowest: return _("Lowest"); case QueuePriority::low: return _("Low"); default: case QueuePriority::normal: return _("Normal"); case QueuePriority::high: return _("High"); case QueuePriority::highest: return _("Highest"); } break; case colTransferStatus: case colErrorReason: return pFolderItem->m_statusMessage; case colTime: return CTimeFormat::FormatDateTime(pItem->GetTime()); default: break; } } break; default: break; } return wxString(); }
void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg) { switch (pMsg->dwMessage) { case TMSG_SHUTDOWN: { switch (g_guiSettings.GetInt("powermanagement.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; case TMSG_RENDERER_FLUSH: g_renderManager.Flush(); break; } } break; case TMSG_POWERDOWN: { g_application.Stop(EXITCODE_POWERDOWN); g_powerManager.Powerdown(); } break; case TMSG_QUIT: { g_application.Stop(EXITCODE_QUIT); } break; case TMSG_HIBERNATE: { g_PVRManager.SetWakeupCommand(); g_powerManager.Hibernate(); } break; case TMSG_SUSPEND: { g_PVRManager.SetWakeupCommand(); g_powerManager.Suspend(); } break; case TMSG_RESTART: case TMSG_RESET: { g_application.Stop(EXITCODE_REBOOT); g_powerManager.Reboot(); } break; case TMSG_RESTARTAPP: { #if defined(TARGET_WINDOWS) || defined(TARGET_LINUX) g_application.Stop(EXITCODE_RESTARTAPP); #endif } break; case TMSG_INHIBITIDLESHUTDOWN: { g_application.InhibitIdleShutdown((bool)pMsg->dwParam1); } 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 if(pMsg->lpVoid) { CFileItemList *list = (CFileItemList *)pMsg->lpVoid; if (list->Size() > 0) { int playlist = PLAYLIST_MUSIC; for (int i = 0; i < list->Size(); i++) { if ((*list)[i]->IsVideo()) { playlist = PLAYLIST_VIDEO; break; } } g_playlistPlayer.ClearPlaylist(playlist); g_playlistPlayer.SetCurrentPlaylist(playlist); //For single item lists try PlayMedia. This covers some more cases where a playlist is not appropriate //It will fall through to PlayFile if (list->Size() == 1 && !(*list)[0]->IsPlayList()) g_application.PlayMedia(*((*list)[0]), playlist); else { // Handle "shuffled" option if present if (list->HasProperty("shuffled") && list->GetProperty("shuffled").isBoolean()) g_playlistPlayer.SetShuffle(playlist, list->GetProperty("shuffled").asBoolean(), false); // Handle "repeat" option if present if (list->HasProperty("repeat") && list->GetProperty("repeat").isInteger()) g_playlistPlayer.SetRepeat(playlist, (PLAYLIST::REPEAT_STATE)list->GetProperty("repeat").asInteger(), false); g_playlistPlayer.Add(playlist, (*list)); g_playlistPlayer.Play(pMsg->dwParam1); } } delete list; } else if (pMsg->dwParam1 == PLAYLIST_MUSIC || pMsg->dwParam1 == PLAYLIST_VIDEO) { if (g_playlistPlayer.GetCurrentPlaylist() != (int)pMsg->dwParam1) g_playlistPlayer.SetCurrentPlaylist(pMsg->dwParam1); PlayListPlayerPlay(pMsg->dwParam2); } } break; case TMSG_MEDIA_RESTART: g_application.Restart(true); break; 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(); if (g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW) g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); if (URIUtils::IsZIP(pMsg->strParam) || URIUtils::IsRAR(pMsg->strParam)) // actually a cbz/cbr { CFileItemList items; CStdString strPath; if (URIUtils::IsZIP(pMsg->strParam)) URIUtils::CreateArchivePath(strPath, "zip", pMsg->strParam.c_str(), ""); else URIUtils::CreateArchivePath(strPath, "rar", pMsg->strParam.c_str(), ""); CUtil::GetRecursiveListing(strPath, items, g_settings.m_pictureExtensions); if (items.Size() > 0) { pSlideShow->Reset(); for (int i=0;i<items.Size();++i) { pSlideShow->Add(items[i].get()); } pSlideShow->Select(items[0]->GetPath()); } } else { CFileItem item(pMsg->strParam, false); pSlideShow->Reset(); 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 ; if (g_application.IsPlayingVideo()) g_application.StopPlaying(); g_graphicsContext.Lock(); pSlideShow->Reset(); CFileItemList items; CStdString strPath = pMsg->strParam; CStdString extensions = g_settings.m_pictureExtensions; if (pMsg->dwParam1) extensions += "|.tbn"; CUtil::GetRecursiveListing(strPath, items, extensions); 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) { if(items.Size() == 0) { g_guiSettings.SetString("screensaver.mode", "screensaver.xbmc.builtin.dim"); g_application.ActivateScreenSaver(); } else g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); } g_graphicsContext.Unlock(); } break; case TMSG_SETLANGUAGE: g_guiSettings.SetLanguage(pMsg->strParam); break; case TMSG_MEDIA_STOP: { // 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_MEDIA_UNPAUSE: if (g_application.IsPaused()) { g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); g_application.m_pPlayer->Pause(); } break; case TMSG_SWITCHTOFULLSCREEN: if( g_windowManager.GetActiveWindow() != WINDOW_FULLSCREEN_VIDEO ) g_application.SwitchToFullScreen(); break; case TMSG_TOGGLEFULLSCREEN: g_graphicsContext.Lock(); g_graphicsContext.ToggleFullScreenRoot(); g_graphicsContext.Unlock(); break; case TMSG_MINIMIZE: g_application.Minimize(); break; case TMSG_EXECUTE_OS: #if defined( _LINUX) && !defined(TARGET_DARWIN) 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_HTTPAPI if (!m_pXbmcHttp) { m_pXbmcHttp = new CXbmcHttp(); } switch (m_pXbmcHttp->xbmcCommand(pMsg->strParam)) { case 1: Restart(); break; case 2: Shutdown(); break; case 3: Quit(); break; case 4: Reset(); break; case 5: RestartApp(); break; } #endif } break; case TMSG_EXECUTE_SCRIPT: #ifdef HAS_PYTHON g_pythonParser.evalFile(pMsg->strParam.c_str(),ADDON::AddonPtr()); #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_PLAY_SONG_ID: if (pMsg->dwParam1 != (DWORD) -1) { bool *result = (bool*)pMsg->lpVoid; *result = g_playlistPlayer.PlaySongId(pMsg->dwParam1); } else g_playlistPlayer.Play(); break; case TMSG_PLAYLISTPLAYER_NEXT: g_playlistPlayer.PlayNext(); break; case TMSG_PLAYLISTPLAYER_PREV: g_playlistPlayer.PlayPrevious(); break; case TMSG_PLAYLISTPLAYER_ADD: if(pMsg->lpVoid) { CFileItemList *list = (CFileItemList *)pMsg->lpVoid; g_playlistPlayer.Add(pMsg->dwParam1, (*list)); delete list; } break; case TMSG_PLAYLISTPLAYER_INSERT: if (pMsg->lpVoid) { CFileItemList *list = (CFileItemList *)pMsg->lpVoid; g_playlistPlayer.Insert(pMsg->dwParam1, (*list), pMsg->dwParam2); delete list; } break; case TMSG_PLAYLISTPLAYER_REMOVE: if (pMsg->dwParam1 != (DWORD) -1) g_playlistPlayer.Remove(pMsg->dwParam1,pMsg->dwParam2); break; case TMSG_PLAYLISTPLAYER_CLEAR: g_playlistPlayer.ClearPlaylist(pMsg->dwParam1); break; case TMSG_PLAYLISTPLAYER_SHUFFLE: g_playlistPlayer.SetShuffle(pMsg->dwParam1, pMsg->dwParam2 > 0); break; case TMSG_PLAYLISTPLAYER_REPEAT: g_playlistPlayer.SetRepeat(pMsg->dwParam1, (PLAYLIST::REPEAT_STATE)pMsg->dwParam2); break; case TMSG_PLAYLISTPLAYER_GET_ITEMS: if (pMsg->lpVoid) { PLAYLIST::CPlayList playlist = g_playlistPlayer.GetPlaylist(pMsg->dwParam1); CFileItemList *list = (CFileItemList *)pMsg->lpVoid; for (int i = 0; i < playlist.size(); i++) list->Add(CFileItemPtr(new CFileItem(*playlist[i]))); } break; case TMSG_PLAYLISTPLAYER_SWAP: if (pMsg->lpVoid) { vector<int> *indexes = (vector<int> *)pMsg->lpVoid; if (indexes->size() == 2) g_playlistPlayer.Swap(pMsg->dwParam1, indexes->at(0), indexes->at(1)); delete indexes; } 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_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((int)pMsg->dwParam1, pMsg->strParam); } break; case TMSG_GUI_SHOW: { CGUIDialog *pDialog = (CGUIDialog *)pMsg->lpVoid; if (pDialog) pDialog->Show(); } break; case TMSG_GUI_WINDOW_CLOSE: { CGUIWindow *window = (CGUIWindow *)pMsg->lpVoid; if (window) window->Close(pMsg->dwParam2 & 0x1 ? true : false, pMsg->dwParam1, pMsg->dwParam2 & 0x2 ? true : false); } break; case TMSG_GUI_ACTIVATE_WINDOW: { g_windowManager.ActivateWindow(pMsg->dwParam1, pMsg->params, pMsg->dwParam2 > 0); } break; case TMSG_GUI_ADDON_DIALOG: { if (pMsg->lpVoid) { // TODO: This is ugly - really these python dialogs should just be normal XBMC dialogs ((ADDON::CGUIAddonWindowDialog *) pMsg->lpVoid)->Show_Internal(pMsg->dwParam2 > 0); } } break; case TMSG_GUI_PYTHON_DIALOG: { if (pMsg->lpVoid) { // TODO: This is ugly - really these python dialogs should just be normal XBMC dialogs if (pMsg->dwParam1) ((CGUIPythonWindowXMLDialog *)pMsg->lpVoid)->Show_Internal(pMsg->dwParam2 > 0); else ((CGUIPythonWindowDialog *)pMsg->lpVoid)->Show_Internal(pMsg->dwParam2 > 0); } } break; case TMSG_GUI_ACTION: { if (pMsg->lpVoid) { CAction *action = (CAction *)pMsg->lpVoid; if (pMsg->dwParam1 == WINDOW_INVALID) g_application.OnAction(*action); else { CGUIWindow *pWindow = g_windowManager.GetWindow(pMsg->dwParam1); if (pWindow) pWindow->OnAction(*action); else CLog::Log(LOGWARNING, "Failed to get window with ID %i to send an action to", pMsg->dwParam1); } delete action; } } break; case TMSG_GUI_MESSAGE: { if (pMsg->lpVoid) { CGUIMessage *message = (CGUIMessage *)pMsg->lpVoid; g_windowManager.SendMessage(*message, pMsg->dwParam1); delete message; } } 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.EvaluateBool(pMsg->params[i])); } } break; case TMSG_CALLBACK: { ThreadMessageCallback *callback = (ThreadMessageCallback*)pMsg->lpVoid; callback->callback(callback->userptr); } break; case TMSG_VOLUME_SHOW: { CAction action((int)pMsg->dwParam1); g_application.ShowVolumeBar(&action); } break; case TMSG_SPLASH_MESSAGE: { if (g_application.GetSplash()) g_application.GetSplash()->Show(pMsg->strParam); } break; case TMSG_DISPLAY_SETUP: { *((bool*)pMsg->lpVoid) = g_application.InitWindow(); g_application.ReloadSkin(); } break; case TMSG_DISPLAY_DESTROY: { *((bool*)pMsg->lpVoid) = g_application.DestroyWindow(); } break; case TMSG_UPDATE_CURRENT_ITEM: { CFileItem* item = (CFileItem*)pMsg->lpVoid; if (!item) return; if (pMsg->dwParam1 == 1 && item->HasMusicInfoTag()) // only grab music tag g_infoManager.SetCurrentSongTag(*item->GetMusicInfoTag()); else if (pMsg->dwParam1 == 2 && item->HasVideoInfoTag()) // only grab video tag g_infoManager.SetCurrentVideoTag(*item->GetVideoInfoTag()); else g_infoManager.SetCurrentItem(*item); delete item; break; } } }
void CVideoThumbLoader::DetectAndAddMissingItemData(CFileItem &item) { if (item.m_bIsFolder) return; if (item.HasVideoInfoTag()) { CStreamDetails& details = item.GetVideoInfoTag()->m_streamDetails; // add audio language properties for (int i = 1; i <= details.GetAudioStreamCount(); i++) { std::string index = StringUtils::Format("%i", i); item.SetProperty("AudioChannels." + index, details.GetAudioChannels(i)); item.SetProperty("AudioCodec." + index, details.GetAudioCodec(i).c_str()); item.SetProperty("AudioLanguage." + index, details.GetAudioLanguage(i).c_str()); } // add subtitle language properties for (int i = 1; i <= details.GetSubtitleStreamCount(); i++) { std::string index = StringUtils::Format("%i", i); item.SetProperty("SubtitleLanguage." + index, details.GetSubtitleLanguage(i).c_str()); } } std::string stereoMode; // detect stereomode for videos if (item.HasVideoInfoTag()) stereoMode = item.GetVideoInfoTag()->m_streamDetails.GetStereoMode(); if (stereoMode.empty()) { std::string path = item.GetPath(); if (item.IsVideoDb() && item.HasVideoInfoTag()) path = item.GetVideoInfoTag()->GetPath(); // check for custom stereomode setting in video settings CVideoSettings itemVideoSettings; m_videoDatabase->Open(); if (m_videoDatabase->GetVideoSettings(item, itemVideoSettings) && itemVideoSettings.m_StereoMode != RENDER_STEREO_MODE_OFF) stereoMode = CStereoscopicsManager::GetInstance().ConvertGuiStereoModeToString( (RENDER_STEREO_MODE) itemVideoSettings.m_StereoMode ); m_videoDatabase->Close(); // still empty, try grabbing from filename // TODO: in case of too many false positives due to using the full path, extract the filename only using string utils if (stereoMode.empty()) stereoMode = CStereoscopicsManager::GetInstance().DetectStereoModeByString( path ); } if (!stereoMode.empty()) item.SetProperty("stereomode", CStereoscopicsManager::GetInstance().NormalizeStereoMode(stereoMode)); }
void CQueueViewFailed::OnRemoveSelected(wxCommandEvent&) { #ifndef __WXMSW__ // GetNextItem is O(n) if nothing is selected, GetSelectedItemCount() is O(1) if (!GetSelectedItemCount()) return; #endif std::list<CQueueItem*> selectedItems; long item = -1; for (;;) { item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (item == -1) break; selectedItems.push_front(GetQueueItem(item)); SetItemState(item, 0, wxLIST_STATE_SELECTED); } CEditHandler* pEditHandler = CEditHandler::Get(); while (!selectedItems.empty()) { CQueueItem* pItem = selectedItems.front(); selectedItems.pop_front(); CQueueItem* pTopLevelItem = pItem->GetTopLevelItem(); if (pItem->GetType() == QueueItemType::Server) { CServerItem* pServerItem = (CServerItem*)pItem; if (pEditHandler && pEditHandler->GetFileCount(CEditHandler::remote, CEditHandler::upload_and_remove_failed, &pServerItem->GetServer())) pEditHandler->RemoveAll(CEditHandler::upload_and_remove_failed, &pServerItem->GetServer()); } else if (pItem->GetType() == QueueItemType::File) { CFileItem* pFileItem = (CFileItem*)pItem; if (pFileItem->m_edit == CEditHandler::remote && pEditHandler) { if (pFileItem->m_edit == CEditHandler::local) { wxString fullPath(pFileItem->GetLocalPath().GetPath() + pFileItem->GetLocalFile()); enum CEditHandler::fileState state = pEditHandler->GetFileState(fullPath); if (state == CEditHandler::upload_and_remove_failed) pEditHandler->Remove(fullPath); } else { CServerItem* pServerItem = (CServerItem*)pFileItem->GetTopLevelItem(); enum CEditHandler::fileState state = pEditHandler->GetFileState(pFileItem->GetRemoteFile(), pFileItem->GetRemotePath(), pServerItem->GetServer()); if (state == CEditHandler::upload_and_remove_failed) pEditHandler->Remove(pFileItem->GetRemoteFile(), pFileItem->GetRemotePath(), pServerItem->GetServer()); } } } if (!pTopLevelItem->GetChild(1)) { // Parent will get deleted // If next selected item is parent, remove it from list if (!selectedItems.empty() && selectedItems.front() == pTopLevelItem) selectedItems.pop_front(); } RemoveItem(pItem, true, false, false); } DisplayNumberQueuedFiles(); SaveSetItemCount(m_itemCount); RefreshListOnly(); if (!m_itemCount && m_pQueue->GetQueueView()->GetItemCount()) m_pQueue->SetSelection(0); }
bool CVideoThumbLoader::FillLibraryArt(CFileItem &item) { CVideoInfoTag &tag = *item.GetVideoInfoTag(); if (tag.m_iDbId > -1 && !tag.m_type.empty()) { std::map<std::string, std::string> artwork; m_videoDatabase->Open(); if (m_videoDatabase->GetArtForItem(tag.m_iDbId, tag.m_type, artwork)) SetArt(item, artwork); else if (tag.m_type == "actor" && !tag.m_artist.empty()) { // we retrieve music video art from the music database (no backward compat) CMusicDatabase database; database.Open(); int idArtist = database.GetArtistByName(item.GetLabel()); if (database.GetArtForItem(idArtist, MediaTypeArtist, artwork)) item.SetArt(artwork); } else if (tag.m_type == MediaTypeAlbum) { // we retrieve music video art from the music database (no backward compat) CMusicDatabase database; database.Open(); int idAlbum = database.GetAlbumByName(item.GetLabel(), tag.m_artist); if (database.GetArtForItem(idAlbum, MediaTypeAlbum, artwork)) item.SetArt(artwork); } if (tag.m_type == MediaTypeEpisode || tag.m_type == MediaTypeSeason) { // For episodes and seasons, we want to set fanart for that of the show if (!item.HasArt("fanart") && tag.m_iIdShow >= 0) { ArtCache::const_iterator i = m_showArt.find(tag.m_iIdShow); if (i == m_showArt.end()) { std::map<std::string, std::string> showArt; m_videoDatabase->GetArtForItem(tag.m_iIdShow, MediaTypeTvShow, showArt); i = m_showArt.insert(std::make_pair(tag.m_iIdShow, showArt)).first; } if (i != m_showArt.end()) { item.AppendArt(i->second, "tvshow"); item.SetArtFallback("fanart", "tvshow.fanart"); item.SetArtFallback("tvshow.thumb", "tvshow.poster"); } } if (!item.HasArt("season.poster") && tag.m_iSeason > -1) { ArtCache::const_iterator i = m_seasonArt.find(tag.m_iIdSeason); if (i == m_seasonArt.end()) { std::map<std::string, std::string> seasonArt; m_videoDatabase->GetArtForItem(tag.m_iIdSeason, MediaTypeSeason, seasonArt); i = m_seasonArt.insert(std::make_pair(tag.m_iIdSeason, seasonArt)).first; } if (i != m_seasonArt.end()) item.AppendArt(i->second, MediaTypeSeason); } } m_videoDatabase->Close(); } return !item.GetArt().empty(); }
CAlbum::CAlbum(const CFileItem& item) { Reset(); const CMusicInfoTag& tag = *item.GetMusicInfoTag(); SYSTEMTIME stTime; tag.GetReleaseDate(stTime); strAlbum = tag.GetAlbum(); strMusicBrainzAlbumID = tag.GetMusicBrainzAlbumID(); genre = tag.GetGenre(); std::vector<std::string> musicBrainAlbumArtistHints = tag.GetMusicBrainzAlbumArtistHints(); strArtistDesc = tag.GetAlbumArtistString(); if (!tag.GetMusicBrainzAlbumArtistID().empty()) { // have musicbrainz artist info, so use it for (size_t i = 0; i < tag.GetMusicBrainzAlbumArtistID().size(); i++) { std::string artistId = tag.GetMusicBrainzAlbumArtistID()[i]; std::string artistName; /* We try and get the mbrainzid <-> name matching from the hints and match on the same index. If not found, we try and use the mbrainz <-> name matching from the artists fields If still not found, try and use the same index of the albumartist field. If still not found, use the mbrainzid and hope we later on can update that entry */ if (i < musicBrainAlbumArtistHints.size()) artistName = musicBrainAlbumArtistHints[i]; else if (!tag.GetMusicBrainzArtistID().empty() && !tag.GetArtist().empty()) { for (size_t j = 0; j < tag.GetMusicBrainzArtistID().size(); j++) { if (artistId == tag.GetMusicBrainzArtistID()[j]) { if (j < tag.GetMusicBrainzArtistHints().size()) artistName = tag.GetMusicBrainzArtistHints()[j]; else artistName = (j < tag.GetArtist().size()) ? tag.GetArtist()[j] : tag.GetArtist()[0]; } } } if (artistName.empty() && tag.GetMusicBrainzAlbumArtistID().size() == tag.GetAlbumArtist().size()) artistName = tag.GetAlbumArtist()[i]; if (artistName.empty()) artistName = artistId; CArtistCredit artistCredit(artistName, tag.GetMusicBrainzAlbumArtistID()[i]); artistCredits.push_back(artistCredit); } } else { // no musicbrainz info, so fill in directly for (std::vector<std::string>::const_iterator it = tag.GetAlbumArtist().begin(); it != tag.GetAlbumArtist().end(); ++it) { artistCredits.emplace_back(*it); } } iYear = stTime.wYear; bCompilation = tag.GetCompilation(); iTimesPlayed = 0; dateAdded.Reset(); lastPlayed.Reset(); releaseType = tag.GetAlbumReleaseType(); }
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)); musictag->SetGenre(bHasTagNow ? epgTagNow.Genre() : StringUtils::EmptyString); 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); videotag->m_strGenre = bHasTagNow ? epgTagNow.Genre() : StringUtils::EmptyString; 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 CActiveAEDSPDatabase::DeleteActiveDSPSettings(const CFileItem &item) { std::string strPath, strFileName; URIUtils::Split(item.GetPath(), strPath, strFileName); return ExecuteQuery(PrepareSQL("DELETE FROM settings WHERE settings.strPath='%s' and settings.strFileName='%s'", strPath.c_str() , strFileName.c_str())); }
//********************************************************************************************* bool CFile::Open(const CStdString& strFileName, bool bBinary, unsigned int flags) { m_flags = flags; try { bool bPathInCache; if (!g_directoryCache.FileExists(strFileName, bPathInCache) ) { if (bPathInCache) return false; } CFileItem fileItem; fileItem.m_strPath = strFileName; if ( (flags & READ_NO_CACHE) == 0 && fileItem.IsInternetStream() && !fileItem.IsPicture()) m_flags |= READ_CACHED; CURL url(strFileName); if (m_flags & READ_CACHED) { m_pFile = new CFileCache(); return m_pFile->Open(url, bBinary); } m_pFile = CFileFactory::CreateLoader(url); if (!m_pFile) return false; try { if (!m_pFile->Open(url, bBinary)) { SAFE_DELETE(m_pFile); return false; } } catch (CRedirectException *pRedirectEx) { // the file implementation decided this item should use a different implementation. // the exception will contain the new implementation. CLog::Log(LOGDEBUG,"File::Open - redirecting implementation for %s", strFileName.c_str()); SAFE_DELETE(m_pFile); if (pRedirectEx && pRedirectEx->m_pNewFileImp) { m_pFile = pRedirectEx->m_pNewFileImp; delete pRedirectEx; if (!m_pFile->Open(url, bBinary)) { SAFE_DELETE(m_pFile); return false; } } } catch (...) { CLog::Log(LOGDEBUG,"File::Open - unknown exception when opening %s", strFileName.c_str()); SAFE_DELETE(m_pFile); return false; } if (m_flags & READ_BUFFERED) { if (m_pFile->GetChunkSize()) { m_pBuffer = new CFileStreamBuffer(0); m_pBuffer->Attach(m_pFile); } } m_bitStreamStats.Start(); return true; } #ifndef _LINUX catch (const win32_exception &e) { e.writelog(__FUNCTION__); } #endif catch(...) { CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__); } CLog::Log(LOGERROR, "%s - Error opening %s", __FUNCTION__, strFileName.c_str()); return false; }
void CMythSession::SetFileItemMetaData(CFileItem &item, cmyth_proginfo_t program) { if (!program) return; /* * Set the FileItem meta-data. */ std::string title = GetValue(m_dll->proginfo_title(program)); // e.g. Mythbusters std::string subtitle = GetValue(m_dll->proginfo_subtitle(program)); // e.g. The Pirate Special item.m_strTitle = title; if (!subtitle.empty()) item.m_strTitle += " - \"" + subtitle + "\""; // e.g. Mythbusters - "The Pirate Special" item.m_dateTime = GetValue(m_dll->proginfo_rec_start(program)); item.m_dwSize = m_dll->proginfo_length(program); // size in bytes /* * Set the VideoInfoTag meta-data so it matches the FileItem meta-data where possible. */ CVideoInfoTag* tag = item.GetVideoInfoTag(); tag->m_strTitle = subtitle; // The title is just supposed to be the episode title. tag->m_strShowTitle = title; tag->m_strOriginalTitle = title; tag->m_strPlotOutline = subtitle; tag->m_strPlot = GetValue(m_dll->proginfo_description(program)); /* * TODO: Strip out the subtitle from the description if it is present at the start? OR add the * subtitle to the start of the plot if not already as it used to? Seems strange, should be * handled by skin? * if (tag->m_strPlot.Left(tag->m_strPlotOutline.length()) != tag->m_strPlotOutline && !tag->m_strPlotOutline.empty()) tag->m_strPlot = tag->m_strPlotOutline + '\n' + tag->m_strPlot; */ tag->m_genre = StringUtils::Split(GetValue(m_dll->proginfo_category(program)), g_advancedSettings.m_videoItemSeparator); // e.g. Sports tag->m_strAlbum = GetValue(m_dll->proginfo_chansign(program)); // e.g. TV3 tag->m_duration = m_dll->proginfo_length_sec(program); SetSeasonAndEpisode(program, &tag->m_iSeason, &tag->m_iEpisode); /* * Original air date is used by the VideoInfoScanner to scrape the TV Show information into the * Video Library. If the original air date is empty the date returned will be the epoch. */ std::string originalairdate = GetValue(m_dll->proginfo_originalairdate(program)).GetAsDBDate(); if (originalairdate != "1970-01-01" && originalairdate != "1969-12-31") tag->m_firstAired.SetFromDateString(originalairdate); /* * Video sort title is the raw title with the date appended on the end in a sortable format so * when the "All Recordings" listing is sorted by "Name" rather than "Date", all of the episodes * for a given show are still presented in date order (even though some may have a subtitle that * would cause it to be shown in a different position if it was indeed strictly sorting by * what is displayed in the list). */ tag->m_strSortTitle = title + " " + item.m_dateTime.GetAsDBDateTime(); // e.g. Mythbusters 2009-12-13 12:23:14 /* * Set further FileItem and VideoInfoTag meta-data based on whether it is LiveTV or not. */ CURL url(item.GetPath()); if (StringUtils::StartsWith(url.GetFileName(), "channels/")) { /* * Prepend the channel number onto the FileItem title for the listing so it's clear what is * playing on each channel without using up as much room as the channel name. */ std::string number = GetValue(m_dll->proginfo_chanstr(program)); item.m_strTitle = number + " - " + item.m_strTitle; /* * Append the channel name onto the end of the tag title for the OSD so it's clear what LiveTV * channel is currently being watched to give some context for Next or Previous channel. Added * to the end so sorting by title will work, and it's not really as important as the title * within the OSD. */ std::string name = GetValue(m_dll->proginfo_chansign(program)); if (!name.empty()) tag->m_strTitle += " - " + name; /* * Set the sort title to be the channel number. */ tag->m_strSortTitle = number; /* * Set the status so XBMC treats the content as LiveTV. */ tag->m_strStatus = "livetv"; /* * Update the path and channel icon for LiveTV in case the channel has changed through * NextChannel(), PreviousChannel() or SetChannel(). */ if (!number.empty()) { url.SetFileName("channels/" + number + ".ts"); // e.g. channels/3.ts item.SetPath(url.Get()); } std::string chanicon = GetValue(m_dll->proginfo_chanicon(program)); if (!chanicon.empty()) { url.SetFileName("files/channels/" + URIUtils::GetFileName(chanicon)); // e.g. files/channels/tv3.jpg item.SetArt("thumb", url.Get()); } } else { /* * MythTV thumbnails aren't generated until a program has finished recording. */ if (m_dll->proginfo_rec_status(program) == RS_RECORDED) { url.SetFileName("files/" + URIUtils::GetFileName(GetValue(m_dll->proginfo_pathname(program))) + ".png"); item.SetArt("thumb", url.Get()); } } }
JSONRPC_STATUS CPlayerOperations::GetItem(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { PlayerType player = GetPlayer(parameterObject["playerid"]); CFileItemPtr fileItem; switch (player) { case Video: case Audio: { if (g_application.CurrentFileItem().GetLabel().empty()) { CFileItem tmpItem = g_application.CurrentFileItem(); if (IsPVRChannel()) { CPVRChannelPtr currentChannel; if (g_PVRManager.GetCurrentChannel(currentChannel)) tmpItem = CFileItem(*currentChannel.get()); } else if (player == Video) { if (!CVideoLibrary::FillFileItem(g_application.CurrentFile(), tmpItem)) { tmpItem = CFileItem(*g_infoManager.GetCurrentMovieTag()); tmpItem.SetPath(g_application.CurrentFileItem().GetPath()); } } else { if (!CAudioLibrary::FillFileItem(g_application.CurrentFile(), tmpItem)) { tmpItem = CFileItem(*g_infoManager.GetCurrentSongTag()); tmpItem.SetPath(g_application.CurrentFileItem().GetPath()); } } fileItem = CFileItemPtr(new CFileItem(tmpItem)); } else fileItem = CFileItemPtr(new CFileItem(g_application.CurrentFileItem())); if (player == Video && !IsPVRChannel()) { bool additionalInfo = false; for (CVariant::const_iterator_array itr = parameterObject["properties"].begin_array(); itr != parameterObject["properties"].end_array(); itr++) { CStdString fieldValue = itr->asString(); if (fieldValue == "cast" || fieldValue == "set" || fieldValue == "setid" || fieldValue == "showlink" || fieldValue == "resume") additionalInfo = true; } if (additionalInfo) { CVideoDatabase videodatabase; if (videodatabase.Open()) { switch (fileItem->GetVideoContentType()) { case VIDEODB_CONTENT_MOVIES: videodatabase.GetMovieInfo("", *(fileItem->GetVideoInfoTag()), fileItem->GetVideoInfoTag()->m_iDbId); break; case VIDEODB_CONTENT_MUSICVIDEOS: videodatabase.GetMusicVideoInfo("", *(fileItem->GetVideoInfoTag()), fileItem->GetVideoInfoTag()->m_iDbId); break; case VIDEODB_CONTENT_EPISODES: videodatabase.GetEpisodeInfo("", *(fileItem->GetVideoInfoTag()), fileItem->GetVideoInfoTag()->m_iDbId); break; case VIDEODB_CONTENT_TVSHOWS: case VIDEODB_CONTENT_MOVIE_SETS: default: break; } videodatabase.Close(); } } } break; } case Picture: { CGUIWindowSlideShow *slideshow = (CGUIWindowSlideShow*)g_windowManager.GetWindow(WINDOW_SLIDESHOW); if (!slideshow) return FailedToExecute; CFileItemList slides; slideshow->GetSlideShowContents(slides); fileItem = slides[slideshow->CurrentSlide() - 1]; break; } case None: default: return FailedToExecute; } HandleFileItem("id", !IsPVRChannel(), "item", fileItem, parameterObject, parameterObject["properties"], result, false); return OK; }
bool PAPlayer::QueueNextFileEx(const CFileItem &file, bool fadeIn/* = true */, bool job /* = false */) { StreamInfo *si = new StreamInfo(); // check if we advance a track of a CUE sheet // if this is the case we don't need to open a new stream std::string newURL = file.GetMusicInfoTag() ? file.GetMusicInfoTag()->GetURL() : file.GetPath(); std::string oldURL = m_FileItem->GetMusicInfoTag() ? m_FileItem->GetMusicInfoTag()->GetURL() : m_FileItem->GetPath(); if (newURL.compare(oldURL) == 0 && file.m_lStartOffset && file.m_lStartOffset == m_FileItem->m_lEndOffset && m_currentStream && m_currentStream->m_prepareTriggered) { m_continueStream = true; m_upcomingCrossfadeMS = 0; *m_FileItem = file; return true; } else { m_continueStream = false; } if (!si->m_decoder.Create(file, (file.m_lStartOffset * 1000) / 75)) { CLog::Log(LOGWARNING, "PAPlayer::QueueNextFileEx - Failed to create the decoder"); delete si; // advance playlist if (job) m_callback.OnPlayBackStarted(); m_callback.OnQueueNextItem(); return false; } /* decode until there is data-available */ si->m_decoder.Start(); while(si->m_decoder.GetDataSize() == 0) { int status = si->m_decoder.GetStatus(); if (status == STATUS_ENDED || status == STATUS_NO_FILE || si->m_decoder.ReadSamples(PACKET_SIZE) == RET_ERROR) { CLog::Log(LOGINFO, "PAPlayer::QueueNextFileEx - Error reading samples"); si->m_decoder.Destroy(); delete si; // advance playlist if (job) m_callback.OnPlayBackStarted(); m_callback.OnQueueNextItem(); return false; } /* yield our time so that the main PAP thread doesnt stall */ CThread::Sleep(1); } /* init the streaminfo struct */ si->m_decoder.GetDataFormat(&si->m_channelInfo, &si->m_sampleRate, &si->m_encodedSampleRate, &si->m_dataFormat); si->m_startOffset = file.m_lStartOffset * 1000 / 75; si->m_endOffset = file.m_lEndOffset * 1000 / 75; si->m_bytesPerSample = CAEUtil::DataFormatToBits(si->m_dataFormat) >> 3; si->m_bytesPerFrame = si->m_bytesPerSample * si->m_channelInfo.Count(); si->m_started = false; si->m_finishing = false; si->m_framesSent = 0; si->m_seekNextAtFrame = 0; si->m_seekFrame = -1; si->m_stream = NULL; si->m_volume = (fadeIn && m_upcomingCrossfadeMS) ? 0.0f : 1.0f; si->m_fadeOutTriggered = false; si->m_isSlaved = false; int64_t streamTotalTime = si->m_decoder.TotalTime(); if (si->m_endOffset) streamTotalTime = si->m_endOffset - si->m_startOffset; si->m_prepareNextAtFrame = 0; // cd drives don't really like it to be crossfaded or prepared if(!file.IsCDDA()) { if (streamTotalTime >= TIME_TO_CACHE_NEXT_FILE + m_defaultCrossfadeMS) si->m_prepareNextAtFrame = (int)((streamTotalTime - TIME_TO_CACHE_NEXT_FILE - m_defaultCrossfadeMS) * si->m_sampleRate / 1000.0f); } if (m_currentStream && (AE_IS_RAW(m_currentStream->m_dataFormat) || AE_IS_RAW(si->m_dataFormat))) { m_currentStream->m_prepareTriggered = false; m_currentStream->m_waitOnDrain = true; m_currentStream->m_prepareNextAtFrame = 0; si->m_decoder.Destroy(); delete si; return false; } UpdateCrossfadeTime(file); si->m_prepareTriggered = false; si->m_playNextAtFrame = 0; si->m_playNextTriggered = false; si->m_waitOnDrain = false; if (!PrepareStream(si)) { CLog::Log(LOGINFO, "PAPlayer::QueueNextFileEx - Error preparing stream"); si->m_decoder.Destroy(); delete si; // advance playlist if (job) m_callback.OnPlayBackStarted(); m_callback.OnQueueNextItem(); return false; } /* add the stream to the list */ CExclusiveLock lock(m_streamsLock); m_streams.push_back(si); //update the current stream to start playing the next track at the correct frame. UpdateStreamInfoPlayNextAtFrame(m_currentStream, m_upcomingCrossfadeMS); *m_FileItem = file; return true; }
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()); } }
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; }
// TODO: Currently no support for "embedded thumb" as there is no easy way to grab it // without sending a file that has this as it's album to this class void CGUIWindowMusicInfo::OnGetThumb() { CFileItemList items; // Grab the thumbnail from the web CStdString thumbFromWeb; CUtil::AddFileToFolder(g_advancedSettings.m_cachePath, "allmusicThumb", thumbFromWeb); int iDownloaded=DownloadThumbnail(thumbFromWeb,true); if (iDownloaded > 0) { for (int i=0;i<iDownloaded;++i) { CStdString strThumb; strThumb.Format("thumb://Remote%i",i); CFileItem *item = new CFileItem(strThumb, false); strThumb.Format("%s%i.tbn",thumbFromWeb,i); item->SetThumbnailImage(strThumb); item->SetLabel(g_localizeStrings.Get(20055)); items.Add(item); } } // Current thumb if (CFile::Exists(m_albumItem->GetThumbnailImage())) { CFileItem *item = new CFileItem("thumb://Current", false); item->SetThumbnailImage(m_albumItem->GetThumbnailImage()); item->SetLabel(g_localizeStrings.Get(20016)); items.Add(item); } // local thumb CStdString cachedLocalThumb; CStdString localThumb; if (m_bArtistInfo) { CMusicDatabase database; database.Open(); CStdString strArtistPath; database.GetArtistPath(m_artist.idArtist,strArtistPath); CUtil::AddFileToFolder(strArtistPath,"folder.jpg",localThumb); } else CStdString localThumb = m_albumItem->GetUserMusicThumb(); if (CFile::Exists(localThumb)) { CUtil::AddFileToFolder(g_advancedSettings.m_cachePath, "localthumb.jpg", cachedLocalThumb); CPicture pic; if (pic.DoCreateThumbnail(localThumb, cachedLocalThumb)) { CFileItem *item = new CFileItem("thumb://Local", false); item->SetThumbnailImage(cachedLocalThumb); item->SetLabel(g_localizeStrings.Get(20017)); items.Add(item); } } CFileItem *item = new CFileItem("thumb://None", false); if (m_bArtistInfo) item->SetThumbnailImage("defaultArtistBig.png"); else item->SetThumbnailImage("defaultAlbumCover.png"); item->SetLabel(g_localizeStrings.Get(20018)); items.Add(item); CStdString result; if (!CGUIDialogFileBrowser::ShowAndGetImage(items, g_settings.m_musicSources, g_localizeStrings.Get(1030), result)) return; // user cancelled if (result == "thumb://Current") return; // user chose the one they have // delete the thumbnail if that's what the user wants, else overwrite with the // new thumbnail CStdString cachedThumb; if (m_bArtistInfo) cachedThumb = m_albumItem->GetCachedArtistThumb(); else cachedThumb = CUtil::GetCachedAlbumThumb(m_album.strAlbum, m_album.strArtist); if (result == "thumb://None") { // cache the default thumb CPicture pic; pic.CacheSkinImage("defaultAlbumCover.png", cachedThumb); } else if (result.Left(14).Equals("thumb://Remote")) CFile::Cache(thumbFromWeb+result.Mid(14)+".tbn", cachedThumb); else if (result == "thumb://Local") CFile::Cache(cachedLocalThumb, cachedThumb); else if (CFile::Exists(result)) { CPicture pic; pic.DoCreateThumbnail(result, cachedThumb); } m_albumItem->SetThumbnailImage(cachedThumb); m_hasUpdatedThumb = true; // tell our GUI to completely reload all controls (as some of them // are likely to have had this image in use so will need refreshing) CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS); g_graphicsContext.SendMessage(msg); // Update our screen Update(); }
CFileItem *CGUIDialogAudioDSPManager::helper_CreateModeListItem(CActiveAEDSPModePtr &ModePointer, AE_DSP_MENUHOOK_CAT &MenuHook, int *ContinuesNo) { CFileItem *pItem = NULL; return pItem; if (!ContinuesNo) { return pItem; } // start to get Addon and Mode properties const int AddonID = ModePointer->AddonID(); std::string addonName; AE_DSP_ADDON addon; std::string modeName = g_localizeStrings.GetAddonString(addon->ID(), ModePointer->ModeName()); std::string description; if (ModePointer->ModeDescription() > -1) { description = g_localizeStrings.GetAddonString(addon->ID(), ModePointer->ModeDescription()); } else { description = g_localizeStrings.Get(15063); } bool isActive = ModePointer->IsEnabled(); int number = ModePointer->ModePosition(); int dialogId = helper_GetDialogId(ModePointer, MenuHook, addon, addonName); // end to get Addon and Mode properties if (isActive) { if (number <= 0) { number = *ContinuesNo; (*ContinuesNo)++; } std::string str = StringUtils::Format("%i:%i:%i:%s", number, AddonID, ModePointer->AddonModeNumber(), ModePointer->AddonModeName().c_str()); pItem = new CFileItem(str); } else { pItem = new CFileItem(modeName); } // set list item properties pItem->SetProperty("ActiveMode", isActive); pItem->SetProperty("Number", number); pItem->SetLabel(modeName); pItem->SetProperty("Description", description); pItem->SetProperty("Help", ModePointer->ModeHelp()); if (ModePointer->IconOwnModePath().empty()) pItem->SetIconImage("DefaultAddonAudioDSP.png"); else pItem->SetIconImage(ModePointer->IconOwnModePath()); pItem->SetProperty("SettingsDialog", dialogId); pItem->SetProperty("AddonId", AddonID); pItem->SetProperty("AddonModeNumber", ModePointer->AddonModeNumber()); pItem->SetLabel2(addonName); pItem->SetProperty("Changed", false); return pItem; }
CSong::CSong(CFileItem& item) { CMusicInfoTag& tag = *item.GetMusicInfoTag(); SYSTEMTIME stTime; tag.GetReleaseDate(stTime); strTitle = tag.GetTitle(); genre = tag.GetGenre(); std::vector<std::string> artist = tag.GetArtist(); std::vector<std::string> musicBrainzArtistHints = tag.GetMusicBrainzArtistHints(); strArtistDesc = tag.GetArtistString(); strArtistSort = tag.GetArtistSort(); m_strComposerSort = tag.GetComposerSort(); //Split the artist sort string to try and get sort names for individual artists std::vector<std::string> artistSort = StringUtils::Split(strArtistSort, g_advancedSettings.m_musicItemSeparator); if (!tag.GetMusicBrainzArtistID().empty()) { // Have musicbrainz artist info, so use it // Vector of possible separators in the order least likely to be part of artist name const std::vector<std::string> separators{ " feat. ", " ft. ", " Feat. "," Ft. ", ";", ":", "|", "#", "/", " with ", ",", "&" }; // Establish tag consistency - do the number of musicbrainz ids and number of names in hints or artist match if (tag.GetMusicBrainzArtistID().size() != musicBrainzArtistHints.size() && tag.GetMusicBrainzArtistID().size() != artist.size()) { // Tags mis-match - report it and then try to fix CLog::Log(LOGDEBUG, "Mis-match in song file tags: %i mbid %i names %s %s", (int)tag.GetMusicBrainzArtistID().size(), (int)artist.size(), strTitle.c_str(), strArtistDesc.c_str()); /* Most likely we have no hints and a single artist name like "Artist1 feat. Artist2" or "Composer; Conductor, Orchestra, Soloist" or "Artist1/Artist2" where the expected single item separator (default = space-slash-space) as not been used. Ampersand (&), comma and slash (no spaces) are poor delimiters as could be in name e.g. "AC/DC", "Earth, Wind & Fire", but here treat them as such in attempt to find artist names. When there are hints but count not match mbid they could be poorly formatted using unexpected separators so attempt to split them. Or we could have more hints or artist names than musicbrainz id so ignore them but raise warning. */ // Do hints exist yet mis-match if (musicBrainzArtistHints.size() > 0 && musicBrainzArtistHints.size() != tag.GetMusicBrainzArtistID().size()) { if (artist.size() == tag.GetMusicBrainzArtistID().size()) // Artist name count matches, use that as hints musicBrainzArtistHints = artist; else if (musicBrainzArtistHints.size() < tag.GetMusicBrainzArtistID().size()) { // Try splitting the hints until have matching number musicBrainzArtistHints = StringUtils::SplitMulti(musicBrainzArtistHints, separators, tag.GetMusicBrainzArtistID().size()); } else // Extra hints, discard them. musicBrainzArtistHints.resize(tag.GetMusicBrainzArtistID().size()); } // Do hints not exist or still mis-match, try artists if (musicBrainzArtistHints.size() != tag.GetMusicBrainzArtistID().size()) musicBrainzArtistHints = artist; // Still mis-match, try splitting the hints (now artists) until have matching number if (musicBrainzArtistHints.size() < tag.GetMusicBrainzArtistID().size()) { musicBrainzArtistHints = StringUtils::SplitMulti(musicBrainzArtistHints, separators, tag.GetMusicBrainzArtistID().size()); } } else { // Either hints or artist names (or both) matches number of musicbrainz id // If hints mis-match, use artists if (musicBrainzArtistHints.size() != tag.GetMusicBrainzArtistID().size()) musicBrainzArtistHints = tag.GetArtist(); } // Try to get number of artist sort names and musicbrainz ids to match. Split sort names // further using multiple possible delimiters, over single separator applied in Tag loader if (artistSort.size() != tag.GetMusicBrainzArtistID().size()) artistSort = StringUtils::SplitMulti(artistSort, { ";", ":", "|", "#" }); for (size_t i = 0; i < tag.GetMusicBrainzArtistID().size(); i++) { std::string artistId = tag.GetMusicBrainzArtistID()[i]; std::string artistName; /* We try and get the corresponding artist name from the hints list. Having already attempted to make the number of hints match, if they still don't then use musicbrainz id as the name and hope later on we can update that entry. */ if (i < musicBrainzArtistHints.size()) artistName = musicBrainzArtistHints[i]; else artistName = artistId; // Use artist sort name providing we have as many as we have mbid, // otherwise something is wrong with them so ignore and leave blank if (artistSort.size() == tag.GetMusicBrainzArtistID().size()) artistCredits.emplace_back(StringUtils::Trim(artistName), StringUtils::Trim(artistSort[i]), artistId); else artistCredits.emplace_back(StringUtils::Trim(artistName), "", artistId); } } else { // No musicbrainz artist ids, so fill in directly // Separate artist names further, if possible, and trim blank space. if (musicBrainzArtistHints.size() > tag.GetArtist().size()) // Make use of hints (ARTISTS tag), when present, to separate artist names artist = musicBrainzArtistHints; else // Split artist names further using multiple possible delimiters, over single separator applied in Tag loader artist = StringUtils::SplitMulti(artist, g_advancedSettings.m_musicArtistSeparators); if (artistSort.size() != artist.size()) // Split artist sort names further using multiple possible delimiters, over single separator applied in Tag loader artistSort = StringUtils::SplitMulti(artistSort, { ";", ":", "|", "#" }); for (size_t i = 0; i < artist.size(); i++) { artistCredits.emplace_back(StringUtils::Trim(artist[i])); // Set artist sort name providing we have as many as we have artists, // otherwise something is wrong with them so ignore rather than guess. if (artistSort.size() == artist.size()) artistCredits.back().SetSortName(StringUtils::Trim(artistSort[i])); } } strAlbum = tag.GetAlbum(); m_albumArtist = tag.GetAlbumArtist(); // Separate album artist names further, if possible, and trim blank space. if (tag.GetMusicBrainzAlbumArtistHints().size() > m_albumArtist.size()) // Make use of hints (ALBUMARTISTS tag), when present, to separate artist names m_albumArtist = tag.GetMusicBrainzAlbumArtistHints(); else // Split album artist names further using multiple possible delimiters, over single separator applied in Tag loader m_albumArtist = StringUtils::SplitMulti(m_albumArtist, g_advancedSettings.m_musicArtistSeparators); for (auto artistname : m_albumArtist) StringUtils::Trim(artistname); m_strAlbumArtistSort = tag.GetAlbumArtistSort(); strMusicBrainzTrackID = tag.GetMusicBrainzTrackID(); m_musicRoles = tag.GetContributors(); strComment = tag.GetComment(); strCueSheet = tag.GetCueSheet(); strMood = tag.GetMood(); rating = tag.GetRating(); userrating = tag.GetUserrating(); votes = tag.GetVotes(); iYear = stTime.wYear; iTrack = tag.GetTrackAndDiscNumber(); iDuration = tag.GetDuration(); strRecordLabel = tag.GetRecordLabel(); strAlbumType = tag.GetMusicBrainzReleaseType(); bCompilation = tag.GetCompilation(); embeddedArt = tag.GetCoverArtInfo(); strFileName = tag.GetURL().empty() ? item.GetPath() : tag.GetURL(); dateAdded = tag.GetDateAdded(); replayGain = tag.GetReplayGain(); strThumb = item.GetUserMusicThumb(true); iStartOffset = item.m_lStartOffset; iEndOffset = item.m_lEndOffset; idSong = -1; iTimesPlayed = 0; idAlbum = -1; }
CStdString CFavouritesDirectory::GetExecutePath(const CFileItem &item, const std::string &contextWindow) { CStdString execute; if (item.m_bIsFolder && (g_advancedSettings.m_playlistAsFolders || !(item.IsSmartPlayList() || item.IsPlayList()))) { if (!contextWindow.empty()) execute = StringUtils::Format("ActivateWindow(%s,%s,return)", contextWindow.c_str(), StringUtils::Paramify(item.GetPath()).c_str()); } /* TODO:STRING_CLEANUP */ else if (item.IsScript() && item.GetPath().size() > 9) // plugin://<foo> execute = StringUtils::Format("RunScript(%s)", StringUtils::Paramify(item.GetPath().substr(9)).c_str()); else if (item.IsAndroidApp() && item.GetPath().size() > 26) // androidapp://sources/apps/<foo> execute = StringUtils::Format("StartAndroidActivity(%s)", StringUtils::Paramify(item.GetPath().substr(26)).c_str()); else // assume a media file { if (item.IsVideoDb() && item.HasVideoInfoTag()) execute = StringUtils::Format("PlayMedia(%s)", StringUtils::Paramify(item.GetVideoInfoTag()->m_strFileNameAndPath).c_str()); else if (item.IsMusicDb() && item.HasMusicInfoTag()) execute = StringUtils::Format("PlayMedia(%s)", StringUtils::Paramify(item.GetMusicInfoTag()->GetURL()).c_str()); else execute = StringUtils::Format("PlayMedia(%s)", StringUtils::Paramify(item.GetPath()).c_str()); } return execute; }
// TODO: Currently no support for "embedded thumb" as there is no easy way to grab it // without sending a file that has this as it's album to this class void CGUIDialogSongInfo::OnGetThumb() { CFileItemList items; // Grab the thumbnail from the web CStdString thumbFromWeb; /* CUtil::AddFileToFolder(g_advancedSettings.m_cachePath, "allmusicThumb.jpg", thumbFromWeb); if (DownloadThumbnail(thumbFromWeb)) { CFileItem *item = new CFileItem("thumb://allmusic.com", false); item->SetThumbnailImage(thumbFromWeb); item->SetLabel(g_localizeStrings.Get(20055)); items.Add(item); }*/ // Current thumb if (CFile::Exists(m_song->GetThumbnailImage())) { CFileItem *item = new CFileItem("thumb://Current", false); item->SetThumbnailImage(m_song->GetThumbnailImage()); item->SetLabel(g_localizeStrings.Get(20016)); items.Add(item); } // local thumb CStdString cachedLocalThumb; CStdString localThumb(m_song->GetUserMusicThumb(true)); if (m_song->IsMusicDb()) { CFileItem item(m_song->GetMusicInfoTag()->GetURL(), false); localThumb = item.GetUserMusicThumb(true); } if (CFile::Exists(localThumb)) { CUtil::AddFileToFolder(g_advancedSettings.m_cachePath, "localthumb.jpg", cachedLocalThumb); CPicture pic; if (pic.DoCreateThumbnail(localThumb, cachedLocalThumb)) { CFileItem *item = new CFileItem("thumb://Local", false); item->SetThumbnailImage(cachedLocalThumb); item->SetLabel(g_localizeStrings.Get(20017)); items.Add(item); } } else { // no local thumb exists, so we are just using the allmusic.com thumb or cached thumb // which is probably the allmusic.com thumb. These could be wrong, so allow the user // to delete the incorrect thumb CFileItem *item = new CFileItem("thumb://None", false); item->SetThumbnailImage("defaultAlbumCover.png"); item->SetLabel(g_localizeStrings.Get(20018)); items.Add(item); } CStdString result; if (!CGUIDialogFileBrowser::ShowAndGetImage(items, g_settings.m_musicSources, g_localizeStrings.Get(1030), result)) return; // user cancelled if (result == "thumb://Current") return; // user chose the one they have // delete the thumbnail if that's what the user wants, else overwrite with the // new thumbnail CStdString cachedThumb(CUtil::GetCachedAlbumThumb(m_song->GetMusicInfoTag()->GetAlbum(), m_song->GetMusicInfoTag()->GetArtist())); if (result == "thumb://None") { // cache the default thumb CPicture pic; pic.CacheSkinImage("defaultAlbumCover.png", cachedThumb); } else if (result == "thumb://allmusic.com") CFile::Cache(thumbFromWeb, cachedThumb); else if (result == "thumb://Local") CFile::Cache(cachedLocalThumb, cachedThumb); else if (CFile::Exists(result)) { CPicture pic; pic.DoCreateThumbnail(result, cachedThumb); } m_song->SetThumbnailImage(cachedThumb); // tell our GUI to completely reload all controls (as some of them // are likely to have had this image in use so will need refreshing) CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS); g_graphicsContext.SendMessage(msg); // m_hasUpdatedThumb = true; }
void CGUIDialogPluginSettings::CreateControls() { CGUISpinControlEx *pOriginalSpin = (CGUISpinControlEx*)GetControl(CONTROL_DEFAULT_SPIN); CGUIRadioButtonControl *pOriginalRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_DEFAULT_RADIOBUTTON); CGUIButtonControl *pOriginalButton = (CGUIButtonControl *)GetControl(CONTROL_DEFAULT_BUTTON); CGUIImage *pOriginalImage = (CGUIImage *)GetControl(CONTROL_DEFAULT_SEPARATOR); if (!pOriginalSpin || !pOriginalRadioButton || !pOriginalButton || !pOriginalImage) return; pOriginalSpin->SetVisible(false); pOriginalRadioButton->SetVisible(false); pOriginalButton->SetVisible(false); pOriginalImage->SetVisible(false); // clear the category group CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(CONTROL_AREA); if (!group) return; // set our dialog heading SET_CONTROL_LABEL(CONTROL_HEADING_LABEL, m_strHeading); // Create our base path, used for type "fileenum" settings CStdString basepath = "Q:\\plugins\\"; CUtil::AddFileToFolder(basepath, m_url.GetHostName(), basepath); CUtil::AddFileToFolder(basepath, m_url.GetFileName(), basepath); // Replace the / at end, GetFileName() leaves a / at the end basepath.Replace("/", "\\"); CGUIControl* pControl = NULL; int controlId = CONTROL_START_CONTROL; TiXmlElement *setting = m_settings.GetPluginRoot()->FirstChildElement("setting"); while (setting) { const char *type = setting->Attribute("type"); const char *id = setting->Attribute("id"); CStdString values; if (setting->Attribute("values")) values = setting->Attribute("values"); CStdString lvalues; if (setting->Attribute("lvalues")) lvalues = setting->Attribute("lvalues"); CStdString entries; if (setting->Attribute("entries")) entries = setting->Attribute("entries"); CStdString label; if (setting->Attribute("label") && atoi(setting->Attribute("label")) > 0) label.Format("$LOCALIZE[%s]", setting->Attribute("label")); else label = setting->Attribute("label"); if (strcmpi(type, "text") == 0 || strcmpi(type, "ipaddress") == 0 || strcmpi(type, "integer") == 0 || strcmpi(type, "video") == 0 || strcmpi(type, "music") == 0 || strcmpi(type, "pictures") == 0 || strcmpi(type, "folder") == 0 || strcmpi(type, "programs") == 0 || strcmpi(type, "files") == 0 || strcmpi(type, "action") == 0) { pControl = new CGUIButtonControl(*pOriginalButton); if (!pControl) return; ((CGUIButtonControl *)pControl)->SettingsCategorySetTextAlign(XBFONT_CENTER_Y); ((CGUIButtonControl *)pControl)->SetLabel(label); if (id) ((CGUIButtonControl *)pControl)->SetLabel2(m_settings.Get(id)); } else if (strcmpi(type, "bool") == 0) { pControl = new CGUIRadioButtonControl(*pOriginalRadioButton); if (!pControl) return; ((CGUIRadioButtonControl *)pControl)->SetLabel(label); ((CGUIRadioButtonControl *)pControl)->SetSelected(m_settings.Get(id) == "true"); } else if (strcmpi(type, "enum") == 0 || strcmpi(type, "labelenum") == 0) { vector<CStdString> valuesVec; vector<CStdString> entryVec; pControl = new CGUISpinControlEx(*pOriginalSpin); if (!pControl) return; ((CGUISpinControlEx *)pControl)->SetText(label); if (!lvalues.IsEmpty()) CUtil::Tokenize(lvalues, valuesVec, "|"); else CUtil::Tokenize(values, valuesVec, "|"); if (!entries.IsEmpty()) CUtil::Tokenize(entries, entryVec, "|"); for (unsigned int i = 0; i < valuesVec.size(); i++) { int iAdd = i; if (entryVec.size() > i) iAdd = atoi(entryVec[i]); if (!lvalues.IsEmpty()) { CStdString replace = g_localizeStringsTemp.Get(atoi(valuesVec[i])); if (replace.IsEmpty()) replace = g_localizeStrings.Get(atoi(valuesVec[i])); ((CGUISpinControlEx *)pControl)->AddLabel(replace, iAdd); } else ((CGUISpinControlEx *)pControl)->AddLabel(valuesVec[i], iAdd); } if (strcmpi(type, "labelenum") == 0) { // need to run through all our settings and find the one that matches ((CGUISpinControlEx*) pControl)->SetValueFromLabel(m_settings.Get(id)); } else ((CGUISpinControlEx*) pControl)->SetValue(atoi(m_settings.Get(id))); } else if (strcmpi(type, "fileenum") == 0) { pControl = new CGUISpinControlEx(*pOriginalSpin); if (!pControl) return; ((CGUISpinControlEx *)pControl)->SetText(label); //find Folders... DIRECTORY::CHDDirectory directory; CFileItemList items; CStdString enumpath; CUtil::AddFileToFolder(basepath, values, enumpath); CStdString mask; if (setting->Attribute("mask")) mask = setting->Attribute("mask"); if (!mask.IsEmpty()) directory.SetMask(mask); directory.GetDirectory(enumpath, items); int iItem = 0; for (int i = 0; i < items.Size(); ++i) { CFileItem* pItem = items[i]; if ((mask.Equals("/") && pItem->m_bIsFolder) || !pItem->m_bIsFolder) { ((CGUISpinControlEx *)pControl)->AddLabel(pItem->GetLabel(), iItem); if (pItem->GetLabel().Equals(m_settings.Get(id))) ((CGUISpinControlEx *)pControl)->SetValue(iItem); iItem++; } } } else if (strcmpi(type, "sep") == 0 && pOriginalImage) pControl = new CGUIImage(*pOriginalImage); if (pControl) { pControl->SetWidth(group->GetWidth()); pControl->SetVisible(true); pControl->SetID(controlId); pControl->AllocResources(); group->AddControl(pControl); pControl = NULL; } setting = setting->NextSiblingElement("setting"); controlId++; } EnableControls(); }
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 CGUIWindowBoxeeWizardResolution::ShowResolutionsList(bool HD, XMode* selectedMode) { // Set either HD/SD according to the selected mode if (selectedMode != NULL) { CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), CONTROL_SD_HD, IsResolutionHD(*selectedMode) ? VALUE_HD : VALUE_SD); OnMessage(msg); } SET_CONTROL_VISIBLE(CONTROL_RESOLUTIONS); // Clear the list first CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_RESOLUTIONS); OnMessage(msgReset); for (unsigned int i = 0; i < m_resolutions.size(); i++) delete m_resolutions[i]; m_resolutions.clear(); m_resolutionNames.clear(); // Go over all the resolutions and display them int iSelectedItem = 0; XOutput output = GetCurrentOutput(); for (unsigned int i = 0; i < output.modes.size(); i++) { // skip modes with similar names (but different Hz) //if (i > 0 && output.modes[i].name == output.modes[i-1].name) // continue; if (IsResolutionHD(output.modes[i]) && IsResolutionValid(output.modes[i])) { CStdString name; name.Format("%s / %.0fHz", output.modes[i].name.c_str(), output.modes[i].hz); CFileItem *item = new CFileItem(name); item->SetProperty("resolutionName", output.modes[i].name); item->SetProperty("resolutionHz", (int) output.modes[i].hz); CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_RESOLUTIONS, 0, 0, item); OnMessage(msg); m_resolutions.push_back(item); CStdString resolutionName; resolutionName.Format("%s: %s @ %.2fHz", output.name.c_str(), output.modes[i].name, output.modes[i].hz); m_resolutionNames.push_back(resolutionName); CStdString modeHz; modeHz.Format("%.2f", output.modes[i].hz); CStdString selectedHz; selectedHz.Format("%.2f", selectedMode->hz); if (selectedMode != NULL && output.modes[i].name == selectedMode->name && modeHz == selectedHz) iSelectedItem = m_resolutions.size() - 1; } } CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), CONTROL_RESOLUTIONS, iSelectedItem); OnMessage(msg); CGUIListContainer *pList = (CGUIListContainer *)GetControl(CONTROL_RESOLUTIONS); if (pList) pList->SetSingleSelectedItem(); SET_CONTROL_FOCUS(CONTROL_RESOLUTIONS, 0); }
CStdString CThumbnailCache::GetAlbumThumb(const CFileItem &item) { return GetAlbumThumb(item.GetMusicInfoTag()); }