annotate src/track/media.cc @ 171:03b444cbe55f

graph: improve? drawing the text dark stylesheet: add borders on QMenu, taking inspiration from MPC-HC media: fix warning about missing enums
author Paper <mrpapersonic@gmail.com>
date Mon, 27 Nov 2023 13:51:27 -0500
parents d43d68408d3c
children 649786bae914
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include "track/media.h"
82
8b65c417c225 *: fix old stuff, make video players and extensions constants
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
2 #include "track/constants.h"
76
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
3 #include "animia.h"
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
4 #include "anitomy/anitomy.h"
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5 #include "core/filesystem.h"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include "core/strings.h"
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
7 #include "core/session.h"
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8 #include <string>
82
8b65c417c225 *: fix old stuff, make video players and extensions constants
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
9 #include <unordered_map>
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10 #include <vector>
154
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 153
diff changeset
11 #include <filesystem>
138
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
12 #include <QFile>
139
478f3b366199 dep/animia: separate lots of things, use base class for OS stuff
Paper <mrpapersonic@gmail.com>
parents: 138
diff changeset
13 #include <QTextStream>
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15 namespace Track {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16 namespace Media {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17
138
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
18 static bool GetCurrentlyPlayingResults(std::vector<animia::Result>& results) {
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
19 std::vector<animia::Player> players;
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
20
147
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 139
diff changeset
21 players.reserve(session.config.recognition.players.size());
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 139
diff changeset
22 for (const auto& [enabled, player] : session.config.recognition.players)
149
e41505d24733 players: filter out web browsers, they aren't even supported in animia yet
Paper <mrpapersonic@gmail.com>
parents: 147
diff changeset
23 if (enabled && player.type == animia::PlayerType::Default)
147
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 139
diff changeset
24 players.push_back(player);
138
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
25
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
26 if (!animia::GetResults(players, results))
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
27 return false;
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
28
138
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
29 return true;
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
30 }
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
31
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
32 /* meh */
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
33 bool GetCurrentlyPlaying(std::vector<std::string>& vec) {
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
34 std::vector<animia::Result> results;
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
35
138
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
36 if (!GetCurrentlyPlayingResults(results))
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
37 return false;
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
38
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
39 bool success = false;
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
40
138
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
41 for (const auto& result : results) {
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
42 for (const auto& media : result.media) {
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
43 for (const auto& info : media.information) {
153
bd439dd6ffc5 *: make win stuff actually work, rename bsd.cc to xnu.cc
Paper <mrpapersonic@gmail.com>
parents: 152
diff changeset
44 switch (info.type) {
154
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 153
diff changeset
45 case animia::MediaInfoType::File:
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 153
diff changeset
46 case animia::MediaInfoType::Title:
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 153
diff changeset
47 vec.push_back(std::filesystem::path(info.value).filename().string());
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 153
diff changeset
48 success |= true;
171
03b444cbe55f graph: improve? drawing the text
Paper <mrpapersonic@gmail.com>
parents: 154
diff changeset
49 default:
03b444cbe55f graph: improve? drawing the text
Paper <mrpapersonic@gmail.com>
parents: 154
diff changeset
50 break;
153
bd439dd6ffc5 *: make win stuff actually work, rename bsd.cc to xnu.cc
Paper <mrpapersonic@gmail.com>
parents: 152
diff changeset
51 }
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
52 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
53 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
54 }
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
55
138
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
56 return success;
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
57 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
58
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59 } // namespace Media
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
60 } // namespace Track