Mercurial > minori
view src/track/media.cc @ 198:bc1ae1810855
dep/animia: switch from using classes to global functions
the old idea was ok, but sort of hackish; this method doesn't use classes
at all, and this way (especially important!) we can do wayland stuff AND x11
at the same time, which wasn't really possible without stupid workarounds in
the other method
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 24 Dec 2023 02:59:42 -0500 |
parents | 649786bae914 |
children | d030b30526d5 2f5a9247e501 |
line wrap: on
line source
#include "track/media.h" #include "core/filesystem.h" #include "core/strings.h" #include "core/session.h" #include <QFile> #include <QTextStream> #include <string> #include <unordered_map> #include <vector> #include <filesystem> #include "animia.h" namespace Track { namespace Media { static bool GetCurrentlyPlayingResults(std::vector<animia::Result>& results) { std::vector<animia::Player> players; players.reserve(session.config.recognition.players.size()); for (const auto& [enabled, player] : session.config.recognition.players) if (enabled && player.type == animia::PlayerType::Default) players.push_back(player); if (!animia::GetResults(players, results)) return false; return true; } /* meh */ bool GetCurrentlyPlaying(std::vector<std::string>& vec) { std::vector<animia::Result> results; if (!GetCurrentlyPlayingResults(results)) return false; bool success = false; for (const auto& result : results) { for (const auto& media : result.media) { for (const auto& info : media.information) { switch (info.type) { case animia::MediaInfoType::File: case animia::MediaInfoType::Title: vec.push_back(std::filesystem::path(info.value).filename().string()); success |= true; default: break; } } } } return success; } } // namespace Media } // namespace Track