Advertisement
Guest User

XBMC Videos in picture slideshow

a guest
Sep 9th, 2010
751
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 12.26 KB | None | 0 0
  1. #P XBMC
  2. Index: xbmc/GUIWindowSlideShow.cpp
  3. ===================================================================
  4. --- xbmc/GUIWindowSlideShow.cpp    (revision 33608)
  5. +++ xbmc/GUIWindowSlideShow.cpp    (working copy)
  6. @@ -42,8 +42,11 @@
  7.  #include "utils/SingleLock.h"
  8.  #include "utils/log.h"
  9.  #include "utils/TimeUtils.h"
  10. +#include "PlayList.h"
  11.  
  12.  using namespace XFILE;
  13. +using namespace PLAYLIST;
  14. +
  15.  
  16.  #define MAX_ZOOM_FACTOR                     10
  17.  #define MAX_PICTURE_SIZE             2048*2048
  18. @@ -119,8 +122,9 @@
  19.        }
  20.      }
  21.    }
  22. -  CLog::Log(LOGDEBUG, "Time for loading %u images: %u ms, average %u ms",
  23. -            count, totalTime, totalTime / count);
  24. +  if (count > 0)
  25. +    CLog::Log(LOGDEBUG, "Time for loading %u images: %u ms, average %u ms",
  26. +              count, totalTime, totalTime / count);
  27.  }
  28.  
  29.  void CBackgroundPicLoader::LoadPic(int iPic, int iSlideNumber, const CStdString &strFileName, const int maxWidth, const int maxHeight)
  30. @@ -140,7 +144,7 @@
  31.    m_pBackgroundLoader = NULL;
  32.    m_slides = new CFileItemList;
  33.    m_Resolution = RES_INVALID;
  34. -  Reset();
  35. +    Reset();
  36.  }
  37.  
  38.  CGUIWindowSlideShow::~CGUIWindowSlideShow(void)
  39. @@ -160,6 +164,7 @@
  40.    g_infoManager.SetShowCodec(false);
  41.    m_bSlideShow = false;
  42.    m_bPause = false;
  43. +  m_bPlayingVideo = false;
  44.    m_bErrorMessage = false;
  45.    m_bReloadImage = false;
  46.    m_bScreensaver = false;
  47. @@ -173,6 +178,7 @@
  48.    CSingleLock lock(m_slideSection);
  49.    m_slides->Clear();
  50.    m_Resolution = g_graphicsContext.GetVideoResolution();
  51. +  m_strExtensions = g_settings.m_pictureExtensions;
  52.  }
  53.  
  54.  void CGUIWindowSlideShow::FreeResources()
  55. @@ -209,7 +215,6 @@
  56.    m_iNextSlide = m_iCurrentSlide + 1;
  57.    if (m_iNextSlide >= m_slides->Size())
  58.      m_iNextSlide = 0;
  59. -
  60.    m_bLoadNextPic = true;
  61.  }
  62.  
  63. @@ -290,7 +295,7 @@
  64.      m_pBackgroundLoader->Create(this);
  65.    }
  66.  
  67. -  bool bSlideShow = m_bSlideShow && !m_bPause;
  68. +  bool bSlideShow = m_bSlideShow && !m_bPause && !m_bPlayingVideo;
  69.  
  70.    if (m_bErrorMessage)
  71.    { // we have an error when loading either the current or next picture
  72. @@ -341,8 +346,9 @@
  73.      GetCheckedSize((float)g_settings.m_ResInfo[m_Resolution].iWidth * zoomamount[m_iZoomFactor - 1],
  74.                      (float)g_settings.m_ResInfo[m_Resolution].iHeight * zoomamount[m_iZoomFactor - 1],
  75.                      maxWidth, maxHeight);
  76. -    m_pBackgroundLoader->LoadPic(m_iCurrentPic, m_iCurrentSlide, m_slides->Get(m_iCurrentSlide)->m_strPath, maxWidth, maxHeight);
  77. -  }
  78. +    if (!m_slides->Get(m_iCurrentSlide)->IsVideo())
  79. +      m_pBackgroundLoader->LoadPic(m_iCurrentPic, m_iCurrentSlide, m_slides->Get(m_iCurrentSlide)->m_strPath, maxWidth, maxHeight);
  80. +    }
  81.  
  82.    // check if we should discard an already loaded next slide
  83.    if (m_bLoadNextPic && m_Image[1 - m_iCurrentPic].IsLoaded() && m_Image[1 - m_iCurrentPic].SlideNumber() != m_iNextSlide)
  84. @@ -384,7 +390,8 @@
  85.        GetCheckedSize((float)g_settings.m_ResInfo[m_Resolution].iWidth * zoomamount[m_iZoomFactor - 1],
  86.                       (float)g_settings.m_ResInfo[m_Resolution].iHeight * zoomamount[m_iZoomFactor - 1],
  87.                       maxWidth, maxHeight);
  88. -      m_pBackgroundLoader->LoadPic(1 - m_iCurrentPic, m_iNextSlide, m_slides->Get(m_iNextSlide)->m_strPath, maxWidth, maxHeight);
  89. +      if (!m_slides->Get(m_iNextSlide)->IsVideo())
  90. +        m_pBackgroundLoader->LoadPic(1 - m_iCurrentPic, m_iNextSlide, m_slides->Get(m_iNextSlide)->m_strPath, maxWidth, maxHeight);
  91.      }
  92.    }
  93.  
  94. @@ -395,7 +402,25 @@
  95.      m_Image[m_iCurrentPic].Pause(m_bPause);
  96.      m_Image[m_iCurrentPic].Render();
  97.    }
  98. +
  99. +  if (m_slides->Get(m_iCurrentSlide)->IsVideo() && bSlideShow)
  100. +  {
  101. +    CLog::Log(LOGDEBUG, "Playing slide %s as video", m_slides->Get(m_iCurrentSlide)->m_strPath.c_str());
  102. +    m_bPlayingVideo = true;
  103. +    g_playlistPlayer.Reset();
  104. +    g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO);
  105. +    CPlayList& playlist = g_playlistPlayer.GetPlaylist(PLAYLIST_VIDEO);
  106. +    playlist.Clear();
  107. +    playlist.Add(m_slides->Get(m_iCurrentSlide));
  108.  
  109. +    // play movie...
  110. +    g_playlistPlayer.Play(0);
  111. +    m_iCurrentSlide = m_iNextSlide;
  112. +    m_iNextSlide++;
  113. +    if (m_iNextSlide >= m_slides->Size())
  114. +      m_iNextSlide = 0;
  115. +  }
  116. +    
  117.    // Check if we should be transistioning immediately
  118.    if (m_bLoadNextPic)
  119.    {
  120. @@ -426,7 +451,6 @@
  121.        }
  122.      }
  123.    }
  124. -
  125.    // check if we should swap images now
  126.    if (m_Image[m_iCurrentPic].IsFinished())
  127.    {
  128. @@ -645,6 +669,24 @@
  129.        RunSlideShow(strFolder, bRecursive, bRandom, bNotRandom);
  130.      }
  131.      break;
  132. +    case GUI_MSG_PLAYLISTPLAYER_STOPPED:
  133. +    {
  134. +      m_bPlayingVideo = false;
  135. +      if (m_bSlideShow)
  136. +        g_windowManager.ActivateWindow(WINDOW_SLIDESHOW);
  137. +    }
  138. +    break;
  139. +    case GUI_MSG_PLAYBACK_STARTED:
  140. +    {
  141. +      g_windowManager.ActivateWindow(WINDOW_FULLSCREEN_VIDEO);
  142. +    }
  143. +    break;
  144. +    case GUI_MSG_PLAYBACK_STOPPED:
  145. +    {
  146. +      m_bSlideShow = false;
  147. +      g_windowManager.PreviousWindow();
  148. +    }
  149. +    break;
  150.    }
  151.    return CGUIWindow::OnMessage(message);
  152.  }
  153. @@ -778,7 +820,12 @@
  154.    return m_iCurrentSlide + 1;
  155.  }
  156.  
  157. -void CGUIWindowSlideShow::AddFromPath(const CStdString &strPath,
  158. +void CGUIWindowSlideShow::AddFromPath(const CStdString &strPath, bool bRecursive, SORT_METHOD method, SORT_ORDER order)
  159. +{
  160. +  AddFromPath(strPath, g_settings.m_pictureExtensions, bRecursive, method, order);
  161. +}
  162. +
  163. +void CGUIWindowSlideShow::AddFromPath(const CStdString &strPath, const CStdString &strExtensions,
  164.                                        bool bRecursive,
  165.                                        SORT_METHOD method, SORT_ORDER order)
  166.  {
  167. @@ -786,6 +833,7 @@
  168.    {
  169.      // reset the slideshow
  170.      Reset();
  171. +    m_strExtensions = strExtensions;
  172.      if (bRecursive)
  173.      {
  174.        path_set recursivePaths;
  175. @@ -796,13 +844,20 @@
  176.    }
  177.  }
  178.  
  179. -void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath, bool bRecursive /* = false */, bool bRandom /* = false */, bool bNotRandom /* = false */, SORT_METHOD method /* = SORT_METHOD_LABEL */, SORT_ORDER order /* = SORT_ORDER_ASC */)
  180. +void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath,
  181. +                                       bool bRecursive /* = false */, bool bRandom /* = false */,
  182. +                                       bool bNotRandom /* = false */, SORT_METHOD method /* = SORT_METHOD_LABEL */,
  183. +                                       SORT_ORDER order /* = SORT_ORDER_ASC */)
  184. +{
  185. +  RunSlideShow(strPath, g_settings.m_pictureExtensions, bRecursive, bRandom, bNotRandom, method, order);
  186. +}
  187. +void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath, const CStdString &strExtensions, bool bRecursive /* = false */, bool bRandom /* = false */, bool bNotRandom /* = false */, SORT_METHOD method /* = SORT_METHOD_LABEL */, SORT_ORDER order /* = SORT_ORDER_ASC */)
  188.  {
  189.    // stop any video
  190.    if (g_application.IsPlayingVideo())
  191.      g_application.StopPlaying();
  192.  
  193. -  AddFromPath(strPath, bRecursive, method, order);
  194. +  AddFromPath(strPath, strExtensions, bRecursive, method, order);
  195.  
  196.    // mutually exclusive options
  197.    // if both are set, clear both and use the gui setting
  198. @@ -832,7 +887,7 @@
  199.  
  200.    // fetch directory and sort accordingly
  201.    CFileItemList items;
  202. -  if (!CDirectory::GetDirectory(strPath, items, g_settings.m_pictureExtensions,false,false,DIR_CACHE_ONCE,true,true))
  203. +  if (!CDirectory::GetDirectory(strPath, items, m_strExtensions,false,false,DIR_CACHE_ONCE,true,true))
  204.      return;
  205.  
  206.    items.Sort(method, order);
  207. Index: xbmc/GUIWindowSlideShow.h
  208. ===================================================================
  209. --- xbmc/GUIWindowSlideShow.h    (revision 33608)
  210. +++ xbmc/GUIWindowSlideShow.h    (working copy)
  211. @@ -71,6 +71,10 @@
  212.    void Select(const CStdString& strPicture);
  213.    const CFileItemList &GetSlideShowContents();
  214.    const CFileItemPtr GetCurrentSlide();
  215. +  void RunSlideShow(const CStdString &strPath, const CStdString &strExtensions, bool bRecursive = false,
  216. +                    bool bRandom = false, bool bNotRandom = false,
  217. +                    SORT_METHOD method = SORT_METHOD_LABEL,
  218. +                    SORT_ORDER order = SORT_ORDER_ASC);
  219.    void RunSlideShow(const CStdString &strPath, bool bRecursive = false,
  220.                      bool bRandom = false, bool bNotRandom = false,
  221.                      SORT_METHOD method = SORT_METHOD_LABEL,
  222. @@ -78,6 +82,9 @@
  223.    void AddFromPath(const CStdString &strPath, bool bRecursive,
  224.                     SORT_METHOD method=SORT_METHOD_LABEL,
  225.                     SORT_ORDER order=SORT_ORDER_ASC);
  226. +  void AddFromPath(const CStdString &strPath, const CStdString &strExtensions, bool bRecursive,
  227. +                   SORT_METHOD method=SORT_METHOD_LABEL,
  228. +                   SORT_ORDER order=SORT_ORDER_ASC);
  229.    void StartSlideShow(bool screensaver=false);
  230.    bool InSlideShow() const;
  231.    virtual bool OnMessage(CGUIMessage& message);
  232. @@ -88,6 +95,7 @@
  233.    int NumSlides() const;
  234.    int CurrentSlide() const;
  235.    void Shuffle();
  236. +  void setExtensions(CStdString strExtensions);
  237.  private:
  238.    typedef std::set<CStdString> path_set;  // set to track which paths we're adding
  239.    void AddItems(const CStdString &strPath, path_set *recursivePaths,
  240. @@ -108,6 +116,7 @@
  241.    bool m_bSlideShow;
  242.    bool m_bScreensaver;
  243.    bool m_bPause;
  244. +  bool m_bPlayingVideo;
  245.    bool m_bErrorMessage;
  246.  
  247.    CFileItemList* m_slides;
  248. @@ -123,4 +132,5 @@
  249.    DllImageLib m_ImageLib;
  250.    RESOLUTION m_Resolution;
  251.    CCriticalSection m_slideSection;
  252. +  CStdString m_strExtensions;
  253.  };
  254. Index: xbmc/GUIWindowPictures.cpp
  255. ===================================================================
  256. --- xbmc/GUIWindowPictures.cpp    (revision 33608)
  257. +++ xbmc/GUIWindowPictures.cpp    (working copy)
  258. @@ -342,10 +342,26 @@
  259.  {
  260.    CGUIWindowSlideShow *pSlideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
  261.    if (pSlideShow)
  262. -    pSlideShow->RunSlideShow(strPicture, true,
  263. -                             g_guiSettings.GetBool("slideshow.shuffle"),false,
  264. -                             m_guiState->GetSortMethod(),
  265. -                             m_guiState->GetSortOrder());
  266. +  {  
  267. +      CStdString strExtensions = "";
  268. +    CFileItemList items;
  269. +    CGUIViewState* viewState=CGUIViewState::GetViewState(GetID(), items);
  270. +    if (viewState)
  271. +    {
  272. +      strExtensions = viewState->GetExtensions();
  273. +      delete viewState;
  274. +    }
  275. +    if (strExtensions.Equals("", false))
  276. +      pSlideShow->RunSlideShow(strPicture, true,
  277. +                               g_guiSettings.GetBool("slideshow.shuffle"),false,
  278. +                               m_guiState->GetSortMethod(),
  279. +                               m_guiState->GetSortOrder());
  280. +    else
  281. +      pSlideShow->RunSlideShow(strPicture, strExtensions, true,
  282. +                               g_guiSettings.GetBool("slideshow.shuffle"),false,
  283. +                               m_guiState->GetSortMethod(),
  284. +                               m_guiState->GetSortOrder());
  285. +  }
  286.  }
  287.  
  288.  void CGUIWindowPictures::OnSlideShowRecursive()
  289. @@ -363,9 +379,24 @@
  290.  {
  291.    CGUIWindowSlideShow *pSlideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
  292.    if (pSlideShow)
  293. -    pSlideShow->RunSlideShow(strPicture, false ,false, false,
  294. -                             m_guiState->GetSortMethod(),
  295. -                             m_guiState->GetSortOrder());
  296. +  {    
  297. +      CStdString strExtensions = "";
  298. +    CFileItemList items;
  299. +    CGUIViewState* viewState=CGUIViewState::GetViewState(GetID(), items);
  300. +    if (viewState)
  301. +    {
  302. +      strExtensions = viewState->GetExtensions();
  303. +      delete viewState;
  304. +    }
  305. +    if (strExtensions.Equals("", false))
  306. +      pSlideShow->RunSlideShow(strPicture, false ,false, false,
  307. +                               m_guiState->GetSortMethod(),
  308. +                               m_guiState->GetSortOrder());
  309. +    else
  310. +      pSlideShow->RunSlideShow(strPicture, strExtensions, false ,false, false,
  311. +                               m_guiState->GetSortMethod(),
  312. +                               m_guiState->GetSortOrder());
  313. +  }
  314.  }
  315.  
  316.  void CGUIWindowPictures::OnRegenerateThumbs()
  317. @@ -495,7 +526,6 @@
  318.        return;
  319.      if (g_application.IsPlayingVideo())
  320.        g_application.StopPlaying();
  321. -
  322.      // convert playlist items into slideshow items
  323.      pSlideShow->Reset();
  324.      for (int i = 0; i < (int)playlist.size(); ++i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement