Go to the documentation of this file.
7 #include <QApplication>
50 result->m_msg =
new QString(*
m_msg);
83 if (QFileInfo(mdata->
Filename()).isAbsolute())
103 LOG(VB_PLAYBACK, LOG_INFO, QString(
"Track %1 = %2")
118 auto *str =
new QString(e);
153 if (QFileInfo(entry->
File()).isAbsolute())
154 m_url = QUrl::fromLocalFile(entry->
File());
158 LOG(VB_PLAYBACK, LOG_INFO, QString(
"Now playing '%1'").arg(
m_url.toString()));
161 if (
m_url.toString().endsWith(
".cda"))
177 LOG(VB_PLAYBACK, LOG_INFO, QString(
"DecoderHandler: Stopping decoder"));
207 if (event ==
nullptr)
218 auto *me =
dynamic_cast<MythEvent *
>(event);
221 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
222 QStringList tokens = me->
Message().split(
" ", QString::SkipEmptyParts);
224 QStringList tokens = me->Message().split(
" ", Qt::SkipEmptyParts);
227 if (tokens.isEmpty())
230 if (tokens[0] ==
"DOWNLOAD_FILE")
232 QStringList
args = me->ExtraDataList();
234 if (tokens[1] ==
"UPDATE")
237 else if (tokens[1] ==
"FINISHED")
239 QString downloadUrl =
args[0];
240 int fileSize =
args[2].toInt();
241 int errorCode =
args[4].toInt();
244 if ((errorCode != 0) || (fileSize == 0))
246 LOG(VB_GENERAL, LOG_ERR, QString(
"DecoderHandler: failed to download playlist from '%1'")
248 QUrl url(downloadUrl);
251 doFailed(url,
"Could not get playlist");
255 QUrl fileUrl = QUrl::fromLocalFile(
filename);
265 QString extension = QFileInfo(url.path()).suffix();
266 LOG(VB_NETWORK, LOG_INFO,
267 QString(
"File %1 has extension %2")
268 .arg(QFileInfo(url.path()).fileName(), extension));
270 if (extension ==
"pls" || extension ==
"m3u" || extension ==
"asx")
272 if (url.scheme() ==
"file" || QFileInfo(url.toString()).isAbsolute())
287 if (url.scheme() ==
"file" || QFileInfo(url.toString()).isAbsolute())
288 entry->
setFile(url.toLocalFile());
290 entry->setFile(url.toString());
299 QString
file = url.toLocalFile();
308 LOG(VB_NETWORK, LOG_INFO,
309 QString(
"Retrieving playlist from '%1'").arg(url.toString()));
313 QString extension = QFileInfo(url.path()).suffix().toLower();
314 QString saveFilename =
GetConfDir() +
"/MythMusic/playlist." + extension;
322 if (time.hasExpired(30000))
326 LOG(VB_GENERAL, LOG_ERR, QString(
"DecoderHandler:: Timed out trying to download playlist from: %1")
327 .arg(url.toString()));
331 QCoreApplication::processEvents();
348 doFailed(url, QString(
"No decoder for this format '%1'").arg(format));
361 LOG(VB_NETWORK, LOG_ERR,
362 QString(
"DecoderHandler error: '%1' - %2").arg(message, url.toString()));
virtual bool supports(const QString &source) const =0
static const Type kMythEventMessage
void doConnectDecoder(const QUrl &url, const QString &format)
DecoderFactory * factory() const
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
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.
#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.
static const Type kOperationStart
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
static const Type kOperationStop
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
void doStart(bool result)
void doFailed(const QUrl &url, const QString &message)
static const Type kBufferStatus
void createPlaylistFromRemoteUrl(const QUrl &url)
bool isRunning(void) const
void add(PlayListFileEntry *e)
Add a entry to the playlist.
void doOperationStart(const QString &name)
void createPlaylistFromFile(const QUrl &url)
uint32_t MythRandom()
generate 32 random bits
MythDownloadManager * GetMythDownloadManager(void)
Gets the pointer to the MythDownloadManager singleton.