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:
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?
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");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With