25#include "mediacontroller.h"
26#include "mediaobject.h"
27#include "addoninterface.h"
30#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
33#include <QStringDecoder>
36#include "frontendinterface_p.h"
38#ifndef QT_NO_PHONON_MEDIACONTROLLER
43class MediaControllerPrivate :
public FrontendInterfacePrivate
46 MediaControllerPrivate(MediaObject *mp) : FrontendInterfacePrivate(mp) {}
48 void backendObjectChanged(
QObject *)
override;
52MediaController::MediaController(MediaObject *mp)
54 , d(new MediaControllerPrivate(mp))
57 d->_backendObjectChanged();
58 setSubtitleAutodetect(
true);
61void MediaControllerPrivate::backendObjectChanged(
QObject *m_backendObject)
63 QObject::connect(m_backendObject, SIGNAL(availableSubtitlesChanged()), q, SIGNAL(availableSubtitlesChanged()));
64 QObject::connect(m_backendObject, SIGNAL(availableAudioChannelsChanged()), q, SIGNAL(availableAudioChannelsChanged()));
65 QObject::connect(m_backendObject, SIGNAL(titleChanged(
int)), q, SIGNAL(titleChanged(
int)));
66 QObject::connect(m_backendObject, SIGNAL(availableTitlesChanged(
int)), q, SIGNAL(availableTitlesChanged(
int)));
67 QObject::connect(m_backendObject, SIGNAL(chapterChanged(
int)), q, SIGNAL(chapterChanged(
int)));
68 QObject::connect(m_backendObject, SIGNAL(availableChaptersChanged(
int)), q, SIGNAL(availableChaptersChanged(
int)));
69 QObject::connect(m_backendObject, SIGNAL(angleChanged(
int)), q, SIGNAL(angleChanged(
int)));
70 QObject::connect(m_backendObject, SIGNAL(availableAnglesChanged(
int)), q, SIGNAL(availableAnglesChanged(
int)));
73MediaController::~MediaController()
79 AddonInterface *iface = d->iface(); \
82MediaController::Features MediaController::supportedFeatures()
const
84 if (!d || !d->media) {
89 if (iface->hasInterface(AddonInterface::AngleInterface)) {
92 if (iface->hasInterface(AddonInterface::ChapterInterface)) {
95 if (iface->hasInterface(AddonInterface::NavigationInterface)) {
98 if (iface->hasInterface(AddonInterface::TitleInterface)) {
101 if (iface->hasInterface(AddonInterface::SubtitleInterface)) {
104 if(iface->hasInterface(AddonInterface::AudioChannelInterface)) {
105 ret |= AudioChannels;
112int MediaController::availableAngles()
const
115 return iface->interfaceCall(AddonInterface::AngleInterface,
116 AddonInterface::availableAngles).toInt();
119int MediaController::currentAngle()
const
122 return iface->interfaceCall(AddonInterface::AngleInterface,
123 AddonInterface::angle).toInt();
126void MediaController::setCurrentAngle(
int titleNumber)
129 iface->interfaceCall(AddonInterface::AngleInterface,
135int MediaController::availableChapters()
const
138 return iface->interfaceCall(AddonInterface::ChapterInterface,
139 AddonInterface::availableChapters).toInt();
142int MediaController::currentChapter()
const
145 return iface->interfaceCall(AddonInterface::ChapterInterface,
146 AddonInterface::chapter).toInt();
149void MediaController::setCurrentChapter(
int titleNumber)
152 iface->interfaceCall(AddonInterface::ChapterInterface,
162 return tr(
"Main Menu");
164 return tr(
"Title Menu");
166 return tr(
"Audio Menu");
168 return tr(
"Subtitle Menu");
170 return tr(
"Chapter Menu");
172 return tr(
"Angle Menu");
182 iface->interfaceCall(AddonInterface::NavigationInterface,
191 iface->interfaceCall(AddonInterface::NavigationInterface,
196int MediaController::availableTitles()
const
199 return iface->interfaceCall(AddonInterface::TitleInterface,
200 AddonInterface::availableTitles).toInt();
203int MediaController::currentTitle()
const
206 return iface->interfaceCall(AddonInterface::TitleInterface,
207 AddonInterface::title).toInt();
210void MediaController::setCurrentTitle(
int titleNumber)
213 iface->interfaceCall(AddonInterface::TitleInterface,
217bool MediaController::autoplayTitles()
const
220 return iface->interfaceCall(AddonInterface::TitleInterface,
221 AddonInterface::autoplayTitles).toBool();
224void MediaController::setAutoplayTitles(
bool b)
227 iface->interfaceCall(AddonInterface::TitleInterface,
231void MediaController::nextTitle()
233 setCurrentTitle(currentTitle() + 1);
236void MediaController::previousTitle()
238 setCurrentTitle(currentTitle() - 1);
246 return iface->interfaceCall(AddonInterface::AudioChannelInterface,
250bool MediaController::subtitleAutodetect()
const
253 return iface->interfaceCall(AddonInterface::SubtitleInterface,
254 AddonInterface::subtitleAutodetect).toBool();
257void MediaController::setSubtitleAutodetect(
bool enable)
260 iface->interfaceCall(AddonInterface::SubtitleInterface,
264QString MediaController::subtitleEncoding()
const
267 return iface->interfaceCall(AddonInterface::SubtitleInterface,
268 AddonInterface::subtitleEncoding).toString();
271void MediaController::setSubtitleEncoding(
const QString &encoding)
274#if QT_VERSION <= QT_VERSION_CHECK(6, 0, 0)
275 if (!QTextCodec::availableCodecs().contains(encoding.
toLocal8Bit()))
281 iface->interfaceCall(AddonInterface::SubtitleInterface,
285void MediaController::setSubtitleFont(
const QFont &font)
288 iface->interfaceCall(AddonInterface::SubtitleInterface,
292QFont MediaController::subtitleFont()
const
295 return iface->interfaceCall(AddonInterface::SubtitleInterface,
296 AddonInterface::subtitleFont).value<
QFont>();
302 return iface->interfaceCall(AddonInterface::SubtitleInterface,
310 retList = iface->interfaceCall(AddonInterface::AudioChannelInterface,
319 retList = iface->interfaceCall(AddonInterface::SubtitleInterface,
320 AddonInterface::availableSubtitles)
328 iface->interfaceCall(AddonInterface::AudioChannelInterface,
335 iface->interfaceCall(AddonInterface::SubtitleInterface,
339void MediaController::setCurrentSubtitle(
const QUrl &url)
342 iface->interfaceCall(AddonInterface::SubtitleInterface,
352#include "moc_mediacontroller.cpp"
Provides a tuple of enduser visible name and description.
const char * constData() const const
T value(qsizetype i) const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QByteArray toLocal8Bit() const const
QByteArray toUtf8() const const
bool isValid() const const
QVariant fromValue(T &&value)