Debian Codegraph @

src/playlist.hpp

raw
1 /*
2 * This file is part of Bino, a 3D video player.
3 *
4 * Copyright (C) 2022, 2023, 2024
5 * Martin Lambers <[email protected]>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #pragma once
22
23 #include <QLocale>
24 #include <QUrl>
25
26 #include "modes.hpp"
27
28
29 class PlaylistEntry
30 {
31 public:
32 static const int NoTrack = -2;
33 static const int DefaultTrack = -1;
34
35 QUrl url;
36 InputMode inputMode;
37 SurroundMode surroundMode;
38 int videoTrack;
39 int audioTrack;
40 int subtitleTrack;
41
42 PlaylistEntry();
43 PlaylistEntry(const QUrl& url,
44 InputMode inputMode = Input_Unknown,
45 SurroundMode surroundMode = Surround_Unknown,
46 int videoTrack = DefaultTrack,
47 int audioTrack = DefaultTrack,
48 int subtitleTrack = DefaultTrack);
49
50 bool noMedia() const;
51 QString optionsToString() const;
52 bool optionsFromString(const QString& s);
53 };
54
55
56 class Playlist : public QObject
57 {
58 Q_OBJECT
59
60 private:
61 QLocale::Language _preferredAudio;
62 QLocale::Language _preferredSubtitle;
63 bool _wantSubtitle;
64 LoopMode _loopMode;
65 WaitMode _waitMode;
66
67 QList<PlaylistEntry> _entries;
68 int _currentIndex;
69
70 void emitMediaChanged();
71
72 public:
73 Playlist();
74 static Playlist* instance();
75
76 QLocale::Language preferredAudio() const;
77 void setPreferredAudio(const QLocale::Language& lang);
78 QLocale::Language preferredSubtitle() const;
79 void setPreferredSubtitle(const QLocale::Language& lang);
80 bool wantSubtitle() const;
81 void setWantSubtitle(bool want);
82 QList<PlaylistEntry>& entries();
83 const QList<PlaylistEntry>& entries() const;
84
85 int length() const;
86 void append(const PlaylistEntry& entry);
87 void insert(int index, const PlaylistEntry& entry);
88 void remove(int index);
89 void clear();
90
91 LoopMode loopMode() const;
92 WaitMode waitMode() const;
93
94 bool save(const QString& fileName, QString& errStr) const;
95 bool load(const QString& fileName, QString& errStr);
96
97 public slots:
98 void start();
99 void stop();
100 void next();
101 void prev();
102 void setCurrentIndex(int index);
103 void setLoopMode(LoopMode loopMode);
104 void setWaitMode(WaitMode waitMode);
105 void setWaitModeAuto();
106
107 void mediaEnded();
108
109 signals:
110 void mediaChanged(PlaylistEntry entry);
111 };