Search code examples
javascriptandroidgoogle-chromehttp-live-streaming

Open Chrome App and Inject Javascript


I have an app that opens the Chrome app with a particular url like so:

Intent intent = new Intent("android.intent.action.MAIN");
                            intent.setComponent(ComponentName.unflattenFromString("com.android.chrome/com.android.chrome.Main"));
                            intent.addCategory("android.intent.category.LAUNCHER");
                            intent.setData(Uri.parse("http://www.twitch.tv/insomniacgamers12345/hls"));
                            startActivity(intent);

Chrome must be used instead of the built in browser because it seems that only chrome can play the html5 video properly that this page contains. This is also the reason I cannot use a webview. Opening this url in a webview shows "unsupported player". However, chrome works.

Now, I want to inject javascript ($('video')[0].play() to be precise) into the page in the chrome instance that I have just opened in order to start the video automatically.

Is this possible? Can I somehow use the intent to schedule javascript to be run on the page that is about to be opened?


Solution

  • Is this possible?

    No. You are welcome to open a browser, but you cannot control an existing browser.