I am trying to take control of the Play / Pause html DOM elements (in a browser open on a PC) from an Android device.
There is a <video> tag on the html page (in Google Chrome browser), so I can manage it like this:
//js code document.querySelector("video").play(); document.querySelector("video").pause();
But I want this to run from an Android device, so I use GCM .
I read here and got some insights, but I still have some questions.
Firstly, since I write in eclipse and does not see the document variable, it causes an error. So how does eclipse recognize that element in the html page so that I can compile and install apk on the device?
Where can I specify the URL of the page I want to chat with? (send play / pause commands)
To run js inside java , I use Rhino . I looked through the examples in the documentation , but I'm still not sure if the @JSFunction annotations @JSFunction enough to declare js .
Here is my code:
import com.alaa.chromote.util.SystemUiHider; import com.google.android.gcm.GCMRegistrar; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.WindowManager; import android.widget.Button; import android.widget.Toast; import android.view.View.OnClickListener; import org.mozilla.javascript.*; import org.mozilla.javascript.annotations.*; public class MainApplication extends Activity { private final static String GCM_SENDER_ID = "484514826047"; private static final String LOG_TAG = "GetAClue::GCMIntentService"; private Button playButton; private Button pauseButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_application); playButton = (Button) findViewById(R.id.PlayButton); pauseButton = (Button) findViewById(R.id.PauseButton); playButton.setVisibility(View.INVISIBLE); pauseButton.setVisibility(View.VISIBLE);
How do I proceed?
source share