From fcc0c181248af443594e3ab643097abd92191ae1 Mon Sep 17 00:00:00 2001
From: Owen <owenca@users.noreply.github.com>
Date: Fri, 15 Dec 2017 06:23:10 +0000
Subject: [PATCH 5/5] Expose the current track as a scripting object.
---
src/apps/mediaplayer/MainWin.cpp | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/src/apps/mediaplayer/MainWin.cpp b/src/apps/mediaplayer/MainWin.cpp
index b338404..75c124d 100644
a
|
b
|
static property_info sPropertyInfo[] = {
|
190 | 190 | "Gets the title of the nth track in Playlist.", 0, |
191 | 191 | { B_STRING_TYPE } |
192 | 192 | }, |
| 193 | { "CurrentTrack", { B_GET_PROPERTY, 0 }, |
| 194 | { B_DIRECT_SPECIFIER, 0 }, |
| 195 | "Gets the pointer to the current track.", 0, |
| 196 | { B_POINTER_TYPE } |
| 197 | }, |
193 | 198 | |
194 | 199 | { 0 } |
195 | 200 | }; |
… |
… |
MainWin::MessageReceived(BMessage* msg)
|
622 | 627 | |
623 | 628 | case 14: |
624 | 629 | { |
625 | | int32 i = specifier.GetInt32("index", 0); |
626 | | if (i >= fPlaylist->CountItems()) { |
| 630 | int32 index = specifier.GetInt32("index", 0); |
| 631 | if (index >= fPlaylist->CountItems()) { |
627 | 632 | result = B_NO_INIT; |
628 | 633 | break; |
629 | 634 | } |
630 | 635 | |
631 | 636 | BAutolock _(fPlaylist); |
632 | | const PlaylistItem* item = fPlaylist->ItemAt(i); |
| 637 | const PlaylistItem* item = fPlaylist->ItemAt(index); |
633 | 638 | result = item == NULL ? B_NO_INIT |
634 | 639 | : reply.AddString("result", item->Title()); |
635 | 640 | break; |
636 | 641 | } |
637 | 642 | |
| 643 | case 15: |
| 644 | { |
| 645 | BAutolock _(fPlaylist); |
| 646 | const PlaylistItem* item = fController->Item(); |
| 647 | result = item == NULL ? B_NO_INIT |
| 648 | : reply.AddPointer("result", item); |
| 649 | break; |
| 650 | } |
| 651 | |
638 | 652 | default: |
639 | 653 | return BWindow::MessageReceived(msg); |
640 | 654 | } |