From d7a53e2f805997f90726538fac9f66c95e7f3350 Mon Sep 17 00:00:00 2001 From: Tobias Contreras Date: Sat, 6 May 2023 11:07:05 -0700 Subject: [PATCH] make reloadableVideo support type=playlist(#) videos and fix destroying video if within the same playlist --- RetroFE/Source/Graphics/Component/Component.h | 3 +-- .../Graphics/Component/ReloadableMedia.cpp | 22 +++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/Component.h b/RetroFE/Source/Graphics/Component/Component.h index 83ac986a4..90fe7307a 100644 --- a/RetroFE/Source/Graphics/Component/Component.h +++ b/RetroFE/Source/Graphics/Component/Component.h @@ -65,12 +65,11 @@ class Component virtual void setText(std::string text, int id = -1) {}; virtual void setImage(std::string filePath, int id = -1) {}; int getId( ); + std::string playlistName; protected: Page &page; - std::string playlistName; - private: bool animate(); diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp index 658470d6f..abfe19614 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp @@ -117,13 +117,19 @@ void ReloadableMedia::freeGraphicsMemory() void ReloadableMedia::reloadTexture() { + std::string typeLC = Utils::toLower(type_); + Item* selectedItem = page.getSelectedItem(displayOffset_); + if(loadedComponent_) { - delete loadedComponent_; - loadedComponent_ = NULL; + // delete image/video/text if no selected Item, or if not a playlist type or playlists are different + if (!selectedItem || !(typeLC.rfind("playlist", 0) == 0 && (page.getPlaylistName() == loadedComponent_->playlistName))) + { + delete loadedComponent_; + loadedComponent_ = NULL; + } } - Item *selectedItem = page.getSelectedItem(displayOffset_); if(!selectedItem) return; config_.getProperty("currentCollection", currentCollection_); @@ -138,7 +144,6 @@ void ReloadableMedia::reloadTexture() names.push_back(selectedItem->cloneof); } - std::string typeLC = Utils::toLower(type_); if (typeLC == "isfavorite") { if (selectedItem->isFavorite) @@ -169,6 +174,13 @@ void ReloadableMedia::reloadTexture() for(unsigned int n = 0; n < names.size() && !loadedComponent_; ++n) { std::string basename = names[n]; + + // support reloadable video based on playlist# type + if (basename != "default" && typeLC.rfind("playlist", 0) == 0) + { + basename = page.getPlaylistName(); + } + if(systemMode_) { @@ -229,6 +241,7 @@ void ReloadableMedia::reloadTexture() if(loadedComponent_) { + loadedComponent_->playlistName = page.getPlaylistName(); loadedComponent_->allocateGraphicsMemory(); baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth; baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight; @@ -404,6 +417,7 @@ void ReloadableMedia::reloadTexture() if (loadedComponent_ != NULL) { + loadedComponent_->playlistName = page.getPlaylistName(); loadedComponent_->allocateGraphicsMemory(); baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth; baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;