Skip to content
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

Merged
merged 1 commit into from
Nov 1, 2023
Merged

[webaudio] Allow stopping play #3766

merged 1 commit into from
Nov 1, 2023

Conversation

dalgwen
Copy link
Contributor

@dalgwen dalgwen commented Aug 20, 2023

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

Signed-off-by: Gwendal Roulleau <gwendal.roulleau@gmail.com>
@dalgwen dalgwen requested a review from a team as a code owner August 20, 2023 11:06
@J-N-K J-N-K requested a review from lolodomo August 27, 2023 11:55
return;
}
logger.debug("Received audio stream of format {}", audioStream.getFormat());
if (audioStream instanceof URLAudioStream urlAudioStream) {
Copy link
Member

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?

Copy link
Contributor Author

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.

@J-N-K J-N-K requested review from lolodomo and removed request for lolodomo September 8, 2023 16:29
Copy link
Member

@J-N-K J-N-K left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@J-N-K J-N-K merged commit 26283da into openhab:main Nov 1, 2023
@J-N-K J-N-K added the enhancement An enhancement or new feature of the Core label Nov 1, 2023
@J-N-K J-N-K added this to the 4.1 milestone Nov 1, 2023
@dalgwen dalgwen deleted the webaudio_stop branch November 4, 2023 07:33
florian-h05 pushed a commit to openhab/openhab-webui that referenced this pull request Nov 8, 2023
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants