21 Mart 2018 Çarşamba

JavaFX WebEngine Sınfı

constructor
Şöyle yaparız.
WebView myWebView = new WebView();
WebEngine engine = myWebView.getEngine();
executeScript metodu
Örnek
Şöyle yaparız.
JSObject jsobj = (JSObject) engine.executeScript("window");
Örnek
Şöyle yaparız.
engine.executeScript(getJSAudioVideo(true)));

/**
 * @param mute
 * @return JS code for mute/unmute
 */
public String getJSAudioVideo(boolean mute){
  return "var videos = document.querySelectorAll('video'),\n" +
"audios = document.querySelectorAll('listen');\n" +
"[].forEach.call(videos, function(video) { video.muted = "+String.valueOf(mute)+"; });\n"+
"[].forEach.call(audios, function(audio) { audio.muted = "+String.valueOf(mute)+"; });";
}
getLoadWorker metodu
Şöyle yaparız.
engine.getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() {
  @Override
  public void changed(ObservableValue<? extends Worker.State> observable,
    Worker.State oldValue, Worker.State newValue) {
    ...
  }
}
});
reload metodu
Şöyle yaparız.
webView.getEngine().reload();

Hiç yorum yok:

Yorum Gönder