summaryrefslogtreecommitdiff
path: root/src/DisplayApp/Screens/Music.cpp
diff options
context:
space:
mode:
authorAdam Pigg <adam@piggz.co.uk>2020-07-20 21:28:21 +0100
committerAdam Pigg <adam@piggz.co.uk>2020-07-20 21:28:21 +0100
commit5713eac1045394928de19e76fd00a172f63bffa7 (patch)
treea20e130e01147c4afc89981d7bcfa6773dc6445e /src/DisplayApp/Screens/Music.cpp
parent686e826f4e656546523e989535c74f286a91855b (diff)
Fully implement music app and service
SystemTask can return a reference to the nimbleController The nimbleController can return a reference to the musicService The musicService get a connection handle from the nimbleController The musicApp communicated directly with the musicService
Diffstat (limited to 'src/DisplayApp/Screens/Music.cpp')
-rw-r--r--src/DisplayApp/Screens/Music.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/DisplayApp/Screens/Music.cpp b/src/DisplayApp/Screens/Music.cpp
index 5b54c49c..9b7d198b 100644
--- a/src/DisplayApp/Screens/Music.cpp
+++ b/src/DisplayApp/Screens/Music.cpp
@@ -41,8 +41,8 @@ Music::Music(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Mus
lv_obj_set_event_cb(btnPlayPause, event_handler);
lv_obj_set_size(btnPlayPause, LV_HOR_RES / 4, LV_VER_RES / 4);
lv_obj_align(btnPlayPause, NULL, LV_ALIGN_IN_BOTTOM_MID, 0,-10);
- label = lv_label_create(btnPlayPause, NULL);
- lv_label_set_text(label, ">");
+ txtPlayPause = lv_label_create(btnPlayPause, NULL);
+ lv_label_set_text(txtPlayPause, ">");
btnNext = lv_btn_create(lv_scr_act(), NULL);
btnNext->user_data = this;
@@ -65,6 +65,8 @@ Music::Music(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Mus
lv_label_set_text(txtTrack, "This is a very long track name");
lv_label_set_align(txtTrack, LV_LABEL_ALIGN_CENTER);
lv_obj_set_width(txtTrack, LV_HOR_RES);
+
+ musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN);
}
Music::~Music() {
@@ -89,6 +91,14 @@ bool Music::Refresh() {
if (m_album != musicService.album()) {
m_album = musicService.album();
}
+ if (m_status != musicService.status()) {
+ m_status = musicService.status();
+ }
+ if (m_status == Pinetime::Controllers::MusicService::STATUS_MUSIC_PLAYING) {
+ lv_label_set_text(txtPlayPause, "||");
+ } else {
+ lv_label_set_text(txtPlayPause, ">");
+ }
return running;
}
@@ -97,13 +107,17 @@ void Music::OnObjectEvent(lv_obj_t* obj, lv_event_t event)
{
if (event == LV_EVENT_CLICKED) {
if (obj == btnVolDown) {
- musicService.event(Controllers::MusicService::EVENT_MUSIC_VOLUP);
- } else if (obj == btnVolUp) {
musicService.event(Controllers::MusicService::EVENT_MUSIC_VOLDOWN);
+ } else if (obj == btnVolUp) {
+ musicService.event(Controllers::MusicService::EVENT_MUSIC_VOLUP);
} else if (obj == btnPrev) {
musicService.event(Controllers::MusicService::EVENT_MUSIC_PREV);
} else if (obj == btnPlayPause) {
- musicService.event(Controllers::MusicService::EVENT_MUSIC_PLAY);
+ if (m_status == Pinetime::Controllers::MusicService::STATUS_MUSIC_PLAYING) {
+ musicService.event(Controllers::MusicService::EVENT_MUSIC_PAUSE);
+ } else {
+ musicService.event(Controllers::MusicService::EVENT_MUSIC_PLAY);
+ }
} else if (obj == btnNext) {
musicService.event(Controllers::MusicService::EVENT_MUSIC_NEXT);
}