use of com.getcapacitor.PluginMethod in project capacitor-video-player by jepiqueau.
the class CapacitorVideoPlayerPlugin method getVolume.
@PluginMethod
public void getVolume(final PluginCall call) {
this.call = call;
JSObject ret = new JSObject();
ret.put("method", "getVolume");
String playerId = call.getString("playerId");
if (playerId == null) {
ret.put("result", false);
ret.put("message", "Must provide a PlayerId");
call.resolve(ret);
return;
}
if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
bridge.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
JSObject ret = new JSObject();
ret.put("method", "getVolume");
if (fsFragment != null) {
Float volume = fsFragment.getVolume();
ret.put("result", true);
ret.put("value", volume);
call.resolve(ret);
} else {
ret.put("result", false);
ret.put("message", "Fullscreen fragment is not defined");
call.resolve(ret);
}
}
});
} else {
ret.put("result", false);
ret.put("message", "player is not defined");
call.resolve(ret);
}
}
use of com.getcapacitor.PluginMethod in project capacitor-video-player by jepiqueau.
the class CapacitorVideoPlayerPlugin method setRate.
@PluginMethod
public void setRate(final PluginCall call) {
this.call = call;
JSObject ret = new JSObject();
ret.put("method", "setRate");
String playerId = call.getString("playerId");
if (playerId == null) {
ret.put("result", false);
ret.put("message", "Must provide a PlayerId");
call.resolve(ret);
return;
}
Float rate = call.getFloat("rate");
if (rate == null) {
ret.put("result", false);
ret.put("method", "setRate");
ret.put("message", "Must provide a volume value");
call.resolve(ret);
return;
}
if (isInRate(rateList, rate)) {
videoRate = rate;
} else {
videoRate = 1f;
}
if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
bridge.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
JSObject ret = new JSObject();
ret.put("method", "setRate");
if (fsFragment != null) {
fsFragment.setRate(videoRate);
ret.put("result", true);
ret.put("value", videoRate);
call.resolve(ret);
} else {
ret.put("result", false);
ret.put("message", "Fullscreen fragment is not defined");
call.resolve(ret);
}
}
});
} else {
ret.put("result", false);
ret.put("message", "player is not defined");
call.resolve(ret);
}
}
use of com.getcapacitor.PluginMethod in project capacitor-video-player by jepiqueau.
the class CapacitorVideoPlayerPlugin method setCurrentTime.
@PluginMethod
public void setCurrentTime(final PluginCall call) {
this.call = call;
JSObject ret = new JSObject();
ret.put("method", "setCurrentTime");
String playerId = call.getString("playerId");
if (playerId == null) {
ret.put("result", false);
ret.put("message", "Must provide a PlayerId");
call.resolve(ret);
return;
}
Double value = call.getDouble("seektime");
if (value == null) {
ret.put("result", false);
ret.put("message", "Must provide a time in second");
call.resolve(ret);
return;
}
final int cTime = (int) Math.round(value);
if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
bridge.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
JSObject ret = new JSObject();
ret.put("method", "setCurrentTime");
if (fsFragment != null) {
fsFragment.setCurrentTime(cTime);
ret.put("result", true);
ret.put("value", cTime);
call.resolve(ret);
} else {
ret.put("result", false);
ret.put("message", "Fullscreen fragment is not defined");
call.resolve(ret);
}
}
});
} else {
ret.put("result", false);
ret.put("message", "player is not defined");
call.resolve(ret);
}
}
use of com.getcapacitor.PluginMethod in project capacitor-video-player by jepiqueau.
the class CapacitorVideoPlayerPlugin method isPlaying.
@PluginMethod
public void isPlaying(final PluginCall call) {
this.call = call;
JSObject ret = new JSObject();
ret.put("method", "isPlaying");
String playerId = call.getString("playerId");
if (playerId == null) {
ret.put("result", false);
ret.put("message", "Must provide a PlayerId");
call.resolve(ret);
return;
}
if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
bridge.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
JSObject ret = new JSObject();
ret.put("method", "isPlaying");
if (fsFragment != null) {
boolean playing = fsFragment.isPlaying();
ret.put("result", true);
ret.put("value", playing);
call.resolve(ret);
} else {
ret.put("result", false);
ret.put("message", "Fullscreen fragment is not defined");
call.resolve(ret);
}
}
});
} else {
ret.put("result", false);
ret.put("message", "player is not defined");
call.resolve(ret);
}
}
use of com.getcapacitor.PluginMethod in project capacitor by ionic-team.
the class WebView method getServerBasePath.
@PluginMethod
public void getServerBasePath(PluginCall call) {
String path = bridge.getServerBasePath();
JSObject ret = new JSObject();
ret.put("path", path);
call.resolve(ret);
}
Aggregations