-
-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[webaudio] Allow stopping play #3766
Conversation
Signed-off-by: Gwendal Roulleau <gwendal.roulleau@gmail.com>
return; | ||
} | ||
logger.debug("Received audio stream of format {}", audioStream.getFormat()); | ||
if (audioStream instanceof URLAudioStream urlAudioStream) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can we remove this different handling here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can we remove this different handling here?
I should have explained it better, sorry.
The two cases, as it is now :
- if we recognize an URLAudioStream, we send the URL to the webui, and it will play it directly. It can be (and probably will ?) on another network host / internet. So potential CORS issue.
- If it is not an URLAudioStream, we don't have the choice : we set up the audio servlet to serve the sound. We then send the audioservlet URL to the webui, and the webui will call it to get the sound. From the webui point of view, it is local, so no CORS issue.
By removing the first case, we ensure that the webui will always use the openHAB audio servlet to get the sound.
The URLAudioStream will be used as any other kind of stream : the audioservlet will get the audio sound and act as a proxy.
But there is still an issue with infinite stream. webUI (and webaudio API as it is used) does not support unlimited stream. I'm not knowledgeable enough of the webaudio API for this kind of modification (and it seems pretty hard).
I forgot to mention what happens. The webui will try to fully load the sound before playing it (no streaming support for the kind of play method we use here). Of course an infinite stream has no end, and therefore the sound will never start playing. Incredibly, streaming audio is not standard with the webaudio API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Use of a dictionary to store audio sources currently playing and stop them all when asked to. Refs openhab/openhab-core#3766. Signed-off-by: Gwendal Roulleau <gwendal.roulleau@gmail.com>
By sending an empty string we can ask the webui to stop playing sound, as specification says.
See here for the corresponding webui modification.
Also : By removing the URLAudioStream special case, we force the webaudio servlet to act as a proxy for every audio. It has the benefit of eliminitating CORS issue.
But there is still an issue with infinite stream. webUI (and webaudio API as it is used) does not support unlimited stream. I'm not knowledgeable enough of the webaudio API for this kind of modification (and it seems pretty hard).
The two modifications comes from this community discussion :
https://community.openhab.org/t/webaudio-not-working-when-trying-to-stream-webradio/148610/18