5 #include <QApplication>
34 #define LASTPLAY_DELAY 15
56 setObjectName(
"MusicPlayer");
83 if (playmode.toLower() ==
"random")
85 else if (playmode.toLower() ==
"intelligent")
87 else if (playmode.toLower() ==
"album")
89 else if (playmode.toLower() ==
"artist")
95 if (repeatmode.toLower() ==
"track")
97 else if (repeatmode.toLower() ==
"all")
220 if (resumestring.toLower() ==
"off")
222 else if (resumestring.toLower() ==
"track")
266 QMutexLocker locker(
m_lock);
267 QSet<QObject*>::const_iterator it =
m_listeners.begin();
339 QString adevice, pdevice;
356 LOG(VB_GENERAL, LOG_ERR,
357 QString(
"MusicPlayer: Cannot open audio output device: %1").arg(adevice));
364 LOG(VB_GENERAL, LOG_ERR,
365 QString(
"MusicPlayer: Cannot open audio output device: %1").arg(adevice));
366 LOG(VB_GENERAL, LOG_ERR,
388 QMutexLocker locker(
m_lock);
450 if (currentTrack >= 0)
555 if (me->
Message().left(14) ==
"PLAYBACK_START")
558 QString hostname = me->
Message().mid(15);
567 else if (me->
Message().left(12) ==
"PLAYBACK_END")
571 QString hostname = me->
Message().mid(13);
576 "MusicBookmarkPosition", 0));
584 else if (me->
Message().left(13) ==
"MUSIC_COMMAND")
586 QStringList list = me->
Message().simplified().split(
' ');
590 if (list[2] ==
"PLAY")
592 else if (list[2] ==
"STOP")
594 else if (list[2] ==
"PAUSE")
596 else if (list[2] ==
"SET_VOLUME")
598 if (list.size() >= 3)
600 int volume = list[3].toInt();
601 if (volume >= 0 && volume <= 100)
605 else if (list[2] ==
"GET_VOLUME")
607 QString message = QString(
"MUSIC_CONTROL ANSWER %1 %2")
612 else if (list[2] ==
"PLAY_FILE")
614 int start = me->
Message().indexOf(
"'");
615 int end = me->
Message().lastIndexOf(
"'");
617 if (start != -1 && end != -1 && start != end)
625 LOG(VB_GENERAL, LOG_ERR,
626 QString(
"MusicPlayer: got invalid MUSIC_COMMAND "
627 "PLAY_FILE - %1").arg(me->
Message()));
629 else if (list[2] ==
"PLAY_URL")
631 if (list.size() == 4)
639 LOG(VB_GENERAL, LOG_ERR,
640 QString(
"MusicPlayer: got invalid MUSIC_COMMAND "
641 "PLAY_URL - %1").arg(me->
Message()));
643 else if (list[2] ==
"PLAY_TRACK")
645 if (list.size() == 4)
647 int trackID = list[3].toInt();
653 LOG(VB_GENERAL, LOG_ERR,
654 QString(
"MusicPlayer: got invalid MUSIC_COMMAND "
655 "PLAY_TRACK - %1").arg(me->
Message()));
657 else if (list[2] ==
"GET_METADATA")
662 mdataStr = QString(
"%1 by %2 from %3").arg(mdata->
Title()).arg(mdata->
Artist()).arg(mdata->
Album());
664 mdataStr =
"Unknown Track2";
666 QString message = QString(
"MUSIC_CONTROL ANSWER %1 %2")
673 LOG(VB_GENERAL, LOG_ERR,
674 QString(
"MusicPlayer: got unknown/invalid MUSIC_COMMAND "
677 else if (me->
Message().startsWith(
"MUSIC_SETTINGS_CHANGED"))
680 startdir = QDir::cleanPath(startdir);
681 if (!startdir.isEmpty() && !startdir.endsWith(
"/"))
688 else if (me->
Message().startsWith(
"MUSIC_METADATA_CHANGED"))
692 QStringList list = me->
Message().simplified().split(
' ');
693 if (list.size() == 2)
695 int songID = list[1].toInt();
719 LOG(VB_GENERAL, LOG_ERR, QString(
"Output Error - %1")
722 ShowOkPopup(QString(
"MythMusic has encountered the following error:\n%1")
730 QApplication::sendPostedEvents();
737 LOG(VB_GENERAL, LOG_ERR, QString(
"Decoder Error - %1")
739 ShowOkPopup(QString(
"MythMusic has encountered the following error:\n%1")
748 LOG(VB_GENERAL, LOG_ERR, QString(
"Output Error - %1")
751 ShowOkPopup(QString(
"MythMusic has encountered the following error:\n%1")
797 LOG(VB_GENERAL, LOG_NOTICE, QString(
"MusicPlayer: Updating track length was %1s, should be %2s")
891 for (
int x = 0;
x < list->count();
x++)
902 if (moveUp && whichTrack <= 0)
1004 if (miniplayer->
Create())
1025 LOG(VB_GENERAL, LOG_ERR,
1026 QString(
"MusicPlayer: asked to set the current track to an invalid track no. %1")
1069 if (m_currentTrack < m_currentPlaylist->getSongs().
size() - 1)
1136 int curTrackID = -1;
1145 if (curTrackID != -1)
1179 if (
GetMythDB()->GetNumSetting(
"AllowTagWriting", 0) == 1)
1298 map[
"volumemute"] =
isMuted() ? tr(
"%1% (Muted)",
"Zero Audio Volume").arg(
getVolume()) :
1300 map[
"volume"] = QString(
"%1").arg(
getVolume());
1301 map[
"volumepercent"] = QString(
"%1%").arg(
getVolume());
1302 map[
"mute"] =
isMuted() ? tr(
"Muted") :
"";
1352 QMutexLocker locker(
m_lock);
1353 QSet<QObject*>::const_iterator it =
m_listeners.begin();
1363 LOG(VB_PLAYBACK, LOG_INFO, QString (
"decoder handler is ready, decoding %1")
1378 QMutexLocker locker(
m_lock);
1379 QSet<QObject*>::const_iterator it =
m_listeners.begin();
1416 LOG(VB_PLAYBACK, LOG_ERR, QString(
"Cannot initialise decoder for %1")