Go to the documentation of this file.
9 #include <QApplication>
10 #include <QScopedPointer>
57 static QString chooseCD(
void)
76 QString sql =
"SELECT DISTINCT hostname "
78 "WHERE groupname = 'Music'";
89 if (hostList.isEmpty())
91 ShowOkPopup(QCoreApplication::translate(
"(MythMusicMain)",
92 "No directories found in the 'Music' storage group. "
93 "Please run mythtv-setup on the backend machine to add one."));
99 sql =
"SELECT DISTINCT hostname "
101 "WHERE groupname = 'MusicArt'";
112 if (hostList.isEmpty())
114 ShowOkPopup(QCoreApplication::translate(
"(MythMusicMain)",
115 "No directories found in the 'MusicArt' storage group. "
116 "Please run mythtv-setup on the backend machine to add one."));
127 bool foundMusic =
false;
128 if (count_query.
exec(
"SELECT COUNT(*) FROM music_songs;"))
130 if(count_query.
next() &&
131 0 != count_query.
value(0).toInt())
139 ShowOkPopup(QCoreApplication::translate(
"(MythMusicMain)",
140 "No music has been found.\n"
141 "Please select 'Scan For New Music' "
142 "to perform a scan for music."));
171 auto *view =
new StreamView(mainStack,
nullptr);
199 #if defined HAVE_CDIO
207 auto *rip =
new Ripper(mainStack, chooseCD());
214 Qt::QueuedConnection);
220 ShowOkPopup(QCoreApplication::translate(
"(MythMusicMain)",
221 "MythMusic hasn't been built with libcdio "
222 "support so ripping CDs is not possible"));
231 LOG(VB_GENERAL, LOG_INFO,
"Scanning for music files");
247 if (import->Create())
252 Qt::QueuedConnection);
266 QString sel = selection.toLower();
267 if (sel ==
"music_create_playlist")
269 else if (sel ==
"music_play")
271 else if (sel ==
"stream_play")
273 else if (sel ==
"music_rip")
277 else if (sel ==
"music_import")
281 else if (sel ==
"settings_scan")
285 else if (sel ==
"settings_general")
295 else if (sel ==
"settings_player")
305 else if (sel ==
"settings_rating")
315 else if (sel ==
"settings_visualization")
326 else if (sel ==
"settings_import")
355 auto *
menu = qobject_cast<MythThemedMenu *>(parentObject);
357 if (
menu &&
menu->objectName() ==
"mainmenu")
363 parentObject = parentObject->parent();
377 if (diag->foundTheme())
386 LOG(VB_GENERAL, LOG_ERR, QString(
"Couldn't find menu %1 or theme %2")
417 #if defined HAVE_CDIO
420 auto *rip =
new Ripper(mainStack, chooseCD());
432 Qt::QueuedConnection);
449 filt.replace(
".",
"*.");
450 return filt.split(
'|');
461 d.setNameFilters(filters);
462 d.setFilter(QDir::Files | QDir::AllDirs |
463 QDir::NoSymLinks | QDir::Readable |
464 QDir::NoDotAndDotDot);
465 d.setSorting(QDir::Name | QDir::DirsLast);
467 QFileInfoList list =
d.entryInfoList();
471 for (
const auto & fi : qAsConst(list))
476 QCoreApplication::processEvents();
480 ret << fi.absoluteFilePath();
488 static QString s_mountPath;
498 LOG(VB_MEDIA, LOG_INFO, QString(
499 "MythMusic: '%1' unmounted, clearing data").
arg(cd->
getVolumeID()));
521 LOG(VB_MEDIA, LOG_NOTICE, QString(
"MythMusic: '%1' mounted on '%2'")
541 QString message = QCoreApplication::translate(
"(MythMusicMain)",
542 "Searching for music files...");
543 auto *busy =
new MythUIBusyDialog( message, popupStack,
"musicscanbusydialog");
554 LOG(VB_MEDIA, LOG_INFO, QString(
"MythMusic: %1 music files found")
555 .
arg(trackList.count()));
560 if (trackList.isEmpty())
563 message = QCoreApplication::translate(
"(MythMusicMain)",
"Loading music tracks");
565 "scalingprogressdialog");
569 progress->SetTotal(trackList.count());
579 for (
const auto &
file : qAsConst(trackList))
584 meta->setTrack(++track);
590 QCoreApplication::processEvents();
593 LOG(VB_MEDIA, LOG_INFO, QString(
"MythMusic: %1 tracks scanned").
arg(track));
604 for (track = 1; track <= tracks; track++)
608 songList.append(mdata->
ID());
610 if (songList.isEmpty())
638 LOG(VB_MEDIA, LOG_NOTICE,
"Got a CD media changed event");
652 LOG(VB_MEDIA, LOG_INFO,
"MythMusic: Storing CD device " +
gCDdevice);
656 LOG(VB_MEDIA, LOG_INFO,
"Device is not usable clearing cd data");
686 QCoreApplication::processEvents();
695 auto *decoder =
new CdDecoder(
"cda",
nullptr,
nullptr);
696 decoder->setDevice(newDevice);
698 int tracks = decoder->getNumTracks();
699 bool setTitle =
false;
701 for (
int trackNo = 1; trackNo <= tracks; trackNo++)
711 QString parenttitle =
" ";
715 parenttitle +=
" ~ ";
718 if (track->
Album().length() > 0)
719 parenttitle += track->
Album();
722 parenttitle =
" " + QCoreApplication::translate(
"(MythMusicMain)",
724 LOG(VB_GENERAL, LOG_INFO,
"Couldn't find your "
725 " CD. It may not be in the freedb database.\n"
726 " More likely, however, is that you need to delete\n"
727 " ~/.cddb and ~/.cdserverrc and restart MythMusic.");
754 songList.append((mdata)->ID());
757 if (!songList.isEmpty())
783 LOG(VB_GENERAL, LOG_NOTICE,
"MythMusic got a media changed event"
784 "but cdio support is not compiled in");
790 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Play music"),
792 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Select music playlists"),
794 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Play radio stream"),
796 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Rip CD"),
798 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Scan music"),
800 REG_JUMPEX(QT_TRANSLATE_NOOP(
"MythControls",
"Show Music Miniplayer"),
803 REG_KEY(
"Music",
"NEXTTRACK", QT_TRANSLATE_NOOP(
"MythControls",
804 "Move to the next track"),
">,.,Z,End");
805 REG_KEY(
"Music",
"PREVTRACK", QT_TRANSLATE_NOOP(
"MythControls",
806 "Move to the previous track"),
",,<,Q,Home");
807 REG_KEY(
"Music",
"FFWD", QT_TRANSLATE_NOOP(
"MythControls",
808 "Fast forward"),
"PgDown");
809 REG_KEY(
"Music",
"RWND", QT_TRANSLATE_NOOP(
"MythControls",
811 REG_KEY(
"Music",
"PAUSE", QT_TRANSLATE_NOOP(
"MythControls",
812 "Pause/Start playback"),
"P");
813 REG_KEY(
"Music",
"PLAY", QT_TRANSLATE_NOOP(
"MythControls",
814 "Start playback"),
"");
815 REG_KEY(
"Music",
"STOP", QT_TRANSLATE_NOOP(
"MythControls",
816 "Stop playback"),
"O");
817 REG_KEY(
"Music",
"VOLUMEDOWN", QT_TRANSLATE_NOOP(
"MythControls",
818 "Volume down"),
"[,{,F10,Volume Down");
819 REG_KEY(
"Music",
"VOLUMEUP", QT_TRANSLATE_NOOP(
"MythControls",
820 "Volume up"),
"],},F11,Volume Up");
821 REG_KEY(
"Music",
"MUTE", QT_TRANSLATE_NOOP(
"MythControls",
822 "Mute"),
"|,\\,F9,Volume Mute");
823 REG_KEY(
"Music",
"TOGGLEUPMIX",QT_TRANSLATE_NOOP(
"MythControls",
824 "Toggle audio upmixer"),
"Ctrl+U");
825 REG_KEY(
"Music",
"CYCLEVIS", QT_TRANSLATE_NOOP(
"MythControls",
826 "Cycle visualizer mode"),
"6");
827 REG_KEY(
"Music",
"BLANKSCR", QT_TRANSLATE_NOOP(
"MythControls",
828 "Blank screen"),
"5");
829 REG_KEY(
"Music",
"THMBUP", QT_TRANSLATE_NOOP(
"MythControls",
830 "Increase rating"),
"9");
831 REG_KEY(
"Music",
"THMBDOWN", QT_TRANSLATE_NOOP(
"MythControls",
832 "Decrease rating"),
"7");
833 REG_KEY(
"Music",
"REFRESH", QT_TRANSLATE_NOOP(
"MythControls",
834 "Refresh music tree"),
"8");
835 REG_KEY(
"Music",
"SPEEDUP", QT_TRANSLATE_NOOP(
"MythControls",
836 "Increase Play Speed"),
"W");
837 REG_KEY(
"Music",
"SPEEDDOWN", QT_TRANSLATE_NOOP(
"MythControls",
838 "Decrease Play Speed"),
"X");
839 REG_KEY(
"Music",
"MARK", QT_TRANSLATE_NOOP(
"MythControls",
840 "Toggle track selection"),
"T");
841 REG_KEY(
"Music",
"TOGGLESHUFFLE", QT_TRANSLATE_NOOP(
"MythControls",
842 "Toggle shuffle mode"),
"");
843 REG_KEY(
"Music",
"TOGGLEREPEAT", QT_TRANSLATE_NOOP(
"MythControls",
844 "Toggle repeat mode"),
"");
845 REG_KEY(
"Music",
"TOGGLELAST", QT_TRANSLATE_NOOP(
"MythControls",
846 "Switch to previous radio stream"),
"");
849 REG_KEY(
"Music",
"SWITCHTOPLAYLIST", QT_TRANSLATE_NOOP(
"MythControls",
850 "Switch to the current playlist view"),
"");
851 REG_KEY(
"Music",
"SWITCHTOPLAYLISTEDITORTREE", QT_TRANSLATE_NOOP(
"MythControls",
852 "Switch to the playlist editor tree view"),
"");
853 REG_KEY(
"Music",
"SWITCHTOPLAYLISTEDITORGALLERY", QT_TRANSLATE_NOOP(
"MythControls",
854 "Switch to the playlist editor gallery view"),
"");
855 REG_KEY(
"Music",
"SWITCHTOSEARCH", QT_TRANSLATE_NOOP(
"MythControls",
856 "Switch to the search view"),
"");
857 REG_KEY(
"Music",
"SWITCHTOVISUALISER", QT_TRANSLATE_NOOP(
"MythControls",
858 "Switch to the fullscreen visualiser view"),
"");
859 REG_KEY(
"Music",
"SWITCHTORADIO", QT_TRANSLATE_NOOP(
"MythControls",
860 "Switch to the radio stream view"),
"");
866 filt.replace(
'|',
',');
885 LOG(VB_GENERAL, LOG_ERR,
886 "Couldn't upgrade music database schema, exiting.");
901 return runMenu(
"musicmenu.xml");
906 return runMenu(
"music_settings.xml");
int mythplugin_config(void)
bool isActive(void) const
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
MythScreenStack * GetMainStack()
static void startDatabaseTree(void)
QString RemoveCurrentLocation()
bool setCurrentTrackPos(int pos)
static void handleCDMedia(MythMediaDevice *)
void importFinished(void)
static QStringList BuildFileList(const QString &dir, const QStringList &filters)
static void setupKeys(void)
void removeAllCDTracks(void)
QVariant value(int i) const
arg(title).arg(filename).arg(doDelete))
static void startRipper(void)
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
bool isPlaying(void) const
void setCDTitle(const QString &a_title)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
static bool TestPluginVersion(const QString &name, const QString &libversion, const QString &pluginversion)
static void runRipCD(void)
static void runMusicSelection(void)
void mythplugin_destroy(void)
static MythThemedMenu * menu
MusicMetadata * getCDMetadata(int m_the_track)
Playlist * getActive(void)
MusicMetadata * getCurrentMetadata(void)
get the metadata for the current track in the playlist
#define REG_KEY(a, b, c, d)
static void runMusicPlayback(void)
void reloadMusic(void) const
reload music after a scan, rip or import
static void startImport(void)
static void MusicCallback(void *data, QString &selection)
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
static void DBError(const QString &where, const MSqlQuery &query)
static void handleMedia(MythMediaDevice *cd)
static void startStreamPlayback(void)
void addCDTrack(const MusicMetadata &the_track)
int getCDTrackCount(void) const
#define REG_JUMP(a, b, c, d)
static void runMusicStreamPlayback(void)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
PlaylistContainer * m_all_playlists
void showMiniPlayer(void) const
bool GetBoolSetting(const QString &key, bool defaultval=false)
static void startPlayback(void)
#define MYTH_BINARY_VERSION
Update this whenever the plug-in ABI changes.
bool UpgradeMusicDatabaseSchema(void)
void loadMusic(void) const
static QStringList GetMusicFilter()
void activePlaylistChanged(int trackID, bool deleted)
static bool checkMusicAvailable(void)
checks we have some tracks available
void save()
Check each MusicMetadata entry and save those that have changed (ratings, etc.)
MythMainWindow * GetMythMainWindow(void)
static void runScan(void)
void ActivateSettingsCache(bool activate=true)
MythScreenStack * GetStack(const QString &Stackname)
#define REG_JUMPEX(a, b, c, d, e)
void sendCDChangedEvent(void)
static void * m_callbackdata
void removeAllTracks(void)
void stop(bool stopAll=false)
static const iso6937table * d
void AddCurrentLocation(const QString &Location)
void fillSonglistFromList(const QList< int > &songList, bool removeDuplicates, InsertPLOption insertOption, int currentTrackID)
void SaveSetting(const QString &key, int newValue)
MythUIHelper * GetMythUI()
static void showMiniPlayer(void)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
MSqlQuery query(MSqlQuery::InitCon())
static void scanMusic(void)
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
int mythplugin_init(const char *libversion)
static void(* m_callback)(void *, QString &)
static bool checkStorageGroup(void)
checks we have at least one music directory in the 'Music' storage group
static int runMenu(const QString &which_menu)
QString GetSetting(const QString &key, const QString &defaultval="")
virtual MythScreenType * GetTopScreen(void) const