nextcloud / android

📱 Nextcloud Android app
https://play.google.com/store/apps/details?id=com.nextcloud.client
GNU General Public License v2.0
4.09k stars 1.74k forks source link

Support direct rendering from server to Chromecast #996

Open yajo opened 7 years ago

yajo commented 7 years ago

Let me tell you a story 😊

Mrs. Peabody wants to display pictures to her parents. She currently uses Google Photos. Opens the app, turns on the TV+Chromecast, presses the cast button, and pictures & videos show on the TV as she swipes on them in her phone. She has some 60fps videos from her last snowboarding holidays and the video renders perfectly smooth in TV (a little low-res at the beginning until buffer catches up, but nobody notices).

Mr. Peabody wants to move from Google to Nextcloud - for obvious reasons -, but cannot do that until his wife is able to show pictures to her parents in the TV comfortably. This includes:

Right now only screen mirroring works, but it's clunky.

Can we help Mr. Peabody?

Actual behaviour

Expected behaviour

su-ex commented 6 years ago

Just to bring some attention into this because I really have to admit streaming is not easy using a Nextcloud setup. The only way I found streaming to TV is using an extra DLNA server with directories used as local external storage in Nextcloud. Then extra application for all devices and so on and so on and bla blub blub. Also this only works good when I'm at home. Sharing to others Chromecasts or whatever is hell. If Nextcloud wants to be a real alternative to Googles cloud for example, then there needs to be a huge simplicity boost (which happened to the server over the last few months (updating built in and so on)). But Nextcloud is far away from even only a few taps to mirror to TV or stream music to soundsystem which are features a cloud should really have. I can only tell from people I know who forget every single step so they will never get anything this complicated way to a streaming device, they forget every single step once they heard it but got used to the single tap to stream icon which is really easy and that's exactly how it should be. So huge +1 for that.

jorisgu commented 6 years ago

That would be awesome !

tobiasKaminsky commented 6 years ago

Due to our menpower I think this will not be avaible within the nearer future, but help is always welcome and if someone wants to give it a try, I will help him/her.

su-ex commented 6 years ago

I took a video, made it shared by link, added "/download" in the end and could "stream" the video through continuous downloading in VLC. So a simple approach would be to automatically generate some link share with some token which can be the streaming endpoint given to a Chromecast or DLNA renderer. Of course this would need multi-link share (what I read somewhere ownCloud supports since some time) and maybe hiding of the auto-generated links in the GUI and some sort of auto-purging.

BloodyIron commented 5 years ago

I just want to be able to chromecast pictures and other media from my phone/tablet/computer to a Chromecast!

I think this would be GREAT for presentations! You can preview/queue up pictures or other content prehaps, that way you can see things the audience can't (let's say it's inappropriate or irrelevant content).

This could be great for business presentations too. Use it as rapid ways to share/show content to a room, not just family!

But right now, I'm in a very situation where I'm visiting family, they have chromecast, and most of my pictures are on nextCloud, but I don't have a way to present them! :(

What would it take for this to happen? And can the preview generation task potentially accelerate it?

Excited if we can get this! :D

tobiasKaminsky commented 5 years ago

What would it take for this to happen?

Time and a chromecast ;-) But to be honest this is not that high on the roadmap…

davideperozzi commented 5 years ago

I stumbled upon the same problem and managed to get video streaming to work by using a DLNA streaming app like "LocalCast" or "BubbleUPnP", combined with "MX Player". Now I just need to select the video I want to stream via the Nextcloud app and hit the "Stream with..." button and then select a DLNA streaming app which will stream the video to the chromecast, that you've selected in your DLNA app. Sounds like a lot to care about, but once its set up, you don't need to worry much about it. Hope this helps someone out there! :)

tobiasKaminsky commented 5 years ago

Cool, nice workaround!

Zuikkis commented 5 years ago

Sad that this is not "high on the roadmap". For me this is the number one reason I can't completely switch from Google cloud..

Playing video and photos on chromecast is easy. The API is public:

https://developers.google.com/cast/docs/developers

The are several open source client implementations. I have tried this one in python:

https://github.com/balloob/pychromecast

It's easy to do a python program that casts any http/https stream to chromecast. It works just fine if I get a public share url in Nextcloud, append /download to get direct link to media, then play on chromecast with the python script.. can't be that difficult to add to android app directly?

tobiasKaminsky commented 5 years ago

can't be that difficult to add to android app directly

It is not always about how difficult a task is, but in this case it is mainly a tradeoff between time of developers and impact of the features. E.g. I am currently working on making photo view a lot better, which is reported/complained about by more than 30 people and is a feature that exists, but is somehow broken. And this is a new feature…

Please do not get me wrong. If someone (or even me at some point) will implement it, I am happy to help.

Zuikkis commented 5 years ago

Thanks for your reply! I understand.

