Skip to content
This repository has been archived by the owner on Dec 27, 2021. It is now read-only.

Commit

Permalink
Update clip() method (add already paused support)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmichalak committed Nov 1, 2017
1 parent c8cab05 commit 25c5150
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/main/java/com/vmichalak/sonoscontroller/SonosDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ public void playFromQueue(int queueIndex) throws IOException, SonosControllerExc
* @throws InterruptedException
*/
public void clip(String uri, String metadata) throws IOException, SonosControllerException, InterruptedException {
PlayState previousState = this.getPlayState();
TrackInfo previous = this.getCurrentTrackInfo();
this.playUri(uri, metadata);
while (this.getPlayState() != PlayState.STOPPED) {
Thread.sleep(500);
}
while (!this.getPlayState().equals(PlayState.STOPPED)) { Thread.sleep(500); }
this.playUri("x-rincon-queue:" + this.getSpeakerInfo().getLocalUID() + "#0", "");
this.playFromQueue(previous.getQueueIndex());
CommandBuilder.transport("Seek").put("InstanceID", "0").put("Unit", "TRACK_NR")
.put("Target", String.valueOf(previous.getQueueIndex())).executeOn(this.ip);
this.seek(previous.getPosition());
this.play();
if(previousState.equals(PlayState.PLAYING)) { this.play(); } else { this.pause(); }
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ public void getCurrentTrackInfo() throws Exception {
"album='Midnight', " +
"albumArtURI='https://i.scdn.co/image/1cc3ef402dc422472cebc5543749f0c89baaedc2'}",
sonosDevice.getCurrentTrackInfo().getMetadata().toString());
assertEquals("TrackInfo{playlistPosition=1, duration='0:03:21', position='0:00:17', " +
assertEquals("TrackInfo{queueIndex=1, duration='0:03:21', position='0:00:17', " +
"uri='x-sonos-spotify:spotify%3atrack%3a2UAUITgVFXb27TV58EWE6L?sid=9&flags=0&sn=3', " +
"metadata=TrackMetadata{title='Midnight', creator='Trinix', albumArtist='Trinix', " +
"album='Midnight', " +
Expand Down

0 comments on commit 25c5150

Please sign in to comment.