Strixx76 / samsungwam

Home Assistant Integration for Samsung Wireless Audio speakers.
MIT License
10 stars 6 forks source link

Play Media #3

Open pbuergi opened 7 months ago

pbuergi commented 7 months ago

Thank you very much for this integration. Works for me. Only Media ia m missing. Would be really nice if that would be implemented as welll ;)

Strixx76 commented 6 months ago

I totally agree with you, and it is the next feature to be implemented after I implemented a function for keeping the connection alive. But I have very limited time to work on this.

Jeremwhy commented 6 months ago

Highly waited feature, thanks for your work !

square-spade commented 5 months ago

Is the keep alive a general function or specifically used for play media? I'm happy to start/help with the play media function (and grouping would be epic). Let me know if I can lighten your load at all :)

Strixx76 commented 5 months ago

No. There is no need for the one or the other.

The API to use to be able to implement this feature (and groupnig) is already in my local dev branch for a long time. The problem is that the speakers doesn't check if the url you are sending is a playable item. And you can only send a supported stream. Many url is a playlist with only one stream, and if you send this to the speaker it will freeze and you you will have to unplug it.

I have been working for different solutions for this from time to time for over a year, but have not finished them yet. I need to implement both a playlist parser and a function for checking that the stream is supported by the speaker before I release it to the public.

Right now I am about to do a lot of clean up in both this and the pywam lib. I think I will release a new version of the lib soon where this API is exposed, but I will not implement it in the integration until I am finished with the checks of the URL.

Until now I have had the idea that this should be a part of the pywam library. But I think I will remove that, and instead split it up. There is available libs for checking magic numbers that we can use, but I don't want any dependencies in the lib, so that checking would then be handled by the integration. And then I publish the very simple playlist parser as a separate package, also to be used in the integration.

Strixx76 commented 3 months ago

Update: Play media is now implemented in the underlying library and in the integration, but I need some more weeks for testing before releasing it. So far I have been able to test it with the radio stations integration and with local media and that seems to be working fine. Before the end of the month I hope to be ready to release it.

Jeremwhy commented 3 months ago

Update: Play media is now implemented in the underlying library and in the integration, but I need some more weeks for testing before releasing it. So far I have been able to test it with the radio stations integration and with local media and that seems to be working fine. Before the end of the month I hope to be ready to release it.

Great news, thanks for your work !

oliver10110 commented 3 months ago

Using v0.1.0rc1 only volume control works. When trying to play anything, Home Assistant shows error "Failed to perform the action media_player/play_media. async_check_connection..outer_wrapper() got an unexpected keyword argument 'extra'"

Strixx76 commented 3 months ago

I found the bug. I had forgotten one commit when updating the "keep alive feature". Unfortunately I have just discovered another bug when playing DLNA or playing from your phone in the native app, which requires some changes in the underlying pywam package. I will try fix that as well before releasing next candidate.

Strixx76 commented 3 months ago

v0.1.0rc2 is now available where the bug is fixed.

llucax commented 3 months ago

I guess this version is not available in HACS, or? Is there any recommended procedure to install/test rc versions?

Strixx76 commented 3 months ago

I guess this version is not available in HACS, or? Is there any recommended procedure to install/test rc versions?

If you have added it as a custom repository it is available if you choose show beta versions. If it is already installed you have to go to HACS -> Integrations -> Samsung Wireless Audio. And the click on the three dots in the top right corner and choose Download again. Then you will be able to choose to show beta versions.

llucax commented 3 months ago

I just added it via the Download button in HACS, but listing all HACS entities I noted there was a disabled switch entity called "Pre-release" (switch.samsung_wireless_audio_pre_release). I enabled it, flipped the switch and voila! I could update the the rc.

After the update I could play media from TuneIn and some local DLNA server. Amazing! Thanks a lot!

Jeremwhy commented 3 months ago

Hey, i've installed v0.1.0rc2 but can't have the play media working. When switching on the wifi source and trying to play a media i don't have any error message but nothing happens on my HW-H750. Any idea ? Source/volumes controls works well

Strixx76 commented 3 months ago

What media are you trying to play? What log level do you have? You should get a warning in the log if the stream you are trying to play is not supported and therefore not sent to the speaker. I have only tried it with Radio Browser and that works.

But I just tried to play a media file from local media in Home Assistant and I noticed that it will be detected as not supported even though it is. The problem is that the mime type in the header ('text/plain') is not correct. But I guess that is a Home Assistant bug!

I need to have some type of checks so that a none supported stream is sent to the speaker. The speaker has no checks what so ever, and will try to play whatever link you send it. And if it is not supported it has happened that the speaker freezes, and you need to unplug it to get it responding again. But i will see if I can fix some kind of workaround to support local media from Home Assistant the next week. I have some ideas.

But then there also is the risk that your speaker doesn't support that API. According that what I have found on the net, some speakers is not compatible, but I don't know how to tell which is, and which isn't.

Strixx76 commented 2 months ago

There should now be a new RC available where the mime types reported by Home Assistant is trusted if the URL is pointing at your Home Assistant instance. But if the URL is pointing else where, either the file extension or the http is checked instead.

I will update README.md before doing a final release but just for info the API used to play URLs is a bit strange.

Any ideas or input about how to fix the above is welcomed!

pbuergi commented 2 months ago

Thank you for your update. DLNA is working, but only if it is in the same subnet (network). If it is in a different network (subnet) it does not play, even if the firewall is configured and the speaker can be accessed.

Play/Pause would obviously be nice if it works.

Strixx76 commented 2 months ago

Thank you for your update. DLNA is working, but only if it is in the same subnet (network). If it is in a different network (subnet) it does not play, even if the firewall is configured and the speaker can be accessed.

This has nothing to do with the integration. DLNA player is a function in the speaker.