[haiku-commits] haiku: hrev53975 - in src/apps/mediaplayer: . playlist

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 14 Mar 2020 14:29:33 -0400 (EDT)

hrev53975 adds 1 changeset to branch 'master'
old head: 768f6b3bc48e139523d5a7c35a148f460dae6a74
new head: 86950f4e763957d54d33a6cd7186170027994014
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=86950f4e7639+%5E768f6b3bc48e

----------------------------------------------------------------------------

86950f4e7639: MediaPlayer: Add Retrieving Track Number through Scripting
  
  Also fix some backend logic
  
  Change-Id: I4b24786ece4be1e9007686d46f6541d39df7a33b
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/319
  Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

                          [ CodeforEvolution <themysterymail555@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev53975
Commit:      86950f4e763957d54d33a6cd7186170027994014
URL:         https://git.haiku-os.org/haiku/commit/?id=86950f4e7639
Author:      CodeforEvolution <themysterymail555@xxxxxxxxx>
Date:        Sat Dec  2 20:30:25 2017 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat Mar 14 18:29:12 2020 UTC

----------------------------------------------------------------------------

2 files changed, 39 insertions(+), 6 deletions(-)
src/apps/mediaplayer/MainWin.cpp                 | 30 ++++++++++++++++----
.../mediaplayer/playlist/FilePlaylistItem.cpp    | 15 +++++++++-

----------------------------------------------------------------------------

diff --git a/src/apps/mediaplayer/MainWin.cpp b/src/apps/mediaplayer/MainWin.cpp
index ad1c8811c0..6668f62005 100644
--- a/src/apps/mediaplayer/MainWin.cpp
+++ b/src/apps/mediaplayer/MainWin.cpp
@@ -148,6 +148,11 @@ static property_info sPropertyInfo[] = {
                "Gets the URI of the currently playing item.", 0,
                { B_STRING_TYPE }
        },
+       { "TrackNumber", { B_GET_PROPERTY, 0 },
+               { B_DIRECT_SPECIFIER, 0 },
+               "Gets the number of the current track playing.", 0,
+               { B_INT32_TYPE }
+       },
        { "ToggleFullscreen", { B_EXECUTE_PROPERTY },
                { B_DIRECT_SPECIFIER, 0 },
                "Toggle fullscreen.", 0
@@ -564,10 +569,25 @@ MainWin::MessageReceived(BMessage* msg)
                                }
 
                                case 9:
-                                       PostMessage(M_TOGGLE_FULLSCREEN);
+                               {
+                                       if (msg->what == B_GET_PROPERTY) {
+                                               BAutolock _(fPlaylist);
+                                               const PlaylistItem* item = 
fController->Item();
+                                               if (item == NULL) {
+                                                       result = B_NO_INIT;
+                                                       break;
+                                               }
+
+                                               result = 
reply.AddInt32("result", item->TrackNumber());
+                                       }
                                        break;
+                               }
 
                                case 10:
+                                       PostMessage(M_TOGGLE_FULLSCREEN);
+                                       break;
+
+                               case 11:
                                        if (msg->what != B_GET_PROPERTY)
                                                break;
 
@@ -575,7 +595,7 @@ MainWin::MessageReceived(BMessage* msg)
                                                fController->TimeDuration());
                                        break;
 
-                               case 11:
+                               case 12:
                                {
                                        if (msg->what == B_GET_PROPERTY) {
                                                result = 
reply.AddInt64("result",
@@ -590,7 +610,7 @@ MainWin::MessageReceived(BMessage* msg)
                                        break;
                                }
 
-                               case 12:
+                               case 13:
                                {
                                        if (msg->what != B_SET_PROPERTY)
                                                break;
@@ -604,11 +624,11 @@ MainWin::MessageReceived(BMessage* msg)
                                        break;
                                }
 
-                               case 13:
+                               case 14:
                                        result = reply.AddInt16("result", 
fPlaylist->CountItems());
                                        break;
 
-                               case 14:
+                               case 15:
                                {
                                        int32 i = specifier.GetInt32("index", 
0);
                                        if (i >= fPlaylist->CountItems()) {
diff --git a/src/apps/mediaplayer/playlist/FilePlaylistItem.cpp 
b/src/apps/mediaplayer/playlist/FilePlaylistItem.cpp
index 775aa6d0ae..54840f998d 100644
--- a/src/apps/mediaplayer/playlist/FilePlaylistItem.cpp
+++ b/src/apps/mediaplayer/playlist/FilePlaylistItem.cpp
@@ -183,7 +183,20 @@ status_t
 FilePlaylistItem::GetAttribute(const Attribute& attribute,
        int32& value) const
 {
-       return B_NOT_SUPPORTED;
+       switch (attribute) {
+               case ATTR_INT32_TRACK:
+                       return _GetAttribute("Audio:Track", B_INT32_TYPE, 
&value,
+                               sizeof(int32));
+               case ATTR_INT32_YEAR:
+                       return _GetAttribute("Media:Year", B_INT32_TYPE, &value,
+                               sizeof(int32));
+               case ATTR_INT32_RATING:
+                       return _GetAttribute("Media:Rating", B_INT32_TYPE, 
&value,
+                               sizeof(int32));
+
+               default:
+                       return B_NOT_SUPPORTED;
+       }
 }
 
 


Other related posts:

  • » [haiku-commits] haiku: hrev53975 - in src/apps/mediaplayer: . playlist - waddlesplash