Controlling Samsung Multiroom Speakers with Python

Blake Bradford Avatar

·

Controlling Samsung Multiroom Speakers with Python

Are you a proud owner of Samsung Multiroom speakers and eager to control them with the power of Python? Look no further – we have you covered! In this article, we will explore how to control Samsung Multiroom speakers using the samsung_multiroom library.

Installation

To get started, you will need to install the samsung_multiroom library. You can do this easily by running the following command:

Basic Functions

pip install samsung_multiroom

Once you have installed the library, you can begin controlling your Samsung Multiroom speakers using basic functions. These functions allow you to get/set volume, switch audio sources, and mute/unmute the speakers. Here’s some example code:

from samsung_multiroom import SamsungMultiroomSpeaker

# Initialise (replace with your speaker's IP address)

speaker = SamsungMultiroomSpeaker('192.168.1.129')

# Get speaker name

speaker.get_name()

# Get/set volume

volume = speaker.get_volume()
print(volume)
speaker.set_volume(10)

# Switch source to connect with your Samsung TV

speaker.set_source('soundshare')

# Mute/unmute

speaker.mute()
speaker.unmute()

Audio Source Browsing

One of the powerful features of the samsung_multiroom library is the ability to browse audio sources on your Multiroom speakers. You can browse DLNA devices and TuneIn radios with ease. Here’s an example of how to browse DLNA devices and print their details:

# Browse DLNA devices

browser = speaker.service('dlna').browser
browser = browser.browse('/nas/Music/By Folder/Air/Moon Safari/CD 1')

for item in browser:
print(item.object_type, item.object_id, item.artist, '-', item.name)

App Integrations

The samsung_multiroom library also provides integrations with various apps, such as Deezer. You can authenticate with these services and browse their content. Here’s how:

# Check available services

names = speaker.get_services_names()
print(names)

# Authenticate with Deezer

speaker.service('Deezer').login('your email', 'your password')

# Browse Deezer content

browser = speaker.service('Deezer').browser
browser = browser.browse('/Browse/Rock/Artists/Queen')

for item in browser:
  print(item.object_type, item.object_id, item.name)

Player Functions

Controlling the player functionality of your Samsung Multiroom speakers is also possible with the samsung_multiroom library. You can play, pause, resume, and get track information. Here’s an example:

# Play a playlist from browser items

speaker.player.play(browser)

# Pause/resume

speaker.player.pause()
speaker.player.resume()

# Get track info

track = speaker.player.get_current_track()
print(track)

Conclusion

In this article, we have explored how to control Samsung Multiroom speakers using the samsung_multiroom library. We learned about the installation process, basic functions, audio source browsing, app integrations, player functions, equalizer functions, clock functions, speaker discovery, speaker grouping, and event monitoring. With this knowledge, you can now leverage the power of Python to interact with your Samsung Multiroom speakers and unlock their full potential.

Remember, with great power comes great responsibility. Make sure to adhere to the licensing terms of the library and respect the rights of others when using this technology.

Happy coding and enjoy your Samsung Multiroom speakers!

References

License: MIT License
Copyright (c) 2018 Krystian Galutowski

Leave a Reply

Your email address will not be published. Required fields are marked *