6

I'm working on Chromecast's Hello World app for Chrome browsers, but I hit a roadblock when I tested it on my Android device. As far as I can tell, there is no way to cast the Chrome tab itself on Android. The only option is to cast the entire screen.

I've found an old reddit thread and an even older Google Cast Help Forum thread. Neither source makes it seem like it's possible to cast a mobile web tab on Android.

This is really hard to believe because I don't see anything intrinsic about a web page being on a mobile device that would prevent it from being Cast-compatible. What am I missing?

The current state of casting on a mobile device seems to be:

  1. Casting audio/video content from the mobile Chrome browser
  2. Casting from native mobile applications
  3. Casting the entire device's screen

The specific use case I'm looking to implement is a web-based game where players can be on a couch in front of a TV. They play the game by visiting a website in Chrome rather than downloading an app. If they were on laptops, it would work just fine because desktop Chrome is able to cast a specific tab where the TV shows some application like in the Hello World example. But this wouldn't be possible with Android.

Is anyone aware of a way to cast a mobile web page or any upcoming plans to do so?

Rick Viscomi
  • 8,180
  • 4
  • 35
  • 50
  • possible duplicate of http://stackoverflow.com/questions/27049265/how-can-i-cast-an-html-page-with-the-google-cast-chrome-extension?rq=1 – Mr.Rebot Jun 26 '16 at 22:28

2 Answers2

1

You can do it by using Webview. It will automatically consider mobile view only. Try this: make the main.xml file like this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" 
android:layout_gravity="center">
<WebView
    android:id="@+id/webView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center" /></LinearLayout>

Now make a class:

WebViewSampleActivity

    public class WebViewSampleActivity extends Activity {
     WebView wb;
    private class HelloWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return false;
        }
    }
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);      
        wb=(WebView)findViewById(R.id.webView1);        
        wb.getSettings().setJavaScriptEnabled(true);
        wb.getSettings().setLoadWithOverviewMode(true);
        wb.getSettings().setUseWideViewPort(true);
        wb.getSettings().setBuiltInZoomControls(true);
        wb.getSettings().setPluginState(WebSettings.PluginState.ON);
        wb.getSettings().setPluginsEnabled(true);           
        wb.setWebViewClient(new HelloWebViewClient());
        wb.loadUrl("http://www.yourUrl.com");        
    }
}
Gustavo Morales
  • 2,614
  • 9
  • 29
  • 37
  • So the webview requires users to download an Android app that will load a web page? Does the web page run with the desktop Chrome capabilities of the Cast API? If it's just mobile Chrome in an Android app, I've done a lot of work to get the same broken behavior. – Rick Viscomi Jun 28 '16 at 17:45
  • Yes it will allow user to download the app...it will be available in google play like other app. – Sanat Chandravanshi Jul 12 '16 at 10:08
  • No my concern is whether the webview runs in a desktop or mobile Chrome environment. The difference is that you can't cast from mobile, which is what this question is trying to figure out. – Rick Viscomi Jul 17 '16 at 08:22
0

Create a webview and inject a url. so easy way.

Smirk test
  • 50
  • 6