radiant-player / radiant-player-mac

:notes: Turn Google Play Music into a separate, beautiful application that integrates with your Mac.
http://radiant-player.github.io/radiant-player-mac/
MIT License
2.99k stars 261 forks source link

Scripting Bridge doesn't work #422

Closed floschliep closed 8 years ago

floschliep commented 8 years ago

The Scripting Bridge doesn't seem to be working for the most part.

The currentSongName, currentSongArtist, currentSongAlbum and currentSongArtproperties are always nil. Only currentSongUrlreturns a value.

I encountered this issue using Radiant 1.5.0 on OS X 10.11.1.

chrismou commented 8 years ago

Perhaps I've misunderstood, but I don't see currentSongName, currentSongArtist, currentSongAlbum or currentSongArt referenced anywhere.

There does seem to be references to currentTitle, currentArtist, currentAlbum and currentArt (https://github.com/radiant-player/radiant-player-mac/blob/master/radiant-player-mac/AppleScript/NSApplication%2BScriptingProperties.h)

Is this what you're after?

floschliep commented 8 years ago

When generating a header from sdef file contained in the app bundle you'll get those properties. sdef /Applications/Radiant\ Player.app | sdp -fh --basename RadiantPlayer

/*
 * RadiantPlayer.h
 */

#import <AppKit/AppKit.h>
#import <ScriptingBridge/ScriptingBridge.h>

@class RadiantPlayerApplication, RadiantPlayerDocument, RadiantPlayerWindow, RadiantPlayerApplication;

enum RadiantPlayerSaveOptions {
    RadiantPlayerSaveOptionsYes = 'yes ' /* Save the file. */,
    RadiantPlayerSaveOptionsNo = 'no  ' /* Do not save the file. */,
    RadiantPlayerSaveOptionsAsk = 'ask ' /* Ask the user whether or not to save the file. */
};
typedef enum RadiantPlayerSaveOptions RadiantPlayerSaveOptions;

enum RadiantPlayerPrintingErrorHandling {
    RadiantPlayerPrintingErrorHandlingStandard = 'lwst' /* Standard PostScript error handling */,
    RadiantPlayerPrintingErrorHandlingDetailed = 'lwdt' /* print a detailed report of PostScript errors */
};
typedef enum RadiantPlayerPrintingErrorHandling RadiantPlayerPrintingErrorHandling;

@protocol RadiantPlayerGenericMethods

- (void) closeSaving:(RadiantPlayerSaveOptions)saving savingIn:(NSURL *)savingIn;  // Close a document.
- (void) saveIn:(NSURL *)in_ as:(id)as;  // Save a document.
- (void) printWithProperties:(NSDictionary *)withProperties printDialog:(BOOL)printDialog;  // Print a document.
- (void) delete;  // Delete an object.
- (void) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties;  // Copy an object.
- (void) moveTo:(SBObject *)to;  // Move an object to a new location.

@end

/*
 * Standard Suite
 */

// The application's top-level scripting object.
@interface RadiantPlayerApplication : SBApplication

- (SBElementArray<RadiantPlayerDocument *> *) documents;
- (SBElementArray<RadiantPlayerWindow *> *) windows;

@property (copy, readonly) NSString *name;  // The name of the application.
@property (readonly) BOOL frontmost;  // Is this the active application?
@property (copy, readonly) NSString *version;  // The version number of the application.

- (id) open:(id)x;  // Open a document.
- (void) print:(id)x withProperties:(NSDictionary *)withProperties printDialog:(BOOL)printDialog;  // Print a document.
- (void) quitSaving:(RadiantPlayerSaveOptions)saving;  // Quit the application.
- (BOOL) exists:(id)x;  // Verify that an object exists.
- (void) backTrack;  // reposition to beginning of current track or go to previous track if already at start of current track
- (void) nextTrack;  // advance to the next track in the current playlist
- (void) playpause;  // toggle the playing/paused state of the current track
- (void) toggleThumbsUp;  // toggle thumbs up for current track
- (void) toggleThumbsDown;  // toggle thumbs down for current track
- (void) toggleShuffle;  // toggle shuffle on/off
- (void) toggleRepeatmode;  // toggle repeat mode
- (void) toggleVisualization;  // toggle visualization on/off

@end

// A document.
@interface RadiantPlayerDocument : SBObject <RadiantPlayerGenericMethods>

@property (copy, readonly) NSString *name;  // Its name.
@property (readonly) BOOL modified;  // Has it been modified since the last save?
@property (copy, readonly) NSURL *file;  // Its location on disk, if it has one.

@end

// A window.
@interface RadiantPlayerWindow : SBObject <RadiantPlayerGenericMethods>

@property (copy, readonly) NSString *name;  // The title of the window.
- (NSInteger) id;  // The unique identifier of the window.
@property NSInteger index;  // The index of the window, ordered front to back.
@property NSRect bounds;  // The bounding rectangle of the window.
@property (readonly) BOOL closeable;  // Does the window have a close button?
@property (readonly) BOOL miniaturizable;  // Does the window have a minimize button?
@property BOOL miniaturized;  // Is the window minimized right now?
@property (readonly) BOOL resizable;  // Can the window be resized?
@property BOOL visible;  // Is the window visible right now?
@property (readonly) BOOL zoomable;  // Does the window have a zoom button?
@property BOOL zoomed;  // Is the window zoomed right now?
@property (copy, readonly) RadiantPlayerDocument *document;  // The document whose contents are displayed in the window.

@end

/*
 * Radiant Player Suite
 */

// Radiant Player's application object
@interface RadiantPlayerApplication (RadiantPlayerSuite)

@property (copy) NSString *currentSongName;  // name of the currently playing song
@property (copy) NSString *currentSongArtist;  // artist of the currently playing song
@property (copy) NSString *currentSongAlbum;  // album of the currently playing song
@property (copy) NSImage *currentSongArt;  // art image of the currently playing song
@property (copy) NSString *currentSongUrl;  // shareable URL of the currently playing song
@property NSInteger playerState;  // the state of the player (0 = stopped, 1 = paused, or 2 = playing)

@end
chrismou commented 8 years ago

Sorry, I don't know much about the Scripting Bridge, hence the confusion.

Though like I say, there's literally no mention of currentSongName, currentSongArtist, currentSongAlbum or currentSongArt anywhere in the code, so I'm at a loss as to where they could be coming from. I'd assume they should match up with the values in here: https://github.com/radiant-player/radiant-player-mac/blob/master/radiant-player-mac/AppleScript/radiant-player-mac.sdef

chrismou commented 8 years ago

OK, ignore me. It looks like the values in your sdef are just caml cased versions of the property name, as opposed to the key value, which makes sense.

AppDelegate only sets a value for currentSongURL, which could explain why that's the only value making it through. I'm guessing the other values will need adding too.

I'll take a look at this when I get some free time - though I know little to nothing about the scripting bridge, so I'm not sure how I'd test if it's working.

Alternatively, PRs are always welcome :-)

