advplyr / audiobookshelf-app

Mobile application for Audiobookshelf
https://audiobookshelf.org
GNU General Public License v3.0
1.27k stars 172 forks source link

Chromecast Fails To Cast From Android Phone #651

Closed wesf99 closed 1 month ago

wesf99 commented 1 year ago

Steps to reproduce

  1. Select and Play audiobook on android phone (direct play via streaming)
  2. Press the Chromecast Icon and Select the Device to Cast To (the icon turns green and the device beeps to show connection made)
  3. The Play Button on the phone Screen "spins", the "cast to" device shows the audiobookshelf screen but nothing plays.

Expected behaviour

Actual behaviour

For the books that do play, I hear the book on the "cast to" device with details of the current track, book cover and play back controls (Google Nest Display).

For the Books that don't play, I simply get a screen on the "cast to" device that says "ready for an audiobook cast", the word "audiobookshelf" and the audiobookshelf icon

For the books that crash the app, I get the same display as books that don't play, but the phone shows a system message "Something went wrong with audiobookshelf" audiobookshelf closed because the app has a bug

Environment data

Audiobookshelf Version: Server: docker v2.2.17 (Synology DS1821+, DSM 7.1.1-142962 Update 4)

Android Issue

Android version: 0.9.63-beta

Device model: Samsung S23 +

Stock or customized system: stock

iOS Issue

iOS Version:

iPhone model: Books That Dont Play Books That Don't Play Books That Dont Play

advplyr commented 1 year ago

What version of Android are you using?

I know you mentioned streaming but are any of these books downloaded on the device?

Can you try to first cast then play the audiobook for the first time? For this you would need to close any cast you have open, then close the audio player, then cast from the appbar, then go to the book and press play.

wesf99 commented 1 year ago

I’m running android version 13, patch security leve1: 1 March 2023

No files are downloaded, as I had seen people had problems casting from local files.

I opened the app and tried to cast before selecting the book to play. The first time I tried this, the app just shutdown with no messages. The next time I tried this, the same issue. Works for some books but not for others.

Thanks for looking at the problem. Audibookshelf is shaping up to be a great app

