annotate src/track/media.cc @ 223:84e0a3c4737a

library: implement menu bar buttons I also went ahead and put the links from Taiga in so I don't have to worry about it later...
author Paper <mrpapersonic@gmail.com>
date Mon, 08 Jan 2024 16:54:16 -0500
parents 649786bae914
children d030b30526d5 2f5a9247e501
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"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2 #include "core/filesystem.h"
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
3 #include "core/strings.h"
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
4 #include "core/session.h"
189
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 171
diff changeset
5
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 171
diff changeset
6 #include <QFile>
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 171
diff changeset
7 #include <QTextStream>
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 171
diff changeset
8
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9 #include <string>
82
8b65c417c225 *: fix old stuff, make video players and extensions constants
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
10 #include <unordered_map>
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 #include <vector>
154
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 153
diff changeset
12 #include <filesystem>
189
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 171
diff changeset
13
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 171
diff changeset
14 #include "animia.h"
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16 namespace Track {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17 namespace Media {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18
138
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
19 static bool GetCurrentlyPlayingResults(std::vector<animia::Result>& results) {
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
20 std::vector<animia::Player> players;
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
21
147
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 139
diff changeset
22 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
23 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
24 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
25 players.push_back(player);
138
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
26
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
27 if (!animia::GetResults(players, results))
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
28 return false;
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
29
138
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
30 return true;
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
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
33 /* meh */
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
34 bool GetCurrentlyPlaying(std::vector<std::string>& vec) {
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
35 std::vector<animia::Result> results;
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
36
138
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
37 if (!GetCurrentlyPlayingResults(results))
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
38 return false;
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
39
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
40 bool success = false;
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
41
138
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
42 for (const auto& result : results) {
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
43 for (const auto& media : result.media) {
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
44 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
45 switch (info.type) {
154
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 153
diff changeset
46 case animia::MediaInfoType::File:
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 153
diff changeset
47 case animia::MediaInfoType::Title:
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 153
diff changeset
48 vec.push_back(std::filesystem::path(info.value).filename().string());
d43d68408d3c dep/animia: fix XnuFdTools
Paper <mrpapersonic@gmail.com>
parents: 153
diff changeset
49 success |= true;
171
03b444cbe55f graph: improve? drawing the text
Paper <mrpapersonic@gmail.com>
parents: 154
diff changeset
50 default:
03b444cbe55f graph: improve? drawing the text
Paper <mrpapersonic@gmail.com>
parents: 154
diff changeset
51 break;
153
bd439dd6ffc5 *: make win stuff actually work, rename bsd.cc to xnu.cc
Paper <mrpapersonic@gmail.com>
parents: 152
diff changeset
52 }
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
53 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
54 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
55 }
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
56
138
28842a8d0c6b dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
57 return success;
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
58 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
60 } // namespace Media
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
61 } // namespace Track