diff --git a/es-app/src/SystemScreenSaver.cpp b/es-app/src/SystemScreenSaver.cpp index b525fa8a1..592e2a185 100644 --- a/es-app/src/SystemScreenSaver.cpp +++ b/es-app/src/SystemScreenSaver.cpp @@ -50,17 +50,13 @@ SystemScreenSaver::SystemScreenSaver( mStopBackgroundAudio(true) { mWindow->setScreenSaver(this); - std::string path = getTitleFolder(); - if (!Utils::FileSystem::exists(path)) - Utils::FileSystem::createDirectory(path); + srand((unsigned int)time(nullptr)); mVideoChangeTime = 30000; } SystemScreenSaver::~SystemScreenSaver() { - // Delete subtitle file, if it exists. - remove(getTitlePath().c_str()); mCurrentGame = nullptr; delete mVideoScreensaver; delete mImageScreensaver; @@ -108,11 +104,11 @@ void SystemScreenSaver::startScreenSaver() #if defined(_RPI_) // Create the correct type of video component if (Settings::getInstance()->getBool("ScreenSaverOmxPlayer")) - mVideoScreensaver = new VideoPlayerComponent(mWindow, getTitlePath()); + mVideoScreensaver = new VideoPlayerComponent(mWindow); else - mVideoScreensaver = new VideoVlcComponent(mWindow, getTitlePath()); + mVideoScreensaver = new VideoVlcComponent(mWindow); #else - mVideoScreensaver = new VideoVlcComponent(mWindow, getTitlePath()); + mVideoScreensaver = new VideoVlcComponent(mWindow); #endif mVideoScreensaver->topWindow(true); @@ -332,12 +328,6 @@ void SystemScreenSaver::pickGameListNode(unsigned long index, mCurrentGame = (*itf); // End of getting FileData. - #if defined(_RPI_) - if (Settings::getInstance()->getString("ScreenSaverGameInfo") != "never") - writeSubtitle(mGameName.c_str(), mSystemName.c_str(), - (Settings::getInstance()->getString("ScreenSaverGameInfo") == - "always")); - #endif return; } } diff --git a/es-app/src/guis/GuiVideoScreensaverOptions.cpp b/es-app/src/guis/GuiVideoScreensaverOptions.cpp index 343763082..0f6d4fcad 100644 --- a/es-app/src/guis/GuiVideoScreensaverOptions.cpp +++ b/es-app/src/guis/GuiVideoScreensaverOptions.cpp @@ -42,45 +42,45 @@ GuiVideoScreensaverOptions::GuiVideoScreensaverOptions(Window* window, const cha addSaveFunc([ss_omx, this] { Settings::getInstance()-> setBool("ScreenSaverOmxPlayer", ss_omx->getState()); }); - // TEMPORARY - Disabled for now (except for RPI), need to find a proper way to make an - // overlay on top of the videos. The solution with rendering subtitles is not a good solution. + // TEMPORARY - Disabled for now, need to find a proper way to make an overlay on top of + // the videos. The solution with rendering subtitles is not a good solution. // And as well the VLC video player subtitles seem to be somehow broken. // Render video game name as subtitles. - auto ss_info = std::make_shared> - (mWindow,getHelpStyle(), "SHOW GAME INFO", false); - std::vector info_type; - info_type.push_back("always"); - info_type.push_back("start & end"); - info_type.push_back("never"); - for (auto it = info_type.cbegin(); it != info_type.cend(); it++) - ss_info->add(*it, *it, Settings::getInstance()->getString("ScreenSaverGameInfo") == *it); - addWithLabel("SHOW GAME INFO ON SCREENSAVER", ss_info); - addSaveFunc([ss_info, this] { Settings::getInstance()-> - setString("ScreenSaverGameInfo", ss_info->getSelected()); }); +// auto ss_info = std::make_shared> +// (mWindow,getHelpStyle(), "SHOW GAME INFO", false); +// std::vector info_type; +// info_type.push_back("always"); +// info_type.push_back("start & end"); +// info_type.push_back("never"); +// for (auto it = info_type.cbegin(); it != info_type.cend(); it++) +// ss_info->add(*it, *it, Settings::getInstance()->getString("ScreenSaverGameInfo") == *it); +// addWithLabel("SHOW GAME INFO ON SCREENSAVER", ss_info); +// addSaveFunc([ss_info, this] { Settings::getInstance()-> +// setString("ScreenSaverGameInfo", ss_info->getSelected()); }); - ComponentListRow row; +// ComponentListRow row; // Set subtitle position. - auto ss_omx_subs_align = std::make_shared> - (mWindow, getHelpStyle(), "GAME INFO ALIGNMENT", false); - std::vector align_mode; - align_mode.push_back("left"); - align_mode.push_back("center"); - for (auto it = align_mode.cbegin(); it != align_mode.cend(); it++) - ss_omx_subs_align->add(*it, *it, Settings::getInstance()-> - getString("SubtitleAlignment") == *it); - addWithLabel("GAME INFO ALIGNMENT", ss_omx_subs_align); - addSaveFunc([ss_omx_subs_align, this] { Settings::getInstance()-> - setString("SubtitleAlignment", ss_omx_subs_align->getSelected()); }); +// auto ss_omx_subs_align = std::make_shared> +// (mWindow, getHelpStyle(), "GAME INFO ALIGNMENT", false); +// std::vector align_mode; +// align_mode.push_back("left"); +// align_mode.push_back("center"); +// for (auto it = align_mode.cbegin(); it != align_mode.cend(); it++) +// ss_omx_subs_align->add(*it, *it, Settings::getInstance()-> +// getString("SubtitleAlignment") == *it); +// addWithLabel("GAME INFO ALIGNMENT", ss_omx_subs_align); +// addSaveFunc([ss_omx_subs_align, this] { Settings::getInstance()-> +// setString("SubtitleAlignment", ss_omx_subs_align->getSelected()); }); // Set font size. - auto ss_omx_font_size = std::make_shared(mWindow, 1.f, 64.f, 1.f, "h"); - ss_omx_font_size->setValue((float)(Settings::getInstance()->getInt("SubtitleSize"))); - addWithLabel("GAME INFO FONT SIZE", ss_omx_font_size); - addSaveFunc([ss_omx_font_size] { - int subSize = (int)Math::round(ss_omx_font_size->getValue()); - Settings::getInstance()->setInt("SubtitleSize", subSize); - }); +// auto ss_omx_font_size = std::make_shared(mWindow, 1.f, 64.f, 1.f, "h"); +// ss_omx_font_size->setValue((float)(Settings::getInstance()->getInt("SubtitleSize"))); +// addWithLabel("GAME INFO FONT SIZE", ss_omx_font_size); +// addSaveFunc([ss_omx_font_size] { +// int subSize = (int)Math::round(ss_omx_font_size->getValue()); +// Settings::getInstance()->setInt("SubtitleSize", subSize); +// }); #endif auto ss_video_audio = std::make_shared(mWindow); @@ -104,27 +104,6 @@ GuiVideoScreensaverOptions::GuiVideoScreensaverOptions(Window* window, const cha addSaveFunc([render_blur] { Settings::getInstance()-> setBool("ScreenSaverVideoBlur", render_blur->getState()); }); #endif - - #if defined(_RPI_) - // Define subtitle font. - auto ss_omx_font_file = std::make_shared(mWindow, "", - Font::get(FONT_SIZE_SMALL), 0x777777FF); - addEditableTextComponent(row, "PATH TO FONT FILE", ss_omx_font_file, - Settings::getInstance()->getString("SubtitleFont")); - addSaveFunc([ss_omx_font_file] { - Settings::getInstance()->setString("SubtitleFont", ss_omx_font_file->getValue()); - }); - - // Define subtitle italic font. - auto ss_omx_italic_font_file = std::make_shared(mWindow, "", - Font::get(FONT_SIZE_SMALL), 0x777777FF); - addEditableTextComponent(row, "PATH TO ITALIC FONT FILE", ss_omx_italic_font_file, - Settings::getInstance()->getString("SubtitleItalicFont")); - addSaveFunc([ss_omx_italic_font_file] { - Settings::getInstance()->setString("SubtitleItalicFont", - ss_omx_italic_font_file->getValue()); - }); - #endif } GuiVideoScreensaverOptions::~GuiVideoScreensaverOptions() diff --git a/es-app/src/views/gamelist/GridGameListView.cpp b/es-app/src/views/gamelist/GridGameListView.cpp index 1cbdf8712..bdad319dd 100644 --- a/es-app/src/views/gamelist/GridGameListView.cpp +++ b/es-app/src/views/gamelist/GridGameListView.cpp @@ -58,11 +58,11 @@ GridGameListView::GridGameListView( // Create the correct type of video window. #if defined(_RPI_) if (Settings::getInstance()->getBool("VideoOmxPlayer")) - mVideo = new VideoPlayerComponent(window, ""); + mVideo = new VideoPlayerComponent(window); else - mVideo = new VideoVlcComponent(window, getTitlePath()); + mVideo = new VideoVlcComponent(window); #else - mVideo = new VideoVlcComponent(window, getTitlePath()); + mVideo = new VideoVlcComponent(window); #endif mGrid.setPosition(mSize.x() * 0.1f, mSize.y() * 0.1f); diff --git a/es-app/src/views/gamelist/VideoGameListView.cpp b/es-app/src/views/gamelist/VideoGameListView.cpp index 89a316da6..b21a99188 100644 --- a/es-app/src/views/gamelist/VideoGameListView.cpp +++ b/es-app/src/views/gamelist/VideoGameListView.cpp @@ -59,11 +59,11 @@ VideoGameListView::VideoGameListView( // Create the correct type of video window. #if defined(_RPI_) if (Settings::getInstance()->getBool("VideoOmxPlayer")) - mVideo = new VideoPlayerComponent(window, ""); + mVideo = new VideoPlayerComponent(window); else - mVideo = new VideoVlcComponent(window, getTitlePath()); + mVideo = new VideoVlcComponent(window); #else - mVideo = new VideoVlcComponent(window, getTitlePath()); + mVideo = new VideoVlcComponent(window); #endif mList.setPosition(mSize.x() * (0.50f + padding), mList.getPosition().y()); @@ -262,7 +262,6 @@ void VideoGameListView::initMDValues() void VideoGameListView::updateInfoPanel() { FileData* file = (mList.size() == 0 || mList.isScrolling()) ? nullptr : mList.getSelected(); - Utils::FileSystem::removeFile(getTitlePath()); // If the game data has already been rendered to the info panel, then skip it this time. if (file == mLastUpdated) { diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index ec8f08382..3c5c6d2a4 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -191,11 +191,6 @@ void Settings::setDefaults() #if defined(_RPI_) // We're defaulting to OMX Player for full screen video on the Pi. mBoolMap["ScreenSaverOmxPlayer"] = true; - // Use OMX Player defaults. - mStringMap["SubtitleFont"] = "/usr/share/fonts/truetype/freefont/FreeSans.ttf"; - mStringMap["SubtitleItalicFont"] = "/usr/share/fonts/truetype/freefont/FreeSansOblique.ttf"; - mIntMap["SubtitleSize"] = 55; - mStringMap["SubtitleAlignment"] = "left"; #else mBoolMap["ScreenSaverOmxPlayer"] = false; #endif diff --git a/es-core/src/components/VideoComponent.cpp b/es-core/src/components/VideoComponent.cpp index af229132d..686cdea35 100644 --- a/es-core/src/components/VideoComponent.cpp +++ b/es-core/src/components/VideoComponent.cpp @@ -18,41 +18,6 @@ #define SCREENSAVER_FADE_IN_TIME 800 -std::string getTitlePath() { - std::string titleFolder = getTitleFolder(); - return titleFolder + "last_title.srt"; -} - -std::string getTitleFolder() { - std::string home = Utils::FileSystem::getHomePath(); - return home + "/.emulationstation/tmp/"; -} - -void writeSubtitle(const char* gameName, const char* systemName, bool always) -{ - FILE* file = fopen(getTitlePath().c_str(), "w"); - int end = static_cast((Settings::getInstance()-> - getInt("ScreenSaverSwapVideoTimeout") / (1000))); - - if (always) - fprintf(file, "1\n00:00:01,000 --> 00:00:%d,000\n", end); - else - fprintf(file, "1\n00:00:01,000 --> 00:00:08,000\n"); - - fprintf(file, "%s\n", gameName); - fprintf(file, "%s\n\n", systemName); - - if (!always) { - if (end > 12) - fprintf(file, "2\n00:00:%d,000 --> 00:00:%d,000\n%s\n%s\n", - end-4, end, gameName, systemName); - } - - fflush(file); - fclose(file); - file = nullptr; -} - void VideoComponent::setScreensaverMode(bool isScreensaver) { mScreensaverMode = isScreensaver; @@ -84,19 +49,12 @@ VideoComponent::VideoComponent( if (mWindow->getGuiStackSize() > 1) topWindow(false); - - std::string path = getTitleFolder(); - - if (!Utils::FileSystem::exists(path)) - Utils::FileSystem::createDirectory(path); } VideoComponent::~VideoComponent() { // Stop any currently running video. stopVideo(); - // Delete subtitle file, if existing. - remove(getTitlePath().c_str()); } void VideoComponent::onOriginChanged() diff --git a/es-core/src/components/VideoComponent.h b/es-core/src/components/VideoComponent.h index fff9eb4a0..554506bed 100644 --- a/es-core/src/components/VideoComponent.h +++ b/es-core/src/components/VideoComponent.h @@ -16,10 +16,6 @@ class TextureResource; -std::string getTitlePath(); -std::string getTitleFolder(); -void writeSubtitle(const char* gameName, const char* systemName, bool always); - class VideoComponent : public GuiComponent { // Structure that groups together the configuration of the video component. diff --git a/es-core/src/components/VideoPlayerComponent.cpp b/es-core/src/components/VideoPlayerComponent.cpp index 0ff8b94ef..9d1d77e30 100644 --- a/es-core/src/components/VideoPlayerComponent.cpp +++ b/es-core/src/components/VideoPlayerComponent.cpp @@ -25,10 +25,9 @@ public: int getVolume() const; }; -VideoPlayerComponent::VideoPlayerComponent(Window* window, std::string path) : +VideoPlayerComponent::VideoPlayerComponent(Window* window) : VideoComponent(window), - mPlayerPid(-1), - subtitlePath(path) + mPlayerPid(-1) { } @@ -176,45 +175,13 @@ void VideoPlayerComponent::startVideo() argv[8] = std::to_string(OMXVolume).c_str(); } - // Test if there's a path for possible subtitles, meaning we're a screensaver video. - if (!subtitlePath.empty()) { - // If we are rendering a screensaver. - // Check if we want to stretch the image. - if (Settings::getInstance()->getBool("ScreenSaverStretchVideos")) - argv[6] = "stretch"; - - if (Settings::getInstance()->getString("ScreenSaverGameInfo") != "never") { - // If we have chosen to render subtitles. - argv[15] = "--subtitles"; - argv[16] = subtitlePath.c_str(); - argv[17] = mPlayingVideoPath.c_str(); - argv[18] = "--font"; - argv[19] = Settings::getInstance()->getString("SubtitleFont").c_str(); - argv[20] = "--italic-font"; - argv[21] = Settings::getInstance()-> - getString("SubtitleItalicFont").c_str(); - argv[22] = "--font-size"; - argv[23] = std::to_string(Settings::getInstance()-> - getInt("SubtitleSize")).c_str(); - argv[24] = "--align"; - argv[25] = Settings::getInstance()-> - getString("SubtitleAlignment").c_str(); - } - else { - // If we have chosen NOT to render subtitles in the screensaver. - argv[15] = mPlayingVideoPath.c_str(); - } - } - else { - // If we are rendering a video gamelist. - if (!mTargetIsMax) - argv[6] = "stretch"; - argv[15] = mPlayingVideoPath.c_str(); - } + // If we are rendering a video gamelist. + if (!mTargetIsMax) + argv[6] = "stretch"; + argv[15] = mPlayingVideoPath.c_str(); argv[10] = Settings::getInstance()->getString("OMXAudioDev").c_str(); - //const char* argv[] = args; const char* env[] = { "LD_LIBRARY_PATH=/opt/vc/libs:/usr/lib/omxplayer", NULL }; // Redirect stdout. diff --git a/es-core/src/components/VideoPlayerComponent.h b/es-core/src/components/VideoPlayerComponent.h index d3bc43ec9..1243f5b98 100644 --- a/es-core/src/components/VideoPlayerComponent.h +++ b/es-core/src/components/VideoPlayerComponent.h @@ -17,7 +17,7 @@ void catch_child(int sig_num); class VideoPlayerComponent : public VideoComponent { public: - VideoPlayerComponent(Window* window, std::string path); + VideoPlayerComponent(Window* window); virtual ~VideoPlayerComponent(); void render(const Transform4x4f& parentTrans) override; @@ -41,7 +41,6 @@ private: private: pid_t mPlayerPid; - std::string subtitlePath; }; #endif // ES_CORE_COMPONENTS_VIDEO_PLAYER_COMPONENT_H diff --git a/es-core/src/components/VideoVlcComponent.cpp b/es-core/src/components/VideoVlcComponent.cpp index 47427b238..6b5e68362 100644 --- a/es-core/src/components/VideoVlcComponent.cpp +++ b/es-core/src/components/VideoVlcComponent.cpp @@ -50,14 +50,14 @@ static void display(void* /*data*/, void* /*id*/) { // Data to be displayed. } -VideoVlcComponent::VideoVlcComponent(Window* window, std::string subtitles) +VideoVlcComponent::VideoVlcComponent(Window* window) : VideoComponent(window), mMediaPlayer(nullptr), mContext({}) { // Get an empty texture for rendering the video. mTexture = TextureResource::get(""); // Make sure VLC has been initialized. - setupVLC(subtitles); + setupVLC(); } VideoVlcComponent::~VideoVlcComponent() @@ -209,23 +209,11 @@ void VideoVlcComponent::freeContext() } } -void VideoVlcComponent::setupVLC(std::string subtitles) +void VideoVlcComponent::setupVLC() { // If VLC hasn't been initialised yet then do it now. if (!mVLC) { - const char** args; - const char* newargs[] = { "--quiet", "--sub-file", subtitles.c_str() }; - const char* singleargs[] = { "--quiet" }; - int argslen = 0; - - if (!subtitles.empty()) { - argslen = sizeof(newargs) / sizeof(newargs[0]); - args = newargs; - } - else { - argslen = sizeof(singleargs) / sizeof(singleargs[0]); - args = singleargs; - } + const char* args[] = { "--quiet" }; #if defined(__APPLE__) // It's required to set the VLC_PLUGIN_PATH variable on macOS, or the libVLC @@ -237,7 +225,7 @@ void VideoVlcComponent::setupVLC(std::string subtitles) setenv("VLC_PLUGIN_PATH", "/Applications/VLC.app/Contents/MacOS/plugins/", 1); #endif - mVLC = libvlc_new(argslen, args); + mVLC = libvlc_new(1, args); } } @@ -319,7 +307,6 @@ void VideoVlcComponent::startVideo() libvlc_media_tracks_release(tracks, track_count); // Make sure we found a valid video track. - if ((mVideoWidth > 0) && (mVideoHeight > 0)) { PowerSaver::pause(); setupContext(); diff --git a/es-core/src/components/VideoVlcComponent.h b/es-core/src/components/VideoVlcComponent.h index e062b69f8..b86b097d1 100644 --- a/es-core/src/components/VideoVlcComponent.h +++ b/es-core/src/components/VideoVlcComponent.h @@ -36,9 +36,9 @@ class VideoVlcComponent : public VideoComponent }; public: - static void setupVLC(std::string subtitles); + static void setupVLC(); - VideoVlcComponent(Window* window, std::string subtitles); + VideoVlcComponent(Window* window); virtual ~VideoVlcComponent(); void render(const Transform4x4f& parentTrans) override;