Youtube Music - Media Browser

doh, my bad.
It mostly works :wink:
Trying my google home mini, right now.

Edit:
The home mini works correctly. Just moved to the next track automagically.

1.000.000 - dollar question ā€¦ why is there no progress bar on the browser_mod media_play?

all other player (so far) report the position in track and I ā€œneedā€ this to harden the auto_advance feature ā€¦ (without this hardening the chromcast sometimes jumps multiple tracks for no obvious reason ā€¦)

Please try the new release 20201221_3
JKW

Boom, just played the next track.
Thanks for all your hard work.

1 Like

Does 20201221_3 contain support for browser_mod? Iā€™m not seeing it listed in the available speakers list. it does show up in my devices, and I can play to it thru other means.

sure does ā€¦ should be in the list ā€¦ or click directly on the player ā€¦ that more-info dialog should also have the browser button
JKW

got it, its working for me now. (think it needed a reboot)

Great work! I have everything working but no soundā€¦
I have Sonosā€¦ It gives me the error "Sonos does not support a media type of ā€œaudio/mp3ā€ in the log of Home Assistantā€¦ So this is a no for me then?

Hi, Iā€™m not sure if that is a general issue with sonos or something that me can fix. Reading

Makes me believe that it is possible to stream a mp3. Can you confirm that you can stream a mp3 file via the play_media service ?
Jkw

Edit: so does it really matter to use ā€œmusicā€?
I use audio/mp3 at the moment ytube_music_player/custom_components/ytube_music_player/media_player.py at cfebe6c279e3b0aebbe21a6dc9330afb2c4a7622 Ā· KoljaWindeler/ytube_music_player Ā· GitHub

Edit2: would you feel comfortable with editing that line in the media_player.py to test if it would work with ā€œmusicā€ ?

Hi,

Already tried to edit the media_player.py and changed audio/mp3 to music. Also tried audio/mp4 does not work.
Red somewhere that you need to present the full link to Sonos in order to make it workā€¦ But that was a test to local mp3 files, so that should work.

If you use ā€˜musicā€™ as the content_id i get ā€œIllegal MIME-Type from 192.168.x.xā€ in the logā€¦

EDIT: something like this works with Sonos: http://hass_ip:8123/local/your.mp3

Youtube Music works fine trough the Sonos appā€¦ I have no clue if i can find out what kind of info it sends to Sonos in order to make it playā€¦

Strange that it works locally.
You can add a ā€œ_LOGGER.error(_url)ā€
Right here https://github.com/KoljaWindeler/ytube_music_player/blob/cfebe6c279e3b0aebbe21a6dc9330afb2c4a7622/custom_components/ytube_music_player/media_player.py#L859
To get the youtube link and try sending that with various ā€œmusicā€ etc to your sonos. Or even download the file locally and then send the command ā€¦ You knowā€¦ figuring out if the type is the problem or the location ā€¦ or whatever :wink:

So do you want me to add this line below the highlighted line, or replace it with _LOGGER.error(_url) ?

Tried it with replacing, and i do get a bunch of errors but i think it plays by video id or something:

{ā€˜videoIdā€™: ā€˜KLvRXYwZNRYā€™, ā€˜titleā€™: ā€˜Zara Larsson - I Would Like (MAGNƜS Remix)ā€™.

After that there is all the information visible that you normally find in the description of every youtube videoā€¦

just add it below
_url = res['url'] + "&sig=" + signature
so you can see it on the log.
JKW

well, that makes my Sonos speakers go to unavailable

well its very hard for me to understand what ā€œthatā€ means. Adding the log output? That seams fairly unlikely.

But anyway ā€¦ you could try to replace the mp3 line with MEDIA_TYPE_TRACK

ATTR_MEDIA_CONTENT_TYPE: MEDIA_TYPE_TRACK,

at least thatā€™s what the spotify integration is usingā€¦
JKW

edit: just tested with my chromcasts ā€¦ works fine here ā€¦ but then again ā€¦ also mp3 worked ā€¦ so I have the feeling that the chromcast pretty much ignores this anyway

Allright so i tested a bit more.

Adding MEDIA_TYPE_TRACK instead of ā€˜audio/mp3ā€™ or ā€˜musicā€™ does not work.

What i do have is the url how it wants to play:

Any chance that you could test the spotify Integration?
All above looks correct, the url works ā€¦ At this point Iā€™m pretty clueless what could be the problem.

I donā€™t have a sonos so I donā€™t know if play_media works with online stored media at all ā€¦

Jkw

I will try to test the Spotify integration later. Waiting on the premium subscription to be active.

Tested some .mp3 files over the internet which works on my Sonos. Apart from that, Iā€™m nowhere near a dev or anything like that, so if you are clueless, than Iā€™m automatically too :stuck_out_tongue:

Maybe, but you have the hardware on site :wink:
Have you tried to download a track from youtube to a local place like your www folder and send your sonos a link to that file?
E.g. test.mp3 in the www folder and send http://IP.8123/local/test.mp3 to the speaker
Jkw

Well, not on my own Home Assistant instance. I have SSL setup and it cried about an ssl issue or something. But I have found a link to a public MP3 files which plays without any issue.
ā€œhttps://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3ā€

Well basically the following thing can be the issue from my view:
1.) Sonos canā€™t play online stored files at all
2.) The media type has to be different from audio/mp3
3.) The youtube link are too long
4.) The youtube links are ssl
5.) The YouTube links donā€™t provide proper file type suffixes
6.) Something else in the file isnā€™t compatible with sonos

Youā€™ve tested 1.) And 2.) And 4.)
The next logical step would be to grab the file from youtube and store/play it locally. Either with a shorter filename and with/without file type suffix

Jkw