jellyfin / jellyfin-expo

Jellyfin Mobile for iOS
https://jellyfin.org
Mozilla Public License 2.0
287 stars 63 forks source link

Add Chromecast Support #16

Open anthonylavado opened 4 years ago

anthonylavado commented 4 years ago

AirPlay is natively supported, we just need to add the button in the controls in Web.

To make it a more complete client, Chromecast should be added, to finally give iOS users the option of using it.

A quick search shows that we might have to eject and use ExpoKit, so I'm unsure how to proceed.

brianclinkenbeard commented 4 years ago

Maybe this would help: https://github.com/react-native-google-cast/react-native-google-cast/

anthonylavado commented 4 years ago

For reference:

https://forums.expo.io/t/chromecast-support/4699/2

https://expo.canny.io/feature-requests/p/support-for-chromecast

Apparently it’s been requested since 2017 with no movement, so we’d have to detach ☹️

krutburken commented 3 years ago

Old issue, but are there any current discussions on how to move forward on this? Not having Chromecast support on iOS is probably the only thing keeping me from migrating my users from plex/emby to Jellyfin.

If not, what workarounds are available?

Coo-ops commented 3 years ago

BUMP.

This is an important feature, and the only thing keeping me on Plex in absence of a dedicated client app for Raspberry Pi.

anthonylavado commented 3 years ago

This doesn't need to be bumped. That just adds extra noise and notifications that we have to deal with. Normally you could leave a thumbs up reaction on the top comment, or even upvote the feature request on our dedicated site: https://features.jellyfin.org/posts/466/chromecast-support-on-ios

We know it is in demand. Thornbill even pinned this just a few hours ago to show that we're aware of it.

It's still not possible yet for a variety of reasons that I've shared before on Reddit. I'll find those and post them here some time.

jaredreich commented 3 years ago

Hey folks! Really interested in getting this feature figured out.

Just a quick note to add to the discussion - it appears when chromecasting from Plex for iOS, it actually initiates a cast via the Plex server's address (127.0.0.1:32400) to the device. Shouldn't Jellyfin be doing the same? The Jellyfin iOS app would ping the Jellyfin server for Chromecast devices, return the list to the iOS device, present them to the user, user chooses one to start the connection, then when content is played it's actually the server that is doing the Chromecasting.

I may be completely wrong here, just spitballing, so feel free to disregard. Thoughts?

anthonylavado commented 3 years ago

@jaredreich Almost, not quite. Say you are in a remote location, away from home. In that case, the server can't necessarily reach those devices on that network to cast ;-)

The way casting works (very, very simplified):

jaredreich commented 3 years ago

@anthonylavado thank you very much for the breakdown. Though I must still ask, shall we not implement this feature only because it won't work on an external network? I'd imagine a lot of users are casting at home while on the same network as the Jellyfin server right? Are there other reasons it can't be implemented other than not working from external networks?

anthonylavado commented 3 years ago

@jaredreich My apologies if that was the impression - there's other technical reasons why it's not there yet. I was just describing how the process works, and why just sending a session from the server isn't enough.

I realize I never fully explained the reasons here.

This app for iOS is written using a Javascript framework known as Expo. It's a special set of packages and a workflow based around React Native. The good part about Expo is they they make building apps very easy for both iOS and Android. They even take care of the build/compile process for you, so you can create an iOS app without owning a Mac (but you still have to have an Apple Developer Program membership). This is known as the "Managed" process.

The downside to Expo is that in most cases, you're limited to using packages and frameworks that they directly support. It's not possible to simply pull in whatever React Native package you'd want.

In order to add Chromecast playback, we need to add the Cast SDK in a supported way. One of those packages for React Native is linked towards the top, and I'm sure there's many others.

To have Expo include a package, you have to make a feature request, hope it gets their attention/enough votes, and then hopefully they include it. People have been asking for years now (see above again), and it hasn't happened yet.

Now you might be thinking - surely there's a way around this, right? Well, there is. The process is known as "ejecting to ExpoKit". This takes everything you've done as an Expo managed project, and converts it to a React Native project that happens to include some Expo modules. This adds a bit more complexity - builds must now be done on the correct platform. For example, the bundle for iOS would have to be compiled on a Mac, instead of just using Expo's servers. Though I have a Mac, I'm not the primary developer. Heck, I'm not really much a developer at all (my expertise is in other areas for Jellyfin, including "management"). My dear friend @thornbill has mostly been working on this from a Linux machine.

As it turns out, this year there are some things falling in to place that will make this transition easier, and we are getting closer to a solution, including ejecting and then adding on the modules we need.

Hopefully this helped explain it better 😄

Edit: Here's a link from Expo on the different "workflows" - https://docs.expo.io/introduction/managed-vs-bare/

cuibonobo commented 3 years ago

Expo just released a proof of concept on getting Chromecast working on Expo projects without having to eject: https://github.com/EvanBacon/prototype-config-plugins/tree/master/packages/react-native-google-cast

anthonylavado commented 3 years ago

Expo just released a proof of concept...

Yes, we got a notification about this since we have voted on the item. We're investigating.

Our other beta app, Swiftfin, does have Chromecast support in testing as well.

edenman commented 2 years ago

Current version of the app has a Chromecast button but it can't find my Chromecast (it only shows my web browser on my computer and the DLNA device for my audio receiver): want a separate bug filed or is this one still tracking the ongoing effort? Edit: filed as https://github.com/jellyfin/jellyfin-expo/issues/309

