mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 23:21:53 +02:00
Merge fb48e3557b
into 3a0d673df4
This commit is contained in:
commit
34c950a061
|
@ -70,9 +70,9 @@ namespace Pinetime {
|
||||||
|
|
||||||
uint16_t eventHandle {};
|
uint16_t eventHandle {};
|
||||||
|
|
||||||
std::string artistName {"Waiting for"};
|
std::string artistName {};
|
||||||
std::string albumName {};
|
std::string albumName {};
|
||||||
std::string trackName {"track information.."};
|
std::string trackName {};
|
||||||
|
|
||||||
bool playing {false};
|
bool playing {false};
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
|
||||||
txtTrackDuration = lv_label_create(lv_scr_act(), nullptr);
|
txtTrackDuration = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_label_set_long_mode(txtTrackDuration, LV_LABEL_LONG_SROLL);
|
lv_label_set_long_mode(txtTrackDuration, LV_LABEL_LONG_SROLL);
|
||||||
lv_obj_align(txtTrackDuration, nullptr, LV_ALIGN_IN_TOP_LEFT, 12, 20);
|
lv_obj_align(txtTrackDuration, nullptr, LV_ALIGN_IN_TOP_LEFT, 12, 20);
|
||||||
lv_label_set_text_static(txtTrackDuration, "--:--/--:--");
|
lv_label_set_text_static(txtTrackDuration, lengthDefault);
|
||||||
lv_label_set_align(txtTrackDuration, LV_ALIGN_IN_LEFT_MID);
|
lv_label_set_align(txtTrackDuration, LV_ALIGN_IN_LEFT_MID);
|
||||||
lv_obj_set_width(txtTrackDuration, LV_HOR_RES);
|
lv_obj_set_width(txtTrackDuration, LV_HOR_RES);
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
|
||||||
lv_obj_align(txtArtist, nullptr, LV_ALIGN_IN_LEFT_MID, 12, MIDDLE_OFFSET + 1 * FONT_HEIGHT);
|
lv_obj_align(txtArtist, nullptr, LV_ALIGN_IN_LEFT_MID, 12, MIDDLE_OFFSET + 1 * FONT_HEIGHT);
|
||||||
lv_label_set_align(txtArtist, LV_ALIGN_IN_LEFT_MID);
|
lv_label_set_align(txtArtist, LV_ALIGN_IN_LEFT_MID);
|
||||||
lv_obj_set_width(txtArtist, LV_HOR_RES - 12);
|
lv_obj_set_width(txtArtist, LV_HOR_RES - 12);
|
||||||
lv_label_set_text_static(txtArtist, "Artist Name");
|
lv_label_set_text_static(txtArtist, artistDefault);
|
||||||
|
|
||||||
txtTrack = lv_label_create(lv_scr_act(), nullptr);
|
txtTrack = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_label_set_long_mode(txtTrack, LV_LABEL_LONG_SROLL_CIRC);
|
lv_label_set_long_mode(txtTrack, LV_LABEL_LONG_SROLL_CIRC);
|
||||||
|
@ -125,7 +125,7 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
|
||||||
|
|
||||||
lv_label_set_align(txtTrack, LV_ALIGN_IN_LEFT_MID);
|
lv_label_set_align(txtTrack, LV_ALIGN_IN_LEFT_MID);
|
||||||
lv_obj_set_width(txtTrack, LV_HOR_RES - 12);
|
lv_obj_set_width(txtTrack, LV_HOR_RES - 12);
|
||||||
lv_label_set_text_static(txtTrack, "This is a very long getTrack name");
|
lv_label_set_text_static(txtTrack, trackDefault);
|
||||||
|
|
||||||
/** Init animation */
|
/** Init animation */
|
||||||
imgDisc = lv_img_create(lv_scr_act(), nullptr);
|
imgDisc = lv_img_create(lv_scr_act(), nullptr);
|
||||||
|
@ -150,14 +150,24 @@ Music::~Music() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Music::Refresh() {
|
void Music::Refresh() {
|
||||||
if (artist != musicService.getArtist()) {
|
if (musicDidExist != musicExists || artist != musicService.getArtist()) {
|
||||||
artist = musicService.getArtist();
|
artist = musicService.getArtist();
|
||||||
|
|
||||||
|
if (musicExists) {
|
||||||
lv_label_set_text(txtArtist, artist.data());
|
lv_label_set_text(txtArtist, artist.data());
|
||||||
|
} else {
|
||||||
|
lv_label_set_text_static(txtArtist, artistDefault);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (track != musicService.getTrack()) {
|
if (musicDidExist != musicExists || track != musicService.getTrack()) {
|
||||||
track = musicService.getTrack();
|
track = musicService.getTrack();
|
||||||
|
|
||||||
|
if (musicExists) {
|
||||||
lv_label_set_text(txtTrack, track.data());
|
lv_label_set_text(txtTrack, track.data());
|
||||||
|
} else {
|
||||||
|
lv_label_set_text_static(txtTrack, trackDefault);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (album != musicService.getAlbum()) {
|
if (album != musicService.getAlbum()) {
|
||||||
|
@ -173,8 +183,13 @@ void Music::Refresh() {
|
||||||
UpdateLength();
|
UpdateLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (musicDidExist != musicExists) {
|
||||||
|
musicDidExist = musicExists;
|
||||||
|
}
|
||||||
|
|
||||||
if (totalLength != musicService.getTrackLength()) {
|
if (totalLength != musicService.getTrackLength()) {
|
||||||
totalLength = musicService.getTrackLength();
|
totalLength = musicService.getTrackLength();
|
||||||
|
musicExists = totalLength > 0;
|
||||||
UpdateLength();
|
UpdateLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +217,9 @@ void Music::Refresh() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Music::UpdateLength() {
|
void Music::UpdateLength() {
|
||||||
if (totalLength > (99 * 60 * 60)) {
|
if (!musicExists) {
|
||||||
|
lv_label_set_text_static(txtTrackDuration, lengthDefault);
|
||||||
|
} else if (totalLength > (99 * 60 * 60)) {
|
||||||
lv_label_set_text_static(txtTrackDuration, "Inf/Inf");
|
lv_label_set_text_static(txtTrackDuration, "Inf/Inf");
|
||||||
} else if (totalLength > (99 * 60)) {
|
} else if (totalLength > (99 * 60)) {
|
||||||
lv_label_set_text_fmt(txtTrackDuration,
|
lv_label_set_text_fmt(txtTrackDuration,
|
||||||
|
|
|
@ -71,6 +71,12 @@ namespace Pinetime {
|
||||||
std::string album;
|
std::string album;
|
||||||
std::string track;
|
std::string track;
|
||||||
|
|
||||||
|
bool musicExists = false;
|
||||||
|
bool musicDidExist = false;
|
||||||
|
static constexpr const char* artistDefault = "Waiting for";
|
||||||
|
static constexpr const char* trackDefault = "track information..";
|
||||||
|
static constexpr const char* lengthDefault = "--:--/--:--";
|
||||||
|
|
||||||
/** Total length in seconds */
|
/** Total length in seconds */
|
||||||
int totalLength = 0;
|
int totalLength = 0;
|
||||||
/** Current position in seconds */
|
/** Current position in seconds */
|
||||||
|
|
Loading…
Reference in a new issue