Mercurial > minori
annotate src/track/media.cc @ 229:adc20fa321c1
theme: force Fusion style on platforms other than Win32 or OS X
I was reluctant to do this, but most of the other styles just
look like pure shite regardless of whether I force a stylesheet
on them or not. KDE's style is actually hilariously bad paired
with my stylesheet, so I've decided to also make the stylesheet
Windows-specific as well, because that's really the only platform
where it makes sense in the first place.
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 10 Jan 2024 21:23:57 -0500 |
parents | 649786bae914 |
children | d030b30526d5 2f5a9247e501 |
rev | line source |
---|---|
64 | 1 #include "track/media.h" |
2 #include "core/filesystem.h" | |
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 | 5 |
6 #include <QFile> | |
7 #include <QTextStream> | |
8 | |
64 | 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 | 11 #include <vector> |
154 | 12 #include <filesystem> |
189 | 13 |
14 #include "animia.h" | |
64 | 15 |
16 namespace Track { | |
17 namespace Media { | |
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 | 46 case animia::MediaInfoType::File: |
47 case animia::MediaInfoType::Title: | |
48 vec.push_back(std::filesystem::path(info.value).filename().string()); | |
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 | 53 } |
54 } | |
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 | 58 } |
59 | |
60 } // namespace Media | |
61 } // namespace Track |