You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

radio.h 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef RADIO_H
  2. #define RADIO_H
  3. #include <QObject>
  4. #include <QColor>
  5. #include <QUrl>
  6. #include <QPixmap>
  7. #include <QNetworkAccessManager>
  8. #include <QNetworkReply>
  9. #include <QMediaPlayer>
  10. #include <QList>
  11. #include <QTimer>
  12. #include "song.h"
  13. class Radio : public QObject
  14. {
  15. Q_OBJECT
  16. public:
  17. explicit Radio(QObject *parent = 0);
  18. QString getName();
  19. QString getClaim();
  20. QColor getTextColor();
  21. QUrl getLogoUrl();
  22. QUrl getStreamUrl();
  23. int getId();
  24. QUrl getApiBase();
  25. QUrl getCoverBase();
  26. Song* getCurrentSong();
  27. signals:
  28. void logoDownloaded(QPixmap);
  29. void songChanged(Song*);
  30. void nextSongsUpdated();
  31. public slots:
  32. void setName(QString n);
  33. void setClaim(QString c);
  34. void setTextColor(QColor c);
  35. void setLogoUrl(QUrl u);
  36. void setStreamUrl(QUrl u);
  37. void setId(int i);
  38. void setApiBase(QUrl u);
  39. void setCoverBase(QUrl u);
  40. void setCurrentSong(Song* s);
  41. void updateNextSongs();
  42. void downloadLogo();
  43. void startStream();
  44. void stopStream();
  45. public slots:
  46. void setNetworkManager(QNetworkAccessManager* m);
  47. private slots:
  48. void logoFinished();
  49. void logoError(QNetworkReply::NetworkError);
  50. void songsFinished();
  51. void songsError(QNetworkReply::NetworkError);
  52. //void streamRead();
  53. void streamError();
  54. void songEnded();
  55. private:
  56. QString name;
  57. QString claim;
  58. QColor textColor;
  59. QUrl logoUrl;
  60. QUrl streamUrl;
  61. int id;
  62. QPixmap logo;
  63. QUrl apiBase;
  64. QUrl coverBase;
  65. QList<Song*> nextSongs;
  66. Song* currentSong;
  67. QTimer* songTimer;
  68. QNetworkAccessManager* mgr;
  69. QMediaPlayer* player;
  70. int logoTries;
  71. int songsTries;
  72. int streamTries;
  73. };
  74. #endif // RADIO_H