I found reasonably simple workaround. Google Photos android app seems to be able to stream an url to chromecast.. Just select "Stream to... " in Nextcloud app, and select Photos. It plays smoothly.

There are other apps in Play store, like "Server Cast" which also seems to work. But it always likes to re-encode the video on phone instead of passing direct url to Chromecast. According to docs this only happens if the video format is incorrect for Chromecast, but I don't understand how "Photos" can play the same video? Unless it's routing it through some google server for re-encoding, horrors..

I'll inspect further. :) My original plan was to minimize Google use, so now it's slighly annoying if Photos works best for video streaming..

Zuikkis commented 5 years ago

There is some bug in the server itself, it does not serve the file properly when Chromecast requests it. That's why "Server Cast" has to route it through phone.

I opened an issue in nextcloud/server..

https://github.com/nextcloud/server/issues/16298

Zuikkis commented 5 years ago

Ok.. It is same site cookie protection that breaks Chromecast. "Stream to.." function starts working if you add this to config.php:

'csrf.optout' => array( '/^WebDAVFS/', // OS X Finder '/^Microsoft-WebDAV-MiniRedir/', // Windows webdav drive '/CrKey/', // Chromecast ),

Then you can view videos with "Server Cast" app without routing the video through phone. Directly from nextcloud to ChromeCast! Very nice and smooth.

Only problem is, if you have a folder with mixed photos and videos, you have to switch back and forth from screen mirroring for photos to Server Cast for videos..

jakobroehrl commented 4 years ago

@Zuikkis Thanks for your effort, chromecast is importortant. What dou you think of integrating https://jellyfin.org? Maybe it's easier/quicker to connect it to nextcloud for audio/video streaming than implementing chromecast in the nextcloud App.

Zuikkis commented 4 years ago

I have tried both Emby and Plex and gave up on both.. Haven't tried Jellyfin, but I read it's based on Emby which is not that good first impression. .NET gives me shudders. :)

Oh, I also should update my above samesite comments. Nextcloud server has a much bigger cookie problem than just chromecast, but it can be mostly fixed by adding single line to apache.conf.. doesn't need the csrf.optout fix then.

h3xduck commented 3 years ago

It's been some years since this issue was opened but unfortunately none of the solutions proposed here worked for me. Until someone finds some time to address this, I wanted to share how I managed to achieve this feature, just in case it helps someone.

TL;DR: Install a DLNA server and give it access to a specific nextcloud folder.

Other solutions mentioned here

As in this comment https://github.com/nextcloud/android/issues/996#issuecomment-460060761 DLNA seems the way to go, but unfortunately I found some other problem with it. Whenever I tried the "Stream with" option, VLC, LocalCast, MXPlayer, and any other application just didn't load the video. I found this other issues related: #3064 and #5221 . However, I was able to connect Kodi to the WebDAV server and stream media (on my phone) from there. Unfortunately Kodi still does not support directly streaming to a chromecast, as in the case of the nextcloud app. Still, if I tried to stream to any of the DLNA apps mentioned before, I found exactly the same issue as before, no media could be loaded. I am mentioning all of this because, if any of the above works for you, or you find some way to connect to chromecast after streaming via WebDAV, you might try those first since I feel they are less "hacky" workarounds than mine.

My workaround

Instead of only using DLNA apps, I installed a DLNA server together with nextcloud's. Personally, I chose MiniDLNA. The user creates a folder (which will be the one with the media to stream) and then, using VLC or other app mentioned before, you will be able to connect to it, stream your media and connect to the chromecast. Note that the DLNA server needs to be added to nextcloud's user group in order to access the files. As @nachoparker mentioned on https://www.reddit.com/r/NextCloud/comments/7mg7j8/nextcloud_and_minidlna/drumwcs/ this shouldn't be a problem since the DLNA server will only perform read operations.

BloodyIron commented 3 years ago

Chromecast devices do not accept DLNA signalling... Have you even tested this? Because it sounds like you haven't.

h3xduck commented 3 years ago

Yes, I did. It is currently up and working. I did not say the Chromecast connects to the server, since as I mentioned you still need some app such as VLC, which is the one connecting to the server and later streaming to the Chromecast. My apologies if I didn't explain myself.

fantome commented 3 years ago

I want to cast my photos from nextcloud server to chromecast. So I start to looking how to do that. I have created a small test android app and a web receiver app. And I can display public image on my chromecast. But I don't know how to take credential from NextCloud app and give to chromecast for access to private file on my nextcloud server.

The web receiver app is basically a web page where I can use standard XMLHttpRequest (or if is easier I can load nextcloud JS files).

Someone have ideas of how take credential information in android apps ? And how to use it in JS code to access my files ?

arthuragone commented 1 year ago

2 years and a half since last post. Will do a little bump. This is for sure a big needed option to get rid of proprietary solutions Kudos to all the volunteers