anthonylavado commented 2 years ago

@edenman Yep, this is still the correct issue.

All - We are in the process of updating the Expo SDK we're using and will update if there's any more info to provide.

In the meanwhile, if you need Chromecast support, the Swiftfin beta client does have that integrated right now.

edenman commented 2 years ago

Sounds good. And yeah, Swiftfin just unfortunately doesn't support external playback control https://github.com/jellyfin/Swiftfin/issues/177 so I'm sticking with Emby for the time being.

salmi4k commented 2 years ago

Any more information on this?

bloodyburger commented 2 years ago

Any update?

thornbill commented 2 years ago

No updates on this yet. I will make sure to comment here when there is something to report.

JefCarlier commented 2 years ago

Expo have released Chromecast support!

thornbill commented 2 years ago

Yes they did... kind of. It's not implemented as one of their standard packages, but uses their relatively new "config plugin" system. Using these new plugins requires you to build native code which requires a Mac for iOS. This defeats my whole reason for using Expo which allows me to develop for iOS from my normal Linux computer.

Personally I don't see any benefit in using Expo vs standard React Native given this is the direction things seem to be going. Hopefully at some point this year I will pickup a Mac that I am able to develop from and I can move forward with ejecting from Expo to React Native proper.

dkbnz commented 2 years ago

I'm not familiar with Expo but is it feasible to develop the Chromecast support locally on Linux and rely on macOS CI/CD machines to build, test and deploy the app?

GitHub Actions have a macOS runner but consume minutes at a 10x rate.

FerMPY commented 1 year ago

Hey I have a Mac and I'm a dev, I don't have much experience with Expo, but I can help with building and do the testing just need some help to know what I should be looking at. So I can help if the only thing needed to avance with this feature is a Mac. I successfully build the application and added de plugin it still no showing my chrome cast but it's a good start.

rbnmrz318 commented 1 year ago

Any Update?

Skyl3lazer commented 9 months ago

This is still a critical feature for mass adoption.

citric-code commented 6 months ago

@thornbill Is there any update on the likelyhood of this? Was very annoying to spend ages setting up my instance to discover my wife cannot cast to any of our TVs.

I have a Mac and while have not worked on Expo before, am willling to take a look at how this could be implemented with the config plugin system.

thornbill commented 6 months ago

No. See this comment for details. Using the Expo plugin system would remove my ability to develop for or maintain this app.

SvenTheBoyy commented 6 months ago

Any update for this? Would love to see Chromecast support in IOS :)

weiyideai520 commented 6 months ago

When will we probably use Chromecast on iOS clients?

rbnmrz318 commented 5 months ago

For anyone interested, i am using the "infuse" App on iOS to connect my jellyfin instance and stream to my Chromecast. Unfortunately, Infuse does not have any rendering options, so when i am on the go i am using the native jellyfin app. Infuse is at a yearly subscription of 15€

ajbastien commented 4 months ago

Maybe consider a rewrite in Flutter. I’ve tried it and works well. I see some cast plugins for flutter. Although I have not tried them.

thornbill commented 4 months ago

In addition to having absolutely no personal interest in learning Flutter, rewriting in Flutter solves none of these issues.

The main blocker is just that I lack access to a modern Mac to develop on and both ejecting to vanilla React Native or using Expo's native plugin system would require building on a Mac.

Aireezz commented 4 months ago

Can you not implement it to stream directly from the server to the chromecast device like plex? @thornbill

ebg1223 commented 4 months ago

@thornbill im a dev work in RN daily. Have all the tooling. I don’t know if I have time to contribute a full implementation including server. If someone wants to tag team I can contribute some time.

thornbill commented 4 months ago

@Aireezz I have no idea what Plex does, but that is not how casting typically works. Possibly a plugin could be written to include cast devices as targets for the normal remote control feature but that is different than what this issue covers.

thornbill commented 4 months ago

@ebg1223 any help would be greatly appreciated! Although we would probably need to update to a current version of expo before any other work could be done. (See https://github.com/jellyfin/jellyfin-expo/issues/462)

ebg1223 commented 4 months ago

@thornbill thank you. Just posted on that issue.

re chromecast: My understanding is that you need a server url with https publicly accessible and chromecast streams directly from server. I believe Plex goes a step further and has a Plex chromecast app that gets loaded. client.loadMedia({ mediaInfo: { contentUrl: 'https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/BigBuckBunny.mp4', contentType: 'video/mp4', metadata: { images: [ { url: 'https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/images/480x270/BigBuckBunny.jpg', }, ], title: 'Big Buck Bunny', subtitle: 'A large and lovable rabbit deals with three tiny bullies, led by a flying squirrel, who are determined to squelch his happiness.', studio: 'Blender Foundation', type: 'movie', }, streamDuration: 596, // seconds }, startTime: 10, // seconds }}

Do you know how from the client can we get an authenticated url for this stream?

thornbill commented 4 months ago

I'm really amazed this issue has been open 4 years and no one else has ever asked about how this would need to be implemented... 🤣

We would need to write a plugin (similar to the native video player plugin) that gets injected into the webview. The plugin will need to replicate some of the functions available in the normal Chromecast plugin from the web project. Similar to the video player, the plugin will need to post messages to trigger calls to the cast library on the react native side.

That at least provides a very high level overview and I'm more than happy to answer any additional questions.

flashtox commented 2 months ago

bump

We need a solution so we can leave plex completely. plzzzzzzzzzzz