sonos-api-java

Java client for the Sonos API

License

License

Categories

Categories

Java Languages
GroupId

GroupId

engineer.nightowl
ArtifactId

ArtifactId

sonos-api-java
Last Version

Last Version

0.0.20
Release Date

Release Date

Type

Type

jar
Description

Description

sonos-api-java
Java client for the Sonos API
Project URL

Project URL

https://github.com/nightowlengineer/sonos-api-java
Source Code Management

Source Code Management

https://github.com/nightowlengineer/sonos-api-java/tree/master

Download sonos-api-java

How to add to project

<!-- https://jarcasting.com/artifacts/engineer.nightowl/sonos-api-java/ -->
<dependency>
    <groupId>engineer.nightowl</groupId>
    <artifactId>sonos-api-java</artifactId>
    <version>0.0.20</version>
</dependency>
// https://jarcasting.com/artifacts/engineer.nightowl/sonos-api-java/
implementation 'engineer.nightowl:sonos-api-java:0.0.20'
// https://jarcasting.com/artifacts/engineer.nightowl/sonos-api-java/
implementation ("engineer.nightowl:sonos-api-java:0.0.20")
'engineer.nightowl:sonos-api-java:jar:0.0.20'
<dependency org="engineer.nightowl" name="sonos-api-java" rev="0.0.20">
  <artifact name="sonos-api-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='engineer.nightowl', module='sonos-api-java', version='0.0.20')
)
libraryDependencies += "engineer.nightowl" % "sonos-api-java" % "0.0.20"
[engineer.nightowl/sonos-api-java "0.0.20"]

Dependencies

compile (6)

Group / Artifact Type Version
junit : junit jar 4.13.1
org.slf4j : slf4j-api jar 1.7.30
org.apache.commons : commons-lang3 jar 3.11
commons-io : commons-io jar 2.8.0
org.apache.httpcomponents : httpclient jar 4.5.13
com.fasterxml.jackson.core : jackson-databind jar 2.11.3

test (2)

Group / Artifact Type Version
org.mockito : mockito-core jar 2.28.2
org.slf4j : slf4j-simple jar 1.7.30

Project Modules

There are no modules declared in this project.

Sonos API client for Java

This library provides a simple integration with the Sonos API, allowing you to control players and content from any Java app.

Please note that this library is currently still in development. Some aspects (particularly with the SMAPI) cannot be tested due to a lack of access, others due to not owning devices with specific features.

Build Status

Prerequisites

Before using the library, it's recommended that you read the official documentation published on the Sonos Developer site. The reference documentation is also detailed and provides a good overview of the many different resources and endpoints open to you.

You'll need to register with Sonos, create a Control Integration, and finally generate client credentials to be able to connect with the Sonos API. It's also recommended that you have at least one Sonos device to be able to properly test and play with your application (plus, listening to music or watching movies with Sonos is awesome anyway!)

Maven Setup

<dependency>
  <groupId>engineer.nightowl</groupId>
  <artifactId>sonos-api-java</artifactId>
  <version><LATEST-VERSION></version>
</dependency>

Getting Started

Create a new configuration object, set your integration's properties (see further above on how to obtain these), then create a client and pass in that configuration:

final SonosApiConfiguration configuration = new SonosApiConfiguration();
configuration.setApiKey(properties.getProperty("apiKey"));
configuration.setApiSecret(properties.getProperty("apiSecret"));
configuration.setApplicationId(properties.getProperty("applicationId"));

final SonosApiClient client = new SonosApiClient(configuration);

Then use the client to view and modify the user's devices - the following types of resource are available:

  • audioClip
  • authorize
  • favorite
  • group
  • groupVolume
  • homeTheater
  • household
  • musicServiceAccounts
  • playbackMetadata
  • playback
  • playbackSession
  • playerVolume
  • playlist
  • settings

For example, to set all 'groups' (aka rooms) to use crossfade when music is playing, you could run the following:

final SonosGroups groups = client.group().getGroups("authToken", "householdId");
final SonosPlayMode playMode = new SonosPlayMode();
playMode.setCrossfade(true);

for (final SonosGroup group : groups.getGroups())
{
    client.playback().setPlayModes("authToken", group.getId(), playMode);
}

Versions

Version
0.0.20
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1