Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Find While on Desktop #2

Open
kristiana-rendon opened this issue May 24, 2018 · 9 comments
Open

Unable to Find While on Desktop #2

kristiana-rendon opened this issue May 24, 2018 · 9 comments

Comments

@kristiana-rendon
Copy link

Hi, thank you for creating this great tool! I was having some issues getting my phone to find mMusicCast on my Windows Desktop. It doesn't show up on the YouTube app as a possible streaming device. I tested to see if it was just my phone, but it was able to find a Chromecast. I also got the following errors:

Thu, 24 May 2018 15:51:06 GMT morgan deprecated undefined format: specify a format at server.js:34:9
Thu, 24 May 2018 15:51:06 GMT morgan deprecated default format: use combined format at server.js:34:9
Thu, 24 May 2018 15:51:06 GMT body-parser deprecated bodyParser: use individual json/urlencoded middlewares at server.js:35:9
Thu, 24 May 2018 15:51:06 GMT body-parser deprecated undefined extended: provide extended option at node_modules\body-parser\index.js:105:29

Do you know what the issue is? Thank you so much!

@vbaicu
Copy link
Owner

vbaicu commented May 24, 2018

Hi,
I've got the same deprecation warnings and everything works fine.
Tested on macOS and Debian linux with the Youtube app on an iPhone. To be honest I didn't test it on Windows.
It would help to know which version of node are you using.
Also, did you grant the firewall access for the application ? This might be the issue your phone is not seeing the "chromecast"

@kristiana-rendon
Copy link
Author

kristiana-rendon commented May 24, 2018 via email

@kristiana-rendon
Copy link
Author

kristiana-rendon commented May 30, 2018

Would it be possible to provide documentation on how your program works, preferably with screenshots? I am having trouble understanding how to connect YouTube from my tablet to your emulator on my laptop (running Ubuntu 18.04). Both devices are connected to the same network.

I am able to run the emulator on my laptop, but when I open up the YouTube app on my tablet, I do not see the Chromecast emulator show up as a streaming option, as I don't even see the casting button. What am I doing wrong?

Thank you for your time.

@vbaicu
Copy link
Owner

vbaicu commented May 31, 2018

Hello,
Though I don't have the time for a proper documentation right now, the working principle is very simple. The application creates a websockets sever on your machine, as you start it, refer to server.js file, on port 8080, opening a few routes. The youtube app on mobile device will check on the local network for devices that have websockets server opened on port 8080 and are chromecast compatible (the routes). If the app finds one or more compatible streaming devices on the local network it will show up the cast button. After you press it, a handshake will be made between the 2 devices and the chromecast will open the desired app.
Now, about your problem, it seems to be a networking issue since you say the emulator is running on desktop. Are your mobile device and computer on the same ip range ? (both ending in .X.something)
For debug you may try to access a route that should be available on port 8080 (/ssdp/device-desc.xml), both on localhost (http://localhost:8080/ssdp/device-desc.xml) and the local ip. You should be able to see a xml file if the server is running on your computer.

If you've got the time and skills, a proper documentation would be welcomed :)
Cheers

@kristiana-rendon
Copy link
Author

kristiana-rendon commented Jun 4, 2018

Thank you for your response. I will try to make some time to make a proper documentation after I get a better understanding of the code. I am making progress on getting it to work. I set up a Raspberry Pi and am partially able to get it working. I am stuck on getting my tablet to make a connection to the emulator. The cast button appears and once I click it, it says it's trying to connect, but my tablet times out without making a complete connection. Do you know why? I am using my phone's hot spot for the internet connection.

Also, how does the handshake part of the code work? Is it the setupSSDP() function in the server.js file?

Thank you for your time!

@kristiana-rendon
Copy link
Author

So! It turns out that it was the hot spot that was causing the problems! I tried it at home with my regular network and it worked immediately! Phew. But I would still love to understand how the code works (from my previous comment), if you have time. Thanks!

@vbaicu
Copy link
Owner

vbaicu commented Jun 5, 2018

I'm glad to hear you've got it working.
Just tried using a hotspot to connect my devices and got the same issue. Thanks for pointing this to me.
On the other hand the handshake starts in '/connection' route of websockets server (line 76). You can debug the app using visual studio code, setup breakpoints and see how data flows in the app at any moment :)
About the raspberry pi I suggest using Benja https://benja.io to run the app. They've got hardware acceleration inside electron so everything will run as smooth as on desktop. If you run the app on raspbian as is, the video will freeze.

@kristiana-rendon
Copy link
Author

Thank you for the info! I think it'll make things a little easier if I explained more of what I was using your code for, haha. I am on a team that is trying to cast DRM-protected media from a strictly local server using your chromecast emulator. We couldn't use the original Chromecast because it required an internet connection despite it being intentionally unnecessary for our project. We were hoping to use your emulator to bypass the internet requirement and have it communicate with our custom mobile app to stream our DRM-protected media to a Raspberry Pi.

So! We were wondering if you knew the following:
1.) A way to bypass the internet requirement.
2.) Suggestions on how to cast local content.
3.) What constitutes as a chromecast compatible device (referring to your routes you mentioned last week)
4.) How would our sender app request a connection to your emulator?

I know these are a lot of questions, but it would really help our project get moving in the right direction since you are experienced in this area. Thank you so much for your help so far. :)

@vbaicu
Copy link
Owner

vbaicu commented Jun 8, 2018

Now I understand your curiosity for the things behind the scenes.
Well, Chromecast by design was intended to stream media directly from the internet, mobile device playing just the remote role. It's the best approach for things like Youtube, Spotify, Prime, etc.
However what you are trying to do is achievable, with a lot of work on your side. I'll start by explaining what chromecast (my emulator based on chromecast v1) does, it offers just a way to pair a web application with a mobile device without having to write the pairing code and provide a bridge for communications between them. Basically each app, Youtube for example, is a webpage displayed by the chromecast when required by the mobile device. All the media streaming is done by that webpage.
So...
1.) You first need to write the 'app' (webpage) that will run on chromecast and register it in setupApps, You can load this app either from the internet, like I'm doing with youtube (https://www.youtube.com/tv?$query) or a localhost url. You don't need the internet connection.
2.) Your mobile application needs to provide the media as a stream to the network, there are various protocols to do this with implementations and examples, depends on what media type you have Then moving to the chromecast side, your app needs to connect to that stream, decode it and show the frames on the screen.
3.) First it should have a http and websockets server running on port 8008 that exposes the routes used to make the connections (/ssdp/device-desc.xml and connection/:app) on http, the rest is handled by the websockets server after a device requested to launch an app.
4.) I recommend using the official chromecast discovery and connection from google : https://developers.google.com/cast/docs/ios_sender_integrate
In terms of the chromecast application I recommend following the official guide for a chromecast app so your project will run on a real device too. The challenge for you is to implement the streamer and the receiver.
There is an open soruce tool that streams any type of video to a chromecast, written in nodejs, might be helpful for your project: https://github.com/xat/castnow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants