DragonCdTocReader Class

Reads the table of contents of an audio CD asynchronously. More...

Header: #include <DragonCdTocReader>
CMake: find_package(DragonMediaBackend REQUIRED COMPONENTS DragonMediaBackend)
target_link_libraries(mytarget PRIVATE DragonMediaBackend::DragonMediaBackend)
In QML: DragonCdTocReader

Public Functions

DragonCdTocReader(QObject *parent = nullptr)
virtual ~DragonCdTocReader() override
void requestToc(const QString &device = QString())

Signals

void failed(const QString &errorMessage)
void tocReady(const DragonCdToc &toc)

Detailed Description

Call requestToc(), then handle tocReady() and the failed() signals.

With the TOC in hand, the application can build its track list and run a CDDB or MusicBrainz lookup itself — the reader supplies the basic track data, it does not do network metadata lookups.

Re-reading after a disc swap requires another requestToc() call. Use Solid to detect when discs are inserted or removed.

Playback of the returned tracks is DragonPlayer's job: set source to a track's url().

See also DragonCdToc, DragonCdTrack, and DragonPlayer.

Member Function Documentation

[explicit] DragonCdTocReader::DragonCdTocReader(QObject *parent = nullptr)

Constructs a TOC reader with the given parent.

[override virtual noexcept] DragonCdTocReader::~DragonCdTocReader()

Destroys the reader. A TOC read still in flight is abandoned; no signal is emitted for it.

[signal] void DragonCdTocReader::failed(const QString &errorMessage)

Emitted with the reason errorMessage when the TOC could not be read: no disc, not an Audio CD, an unopenable device, or the library was built without CD support.

[invokable] void DragonCdTocReader::requestToc(const QString &device = QString())

Reads the TOC of device asynchronously and emits tocReady() or failed(). An empty device selects the default CD drive.

Re-reading after a disc swap is a plain second requestToc() call; the backend's disc cache handles media-change detection. Request the TOC of the same device while a read is in flight coalesces into that read, so it produces a single tocReady().

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[signal] void DragonCdTocReader::tocReady(const DragonCdToc &toc)

Emitted with the TOC toc of the requested device once it has been read. Spinning up an optical drives might take a couple of seconds.