Mercurial > minori
diff src/track/media.cc @ 138:28842a8d0c6b
dep/animia: huge refactor (again...)
but this time, it actually compiles! and it WORKS! (on win32... not sure about
other platforms...)
configuring players is still not supported: at some point I'll prune something
up...
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 12 Nov 2023 04:53:19 -0500 |
parents | 0a458cb26ff4 |
children | 478f3b366199 |
line wrap: on
line diff
--- a/src/track/media.cc Fri Nov 10 13:52:47 2023 -0500 +++ b/src/track/media.cc Sun Nov 12 04:53:19 2023 -0500 @@ -9,39 +9,51 @@ #include <unordered_map> #include <vector> #include <iostream> +#include <QFile> namespace Track { namespace Media { -std::vector<std::filesystem::path> GetCurrentlyPlayingFiles() { - /* getting all open files */ - std::vector<std::filesystem::path> ret; +static bool GetCurrentlyPlayingResults(std::vector<animia::Result>& results) { + std::vector<animia::Player> players; + + { + QFile f(":/players.anisthesia"); + if (!f.exists()) + return false; + + f.open(QFile::ReadOnly | QFile::Text); + QTextStream ts(&f); + + if (!animia::ParsePlayersData(Strings::ToUtf8String(ts.readAll()), players)) + return false; + } + + if (!animia::GetResults(players, results)) + return false; - std::vector<int> pids = Animia::get_all_pids(); - for (int pid : pids) { - for (const Types::MediaPlayer& player : session.recognition.players) { - if (!player.GetEnabled() || Animia::get_process_name(pid) != player.GetExecutable()) - continue; + return true; +} + +/* meh */ +bool GetCurrentlyPlaying(std::vector<std::string>& vec) { + std::vector<animia::Result> results; - for (const std::string& file : Animia::filter_system_files(Animia::get_open_files(pid))) { - const std::filesystem::path path(file); + if (!GetCurrentlyPlayingResults(results)) + return false; + + bool success = false; - for (const Types::MediaExtension& ext : session.recognition.extensions) - if (path.extension() == ext.GetExtension()) - ret.push_back(path); + for (const auto& result : results) { + for (const auto& media : result.media) { + for (const auto& info : media.information) { + vec.push_back(info.value); + success |= true; } } } - return ret; -} - -std::filesystem::path GetCurrentPlaying() { - /* getting all open files */ - std::vector<std::filesystem::path> paths = GetCurrentlyPlayingFiles(); - if (paths.size()) - return paths.at(0); - return std::filesystem::path(); + return success; } std::unordered_map<std::string, std::string> GetMapFromElements(const anitomy::Elements& elements) {