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.9KB

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