/* * Copyright (C) 2019 Kevin Whitaker * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef MINIMEDIAPLAYER_H #define MINIMEDIAPLAYER_H #include #include /** * Mini Media Player is a simple class that wraps some wrappers around Qt's Multimedia classes for adding and playing media from a playlist. Also parses URLs to be added to playlist using youtube-dl and makes sure they are valid. */ class MiniMediaPlayer : public QObject { Q_OBJECT public: MiniMediaPlayer(QObject *parent = 0); bool addURLToPlaylist(QUrl mediaUrl); QList getTrackNames(); bool isPlaying(); QMap currentState(); bool nextTrack(); bool playPauseTrack(bool playing); signals: void playStateChanged(bool isPlaying); void playlistChanged(QStringList trackTitles); void trackDurationChanged(qint64 length); void trackPositionChanged(qint64 position); private slots: void mediaStatusChanged(QMediaPlayer::MediaStatus status); void mediaStateChanged(QMediaPlayer::State state); void durationChanged(qint64 length); void positionChanged(qint64 position); private: QMediaPlayer *m_player; QList> playlist; bool isValidMediaUrl(QUrl mediaUrl); QUrl getStreamUrlFromUrl(QUrl mediaUrl); QList> getStreamTitlesAndUrlsFromUrl(QUrl mediaUrl); }; #endif // MINIMEDIAPLAYER_H