From 0107979d7af656e9c696b4d1befcdd958efebd96 Mon Sep 17 00:00:00 2001
From: CodeforEvolution <themysterymail555@gmail.com>
Date: Sat, 2 Dec 2017 14:30:25 -0600
Subject: [PATCH] MediaPlayer: Add Retrieving Track Number through Scripting
Also fix some backend logic
---
src/apps/mediaplayer/MainWin.cpp | 29 +++++++++++++++++++---
src/apps/mediaplayer/playlist/FilePlaylistItem.cpp | 15 ++++++++++-
2 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/src/apps/mediaplayer/MainWin.cpp b/src/apps/mediaplayer/MainWin.cpp
index b63b193..6cd2b60 100644
a
|
b
|
static property_info sPropertyInfo[] = {
|
160 | 160 | B_TRANSLATE("Gets the URI of the currently playing item."), 0, |
161 | 161 | { B_STRING_TYPE } |
162 | 162 | }, |
| 163 | { B_TRANSLATE("TrackNumber"), { B_GET_PROPERTY, 0 }, |
| 164 | {B_DIRECT_SPECIFIER, 0 }, |
| 165 | B_TRANSLATE("Gets the number of the current track playing."), 0, |
| 166 | { B_INT32_TYPE } |
| 167 | }, |
163 | 168 | { B_TRANSLATE("ToggleFullscreen"), { B_EXECUTE_PROPERTY }, |
164 | 169 | { B_DIRECT_SPECIFIER, 0 }, |
165 | 170 | B_TRANSLATE("Toggle fullscreen."), 0 |
… |
… |
MainWin::MessageReceived(BMessage* msg)
|
564 | 569 | } |
565 | 570 | break; |
566 | 571 | } |
567 | | |
| 572 | |
568 | 573 | case 9: |
569 | | PostMessage(M_TOGGLE_FULLSCREEN); |
| 574 | { |
| 575 | if (msg->what == B_GET_PROPERTY) { |
| 576 | BAutolock _(fPlaylist); |
| 577 | const PlaylistItem* item = fController->Item(); |
| 578 | if (item == NULL) { |
| 579 | result = B_NO_INIT; |
| 580 | break; |
| 581 | } |
| 582 | |
| 583 | result = reply.AddInt32("result", item->TrackNumber()); |
| 584 | } |
570 | 585 | break; |
| 586 | } |
| 587 | |
571 | 588 | |
572 | 589 | case 10: |
| 590 | PostMessage(M_TOGGLE_FULLSCREEN); |
| 591 | break; |
| 592 | |
| 593 | case 11: |
573 | 594 | if (msg->what != B_GET_PROPERTY) |
574 | 595 | break; |
575 | 596 | |
… |
… |
MainWin::MessageReceived(BMessage* msg)
|
577 | 598 | fController->TimeDuration()); |
578 | 599 | break; |
579 | 600 | |
580 | | case 11: |
| 601 | case 12: |
581 | 602 | { |
582 | 603 | if (msg->what == B_GET_PROPERTY) { |
583 | 604 | result = reply.AddInt64("result", |
… |
… |
MainWin::MessageReceived(BMessage* msg)
|
592 | 613 | break; |
593 | 614 | } |
594 | 615 | |
595 | | case 12: |
| 616 | case 13: |
596 | 617 | { |
597 | 618 | if (msg->what != B_SET_PROPERTY) |
598 | 619 | break; |
diff --git a/src/apps/mediaplayer/playlist/FilePlaylistItem.cpp b/src/apps/mediaplayer/playlist/FilePlaylistItem.cpp
index 56d3cec..c0bd217 100644
a
|
b
|
status_t
|
183 | 183 | FilePlaylistItem::GetAttribute(const Attribute& attribute, |
184 | 184 | int32& value) const |
185 | 185 | { |
186 | | return B_NOT_SUPPORTED; |
| 186 | switch (attribute) { |
| 187 | case ATTR_INT32_TRACK: |
| 188 | return _GetAttribute("Audio:Track", B_INT32_TYPE, &value, |
| 189 | sizeof(int32)); |
| 190 | case ATTR_INT32_YEAR: |
| 191 | return _GetAttribute("Media:Year", B_INT32_TYPE, &value, |
| 192 | sizeof(int32)); |
| 193 | case ATTR_INT32_RATING: |
| 194 | return _GetAttribute("Media:Rating", B_INT32_TYPE, &value, |
| 195 | sizeof(int32)); |
| 196 | |
| 197 | default: |
| 198 | return B_NOT_SUPPORTED; |
| 199 | } |
187 | 200 | } |
188 | 201 | |
189 | 202 | |