floschliep commented 8 years ago

Here's a small app to test the scripting bridge: http://d.pr/f/gKim

chrismou commented 8 years ago

Ah cool, thanks for that.

So without making any changes, when I run it I see this:

screenshot 2015-11-30 11 04 29

I let it run onto the next song and reloaded, and it seemed to update OK.

How do I recreate the issue you're seeing?

floschliep commented 8 years ago

If I play a song I just see the URL: bildschirmfoto 2015-11-30 um 12 20 04

chrismou commented 8 years ago

OK cool, it looks like I'm getting the same against the 1.5.0 version, but it looks to be working against master.

Could you try it against the master branch? There's been a ton of fixes since @kbhomes last did a release. I suspect this relates to https://github.com/radiant-player/radiant-player-mac/pull/400

I put up a recent build for a recent PR, save you booting up Xcode: https://github.com/chrismou/radiant-player-mac/releases/download/v1.5.0-cyan/RadiantPlayer.app.zip

floschliep commented 8 years ago

Alright, this version works. Is this release publicly available (via Sparkle) for users? Now the only Scripting Bridge-related issue left is https://github.com/radiant-player/radiant-player-mac/issues/423.

chrismou commented 8 years ago

No, current version is still 1.5.0. A few of us are able to review/merge PRs, but currently only @kbhomes can do releases. It's something we're working on (https://github.com/radiant-player/radiant-player-mac/pull/416).

In the meantime, you should be safe to use that binary I sent you the link to. It's tagged at 1.5.0, so you should still get the update notification when he next does a release.

Thanks for the help debugging!