{"id":19654964,"url":"https://github.com/kilianb/java-sonos-controller","last_synced_at":"2025-08-15T15:09:03.628Z","repository":{"id":144583043,"uuid":"131424110","full_name":"KilianB/Java-Sonos-Controller","owner":"KilianB","description":"Sonos controller api with UPnP event support. Examples show text to speech on speakers and local music file playback.","archived":false,"fork":false,"pushed_at":"2022-08-30T12:25:43.000Z","size":399,"stargazers_count":12,"open_issues_count":5,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-28T17:46:35.501Z","etag":null,"topics":["controller","java","sonos","upnp"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KilianB.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-28T16:04:59.000Z","updated_at":"2025-01-19T16:25:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"678a240a-7a74-4802-b507-14ceb7bf2a2c","html_url":"https://github.com/KilianB/Java-Sonos-Controller","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/KilianB/Java-Sonos-Controller","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KilianB%2FJava-Sonos-Controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KilianB%2FJava-Sonos-Controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KilianB%2FJava-Sonos-Controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KilianB%2FJava-Sonos-Controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KilianB","download_url":"https://codeload.github.com/KilianB/Java-Sonos-Controller/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KilianB%2FJava-Sonos-Controller/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270586168,"owners_count":24611314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-15T02:00:12.559Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["controller","java","sonos","upnp"],"created_at":"2024-11-11T15:18:58.293Z","updated_at":"2025-08-15T15:09:03.558Z","avatar_url":"https://github.com/KilianB.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[ ![Download](https://api.bintray.com/packages/kilianb/maven/Java-Sonos-Controller/images/download.svg) ](https://bintray.com/kilianb/maven/Java-Sonos-Controller/_latestVersion)\n\n# Sonos-controller\nJava API for controlling [SONOS](http://www.sonos.com/) players. \n\n\u003cp align= \"center\"\u003e\n\u003cimg src =\"http://blog.vmichalak.com/wp-content/uploads/2017/01/SONOS_controller_header.png\" /\u003e\n\u003c/p\u003e\n\n\n## Available via Bintray and JCenter\n\nStarting with version 2.0.0 at least Java 10 is required.\n\n```\n\u003crepositories\u003e\n\t\u003crepository\u003e\n\t\t\u003cid\u003ejcenter\u003c/id\u003e\n\t\t\u003curl\u003ehttps://jcenter.bintray.com/\u003c/url\u003e\n\t\u003c/repository\u003e\n\u003c/repositories\u003e\n\n\u003cdependency\u003e\n\t\u003cgroupId\u003egithub.com.kilianB\u003c/groupId\u003e\n\t\u003cartifactId\u003esonos-controller\u003c/artifactId\u003e\n\t\u003cversion\u003e2.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Basic Usage\n\nDiscovery all Sonos Devices on your network.\n\n```java\nList\u003cSonosDevice\u003e devices = SonosDiscovery.discover();\n\n//Asynchronous\nSonosDiscovery.discoverAsynch(3, device -\u003e{\n   System.out.println(\"Device: \" + device + \" found\");\n});\n\n```\n\nConnect to a known Sonos and pause currently playing music.\n\n```java\nSonosDevice sonos = new SonosDevice(\"10.0.0.102\");\nsonos.pause();\n```\n\n## UPnP Event Handling\n\nRegister event handlers to gain immediate access to update events\n\n```java\nsonos.registerSonosEventListener(new SonosEventAdapter() {\n\t\n\t@Override\n\tpublic void volumeChanged(int newVolume) {\n\t\tSystem.out.println(\"Volume changed: \" + newVolume);\n\t}\n\n\t@Override\n\tpublic void playStateChanged(PlayState newPlayState) {\n\t\tSystem.out.println(\"Playstate changed: \" + newPlayState);\n\t}\n\n\t@Override\n\tpublic void trackChanged(TrackInfo currentTrack) {\n\t\tSystem.out.println(\"Track changed: \" + currentTrack);\n\t}\n}\n```\n\nGain full access by utilizing the entire range of callback methods found in the [SonosEventListener.java](https://github.com/KilianB/Java-Sonos-Controller/blob/master/src/main/java/com/github/kilianB/sonos/listener/SonosEventListener.java).\n\n\n## More examples\n\n### 1. Text to speech playback on any sonos speakers\n\nA small example utilizing my \u003ca href=\"https://github.com/KilianB/GoogleTranslatorTTS\"\u003eprototyping text to speech library\u003c/a\u003e. \nThe generated mp3 file is hosted on the current machine to make it accessible to the sonos speakers on the network.\n\n\u003ca href=\"src/main/java/com/github/kilianB/example/voiceToTextPlayback\"\u003eSource\u003c/a\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/9025925/46544392-becbb800-c8c3-11e8-90d8-945bf1e3880d.jpg\" /\u003e\n\u003c/p\u003e\n\n### 2. Simple Sonos Desktop Player With Local File Playback\n\nA basic player allowing to playback local music files. Index any folder on your computer, create a track index in a SQL \ntable and make the folders accessible to the network. While you are able to start stop, playback change volume etc,\nthis is just intended to lay out the steps needed to implement local music file playback and not function as a standalone application.\n\n\u003col\u003e\n\t\u003cli\u003e\u003ca href=\"src/main/java/com/github/kilianB/example/localFilePlayer/fileHandling/MusicFileIndexer.java\"\u003eDirectory Crawler \u0026 File Indexer\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href=\"src/main/java/com/github/kilianB/example/localFilePlayer/fileHandling/DatabaseManager.java\"\u003eSQL Database\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href=\"src/main/java/com/github/kilianB/example/localFilePlayer/fileHandling/NetworkFileProvider.java\"\u003eFile Hosting\u003c/a\u003e\u003c/li\u003e\n\u003c/ol\u003e\n\n![sonosspeaker](https://user-images.githubusercontent.com/9025925/46569592-b8871b80-c957-11e8-9095-d4310b4c977b.jpg)\n\n\n\n## Original contribution\n\nA fork of the tremendous sonos controller library originally created by \u003ca href=\"https://github.com/vmichalak/sonos-controller\"\u003eValentin Michalak\u003c/a\u003e. \n\nBased upon this changes include:\n\u003col\u003e\n\t\u003cli\u003eImplementing UPnP event subscriptions\u003c/li\u003e\n\t\u003cli\u003eSwapping out gradle\u003c/li\u003e\n\t\u003cli\u003eLicense change to GPLv3\u003c/li\u003e\n\u003c/ol\u003e\n\nThis repository allows to subscribe to the \u003ca href=\"http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf\"\u003eUPnP 1.1 Event\u003c/a\u003e endpoints enabling to receive continious updates of the devices state. I decided to fork the project instead of issuing a pull request due to the need of it being hosted via maven central within a (short) period of time. A huge portion of the code was being rewritten resulting in breaking changes and no backward compatibility If you look for a MIT version or high test coverage either contact me or take a look at the original repository. \n\n## Up next\n\nInvestigate the UPnP event endpoints.\n\n\u003cul\u003e\n\u003cli\u003e/MediaServer/ConnectionManager/Event\u003c/li\u003e\n\u003cli\u003e/MediaRenderer/ConnectionManager/Event\u003c/li\u003e\n\u003cli\u003e/MediaServer/ContentDirectory/Event\u003c/li\u003e\n\u003cli\u003e/AlarmClock/Event\u003c/li\u003e\n\u003cli\u003e/MusicServices/Event\u003c/li\u003e\n\u003cli\u003e/SystemProperties/Event\u003c/li\u003e\n\u003c/ul\u003e\n\n\nHow are topology changes best are tracked? (New device found  / device disconnected)\nCurrently the library utilizes the `/ZoneGroupTopology/Event` as does the official client.\nBut updates are delayed as much as two minutes.\nA different approach would be to either:\n\n\u003cul\u003e\n\t\u003cli\u003eTimeout if no upnp advertisement is send within a certain timeframe?\u003c/li\u003e\n\t\u003cli\u003eParse topology page of a sonos controler e.g. http://192.168.178.26:1400/status/topology  - polling ....\u003c/li\u003e\n\u003c/ul\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkilianb%2Fjava-sonos-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkilianb%2Fjava-sonos-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkilianb%2Fjava-sonos-controller/lists"}