Go to the documentation of this file.
7 #include <QApplication>
51 result->m_msg =
new QString(*
m_msg);
84 if (QFileInfo(mdata->
Filename()).isAbsolute())
104 LOG(VB_PLAYBACK, LOG_INFO, QString(
"Track %1 = %2")
119 auto *str =
new QString(
e);
154 if (QFileInfo(entry->
File()).isAbsolute())
155 m_url = QUrl::fromLocalFile(entry->
File());
159 LOG(VB_PLAYBACK, LOG_INFO, QString(
"Now playing '%1'").
arg(
m_url.toString()));
162 if (
m_url.toString().endsWith(
".cda"))
178 LOG(VB_PLAYBACK, LOG_INFO, QString(
"DecoderHandler: Stopping decoder"));
208 if (event ==
nullptr)
219 auto *me =
dynamic_cast<MythEvent *
>(event);
222 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
223 QStringList tokens = me->
Message().split(
" ", QString::SkipEmptyParts);
225 QStringList tokens = me->Message().split(
" ", Qt::SkipEmptyParts);
228 if (tokens.isEmpty())
231 if (tokens[0] ==
"DOWNLOAD_FILE")
233 QStringList
args = me->ExtraDataList();
235 if (tokens[1] ==
"UPDATE")
238 else if (tokens[1] ==
"FINISHED")
240 QString downloadUrl =
args[0];
241 int fileSize =
args[2].toInt();
242 int errorCode =
args[4].toInt();
245 if ((errorCode != 0) || (fileSize == 0))
247 LOG(VB_GENERAL, LOG_ERR, QString(
"DecoderHandler: failed to download playlist from '%1'")
249 QUrl url(downloadUrl);
252 doFailed(url,
"Could not get playlist");
256 QUrl fileUrl = QUrl::fromLocalFile(
filename);
266 QString extension = QFileInfo(url.path()).suffix();
267 LOG(VB_NETWORK, LOG_INFO,
268 QString(
"File %1 has extension %2")
269 .
arg(QFileInfo(url.path()).fileName()).arg(extension));
271 if (extension ==
"pls" || extension ==
"m3u" || extension ==
"asx")
273 if (url.scheme() ==
"file" || QFileInfo(url.toString()).isAbsolute())
288 if (url.scheme() ==
"file" || QFileInfo(url.toString()).isAbsolute())
289 entry->
setFile(url.toLocalFile());
291 entry->setFile(url.toString());
300 QString
file = url.toLocalFile();
309 LOG(VB_NETWORK, LOG_INFO,
310 QString(
"Retrieving playlist from '%1'").
arg(url.toString()));
314 QString extension = QFileInfo(url.path()).suffix().toLower();
315 QString saveFilename =
GetConfDir() +
"/MythMusic/playlist." + extension;
323 if (time.hasExpired(30000))
327 LOG(VB_GENERAL, LOG_ERR, QString(
"DecoderHandler:: Timed out trying to download playlist from: %1")
328 .
arg(url.toString()));
332 QCoreApplication::processEvents();
349 doFailed(url, QString(
"No decoder for this format '%1'").
arg(format));
362 LOG(VB_NETWORK, LOG_ERR,
363 QString(
"DecoderHandler error: '%1' - %2").
arg(message).
arg(url.toString()));
virtual bool supports(const QString &source) const =0
static Type MythEventMessage
static Type OperationStart
void doConnectDecoder(const QUrl &url, const QString &format)
DecoderFactory * factory() const
MythEvent * clone(void) const override
PlayListFileEntry * get(int i)
Get a file entry.
This class is used as a container for messages.
void queueDownload(const QString &url, const QString &dest, QObject *caller, bool reload=false)
Adds a url to the download queue.
arg(title).arg(filename).arg(doDelete))
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void dispatch(const MythEvent &event)
Dispatch an event to all listeners.
~DecoderHandlerEvent() override
const QString & Message() const
void error(const QString &e)
Class for representing entries in a pls file.
Events sent by the DecoderHandler and it's helper classes.
void getBufferStatus(int *available, int *maxSize) const
static Decoder * create(const QString &source, AudioOutput *output, bool deletable=false)
virtual void unlock(void)
static int parse(PlayListFile *pls, const QString &filename)
Parse a pls, m3u or asx playlist file.
void createPlaylistForSingleFile(const QUrl &url)
void setFile(const QString &f)
void createPlaylist(const QUrl &url)
void cancelDownload(const QString &url, bool block=true)
Cancel a queued or current download.
void customEvent(QEvent *e) override
int size(void) const
Get the number of entries in the pls file.
void clear(void)
Clear out all the entries.
void setURL(const QString &url)
DecoderHandlerEvent(Type type)
void start(MusicMetadata *mdata)
void doOperationStop(void)
~DecoderHandler(void) override
static Type OperationStop
static long int random(void)
void doStart(bool result)
void doFailed(const QUrl &url, const QString &message)
void createPlaylistFromRemoteUrl(const QUrl &url)
bool isRunning(void) const
void add(PlayListFileEntry *e)
Add a entry to the playlist.
bool wait(unsigned long time=ULONG_MAX)
Wait for the MThread to exit, with a maximum timeout.
void doOperationStart(const QString &name)
void createPlaylistFromFile(const QUrl &url)
MythDownloadManager * GetMythDownloadManager(void)
Gets the pointer to the MythDownloadManager singleton.