Playing sounds on openhab clients

Okay Pierre,

I do now understand that what you are documenting is EXACTLY what you’re experiencing, rather than what you intend.

So…

(Please excuse my approach)

Have you checked the basics?

Have you got a PaperUI running on a device that you are happy plays sounds from other sources? (By which I mean, have you played some music on your phone, then opened PaperUI in a web browser on that device)

Which UI are you running on the clients that aren’t responding?

Which flavour of web browser are you using (good tip @mstormi)

Is the volume turned up for that device / or for that bit of software in the audio mixer on that device.
(I know for example that Windows machines allow different volumes for different applications)

Just got that to work on my Windows machine for the first time.
Had to start Internet Explorer though, it did not work with Firefox.

@isabellep do you happen to run a browser on your OH server ?
Would at least explain the sound there.
And on clients it seems to be browser dependent at least.
Also check the output of smarthome:audio sinks to see if the webaudio sink is there.

1 Like

I’ll confess that I’ve only ever used Google Chrome (or Chromium)

The sound comes out fine through Chrome running on the Windows 10 machine which is hosting the OH server.

I tried to get the sound as well on two different client machines.

  • a Windows 10 machine pointing either Chrome or IE to the paper UI on the server machine. I can interact with the paper UI allright but it does not get any of the sounds sent when my rule triggers playSound(“webaudio”,“doorbell.mp3”).

  • an Android phone running Chrome and accessing the paper UI in the same, with the same unfortunate result. I also tried without success using the OH app on the same phone (I suppose this was to be expected as this is not a web browser).

For good measure, I also tried using the OH console on the server machine:

smarthome:audio play doorbell.mp3

The result was the same.

Perhaps there is a bug in the Windows 10 implemantation?

@MDAR @mstormi

Somehow, just a minute ago it started working after I restarted the system. I have no idea what is going on, but for the time being it does work. Thanks.

1 Like

This is very strange.

It really should just work now.

Update

Okay, so now it works it should keep on working.

I’ll keep my fingers crossed for you

@MDAR

Thanks alot!

You mentioned that you have also been able to send sounds to “specific audio sinks like my Chromecast devices”. Can you point me to some info about hos such specific sinks can be defined?

No worries :slight_smile:

Other audio sinks are easy…

You just need to identify how your copy of openHAB2 names them.

Just replace webaudio with the full name of the audio sink.

Thanks for the tip but unfortunately I am not expert at all on such issues. Could you give me of how to find the right name for a given sink, given that my server is running on Windows 10?

Le lun. 18 mars 2019 à 15:29, Stuart Hanlon via openHAB Community bot@community.openhab.org a écrit :

Sorry about my last post: the answer to my question is obviously the command ‘smarthome:audio sinks’.

The more relevant question I had in mind was how can one add new sinks? Is this a matter to be raised only at the OS level (in my case Windows10). I just paired and connected a bluetooth speaker to my Windows server machine. After restarting the OH server, the list of available audio sinks does not include that new Bluetooth sink.

Le lun. 18 mars 2019 à 15:29, Stuart Hanlon via openHAB Community bot@community.openhab.org a écrit :

Now there’s a question.

I’ve no idea how to send audio to a Bluetooth speaker, I assumed a simple one would only stream audio from its paired audio source.
Unlike a device that has a player built in and is instructed “what to play”, rather than just fed a stream.

So would JavaSound or AdvancedJavaSound work?

Just for reference,

When I run the smarthome:audio sinks command in a Karaf console on one of my machines, I get this response

openhab> smarthome:audio sinks
    * Bathroom (chromecast:audio:3f5b31d2c7d792037ef036c498c40a1c)
    Cabin (chromecast:chromecast:dc1c3cdca7c119edda07b157b89213ed)
    Lounge ChromeCast (chromecast:chromecast:9fcd8320e1763a302be40c2accd5decf)
    System Speaker (javasound)
    System Speaker (with mp3 support) (enhancedjavasound)
    TV Room ChromeCast (chromecast:chromecast:aa06742fcb32f738f264f256ad1540c7)
    Web Audio (webaudio)
openhab>

So a playSound command for me might look like this

playSound ("chromecast:audio:3f5b31d2c7d792037ef036c498c40a1c", "doorbell.mp3")

Thanks for the examples.

Were the Chromecast sinks added automatically to your list of available audio sinks upon the discovery of the Chromecasts?

Hi

Yes, that’s exactly what should happen when Things are added to openHAB2.
(Or at least, that’s my understanding)

Good: this was the missing piece in my puzzled head!

Actually, I do own a Chromecast, but for some reason the automatic discovery process does not find it (nor anything else) on my LAN. Not sure if I need to enable some setting for automatic discovery to work.

I then tried to enter the Chromecast manually in the inbox. I provided its IP address and letting the default values remain on the rest (including port number). The Chromecast was found as a " Network device with running service" and only generic channels were provided (online, latency, last seen). No audio sink was added.
Do you know what is missing?

Hi

It sounds like you’ve got something blocking traffic to me.

The Chromecast binding is particularly robust.

Simply having the binding loaded and doing the normal routine to add a Chromecast to a WiFi network is enough for openHAB2 to detect it.

By the looks of this statement

Should I assume that you’ve used the Network binding instead of the Chromecast binding?

Indeed, I did use the Network binding. I had not realized that a dedicated one was available for the Chrocast.

Thanks for letting me know. I will try it soon.

1 Like

My Chromecast was auto,matically found, and it now appears in the list of available audio sinks.

Many thanks once again.

1 Like

The Network binding is only intended to look and see if something is present, not to “use” it

Hello,
I want to explain how to solve playin sound problem on BasicUI.
The problem is, you are not able to play any video/audio more than once. Because the page loads Auido file once while page loading, so the sound file plays at once, but you can play audio files on PaperUI whenever you want or when something triggered. However, the clients not able to play sounds automatically on BasicUI.
How to solve this issue, it’s smart way below;
Add webview on sitemap, and sitemap url have to be your paperUI url (http://openhab:8080/paperui/index.html) but you may not want to show whole page on BasicUI, so add visibility parameter to webview, for example Button item’s value never be 10, so the iframe never showed up on BasicUI, but already loaded at background.

Webview url=“http://openhab:8080/paperui/index.html” height=5 icon=“none” visibility=[Button==10]

just add code above to sitemap :slight_smile: (change Button to any your object/thing name)

1 Like

Wow, man. You are smart like hell. Thanx! :slight_smile: