Ticket #13829: 0001-MediaPlayer-Add-Retrieving-Track-Number-through-Scri.patch

File 0001-MediaPlayer-Add-Retrieving-Track-Number-through-Scri.patch, 2.9 KB (added by CodeforEvolution, 6 years ago)

My Patch

  • src/apps/mediaplayer/MainWin.cpp

    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[] = {  
    160160        B_TRANSLATE("Gets the URI of the currently playing item."), 0,
    161161        { B_STRING_TYPE }
    162162    },
     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    },
    163168    { B_TRANSLATE("ToggleFullscreen"), { B_EXECUTE_PROPERTY },
    164169        { B_DIRECT_SPECIFIER, 0 },
    165170        B_TRANSLATE("Toggle fullscreen."), 0
    MainWin::MessageReceived(BMessage* msg)  
    564569                    }
    565570                    break;
    566571                }
    567 
     572               
    568573                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                    }
    570585                    break;
     586                }
     587                   
    571588
    572589                case 10:
     590                    PostMessage(M_TOGGLE_FULLSCREEN);
     591                    break;
     592
     593                case 11:
    573594                    if (msg->what != B_GET_PROPERTY)
    574595                        break;
    575596
    MainWin::MessageReceived(BMessage* msg)  
    577598                        fController->TimeDuration());
    578599                    break;
    579600
    580                 case 11:
     601                case 12:
    581602                {
    582603                    if (msg->what == B_GET_PROPERTY) {
    583604                        result = reply.AddInt64("result",
    MainWin::MessageReceived(BMessage* msg)  
    592613                    break;
    593614                }
    594615
    595                 case 12:
     616                case 13:
    596617                {
    597618                    if (msg->what != B_SET_PROPERTY)
    598619                        break;
  • src/apps/mediaplayer/playlist/FilePlaylistItem.cpp

    diff --git a/src/apps/mediaplayer/playlist/FilePlaylistItem.cpp b/src/apps/mediaplayer/playlist/FilePlaylistItem.cpp
    index 56d3cec..c0bd217 100644
    a b status_t  
    183183FilePlaylistItem::GetAttribute(const Attribute& attribute,
    184184    int32& value) const
    185185{
    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    }
    187200}
    188201
    189202