1

I'm trying to use JSch to send AppleScript to my Apple device. My code sends a 'playpause' command to iTunes and works but only twice. After the third click of the button, the code doesn't work any longer.

Can you guys tell me why?

Code:

public void onPlayPauseClick(View view){ channel.setCommand("osascript -e 'tell app \"iTunes\" to playpause'"); Log.i("Button", "Pressed play"); try { channel.connect(); } catch (JSchException e) { e.printStackTrace(); } }

user3646937
  • 161
  • 1
  • 1
  • 3

1 Answers1

0

JSCH does not automatically disconnect channels when their command has been successfully executed or when they fail. You need to set your button up to reuse an open channel, or explicitly disconnect your channel after it sends the playpause command.

See the post here for an example.

Community
  • 1
  • 1
Damienknight
  • 1,876
  • 2
  • 18
  • 34