From: advplyr @.> Sent: Wednesday, March 29, 2023 5:28 AM To: advplyr/audiobookshelf-app @.> Cc: wesf99 @.>; Author @.> Subject: Re: [advplyr/audiobookshelf-app] Chromecast Fails To Cast From Android Phone (Issue #651)

What version of Android are you using?

I know you mentioned streaming but are any of these books downloaded on the device?

Can you try to first cast then play the audiobook for the first time? For this you would need to close any cast you have open, then close the audio player, then cast from the appbar, then go to the book and press play.

— Reply to this email directly, view it on GitHub https://github.com/advplyr/audiobookshelf-app/issues/651#issuecomment-1487617515 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ANFXZBNTNDYUAK2WATUPGUTW6NJW5ANCNFSM6AAAAAAWKB7WPA . You are receiving this because you authored the thread. https://github.com/notifications/beacon/ANFXZBP5E3H3JBTPADMKKJ3W6NJW5A5CNFSM6AAAAAAWKB7WPCWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSYVM66W.gif Message ID: @. @.> >

wesf99 commented 1 year ago

PS.

I am able to cast and play local files from Booksonic while offline or online.

From: advplyr @.> Sent: Wednesday, March 29, 2023 5:28 AM To: advplyr/audiobookshelf-app @.> Cc: wesf99 @.>; Author @.> Subject: Re: [advplyr/audiobookshelf-app] Chromecast Fails To Cast From Android Phone (Issue #651)

What version of Android are you using?

I know you mentioned streaming but are any of these books downloaded on the device?

Can you try to first cast then play the audiobook for the first time? For this you would need to close any cast you have open, then close the audio player, then cast from the appbar, then go to the book and press play.

— Reply to this email directly, view it on GitHub https://github.com/advplyr/audiobookshelf-app/issues/651#issuecomment-1487617515 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ANFXZBNTNDYUAK2WATUPGUTW6NJW5ANCNFSM6AAAAAAWKB7WPA . You are receiving this because you authored the thread. https://github.com/notifications/beacon/ANFXZBP5E3H3JBTPADMKKJ3W6NJW5A5CNFSM6AAAAAAWKB7WPCWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSYVM66W.gif Message ID: @. @.> >

wesf99 commented 1 year ago

I have tried to examine the mp3 files that don't cast. I am unable to determine anything that is broken or common between them. I have tested them using MP3 Diags with no unusual messages. I have tried repairing/re coding them using VLC Media player and AVS Audio Converter without success. The only thing that has worked is recoding the mp3 files (usually split into 3 minute files to aid moving forward and backwards easily) into one large mp3 file with chapter's using AudiobookConverter 6.1.2.

lhassell commented 1 year ago

Can confirm same issue. Casting from pixel 5 on latest version of Android OS fails. It connects, but will not play files. In my case, I am connected to audiobookshelf instance via reverse proxy, but server is on same local net and accessed via a DNS alias (i.e. server is locally hosted at IP 192.x.x.x, and router is programmed to reroute DNS requests to outside set er back to that IP)

advplyr commented 1 year ago

One potential issue is if the files you are trying to cast cannot be direct played. I don't believe chromecast support HLS streaming at all so make sure when you play a file regularly it isn't being transcoded. You can tell by opening the audio player up full screen and there will be either "Local", "Direct" or "Transcode" displayed at the top.

Additionally, last I check chromecast is more strict on which audio codecs it supports then regular android device

lhassell commented 1 year ago

As a test, I tried connecting directly to the server (via the internal IP, instead of by the reverse proxy alias) and it worked. I think, in my case at least, it may be related to the reverse proxy / internal LAN interface.

lhassell commented 1 year ago

Did a little digging and was able to set up some hairpin nat rules that fixed the problem. Used https://help.ui.com/hc/en-us/articles/204952134-EdgeRouter-Hairpin-NAT as a guide.

lhassell commented 1 year ago

Ok... new issue with the app in the last couple of versions. Weirdly, cast only seems to work to devices that have a screen (GoogleTV, etc...). When I try to cast to a speaker-only device, it connects, but the app just hangs with a waiting animation in the place of the play button. Please let me know if there are any details or logs I can provide to assist.

lhassell commented 11 months ago

Wondering if anyone has looked at this issue.

sluggathor commented 7 months ago

As mentioned, this seems to be connected to setups using a reverse proxy to access the server. Setting up static routes for Google DNS servers (8.8.8.8, 8.8.4.4) to your local dns server (probably local gateway ip) fixes the spinning play button and makes casting work.

Edit: fixes it for me at least.

lhassell commented 6 months ago

No such luck. As I had stated, it will still cast to devices that have a screen (android TV, nest home hub, etc...) but fails and just sits there spinning when casting to audio-only devices.

wesf99 commented 6 months ago

Just to confirm my setup is now working on my Samsung S24 Ultra. I either connect to my synology server via local IP or reverse proxy. I can cast to audio only devices and screen based devices. I do need to be patient to allow the spinning to stop and then press play on the phone again.

wesf99 commented 6 months ago

Just adding some more information. Casting fails to the older chromecast audio devices. They are the ones that connect to a speaker via a 3.5mm DIN plug. Other audio only chromecast devices seem to work for me.

lhassell commented 1 month ago

Have been playing with this. Hoping someone can point me at the solution. I think I'm close. ABS running via docker on a synology NAS, using the synology reverse proxy attached to a namecheap DNS. In order to resolve the domain name iside the LAN, I have a static DNS route on my router pointing the domain name at the internal IP address. If I log into the server using the IP address instead of the domain name, it works.

Am I using the wrong tool with the static route?

lhassell commented 1 month ago

Just to update anyone coming later, I found the issue in my particular situation. I was double-NATed. Once I set up my ISP's router to bridge the network connection directly to my router, the issue was resolved.