Search in sources :

Example 96 with PluginMethod

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);
    }
}
Also used : MyRunnable(com.jeep.plugin.capacitor.capacitorvideoplayer.Notifications.MyRunnable) JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 97 with PluginMethod

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);
    }
}
Also used : MyRunnable(com.jeep.plugin.capacitor.capacitorvideoplayer.Notifications.MyRunnable) JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 98 with PluginMethod

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);
    }
}
Also used : MyRunnable(com.jeep.plugin.capacitor.capacitorvideoplayer.Notifications.MyRunnable) JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 99 with PluginMethod

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);
    }
}
Also used : MyRunnable(com.jeep.plugin.capacitor.capacitorvideoplayer.Notifications.MyRunnable) JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 100 with PluginMethod

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);
}
Also used : JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Aggregations

PluginMethod (com.getcapacitor.PluginMethod)120 JSObject (com.getcapacitor.JSObject)93 JSONException (org.json.JSONException)18 MyRunnable (com.jeep.plugin.capacitor.capacitorvideoplayer.Notifications.MyRunnable)13 JSONObject (org.json.JSONObject)13 JSArray (com.getcapacitor.JSArray)12 Radar (io.radar.sdk.Radar)11 Location (android.location.Location)8 Intent (android.content.Intent)7 NotNull (org.jetbrains.annotations.NotNull)6 Nullable (org.jetbrains.annotations.Nullable)6 Uri (android.net.Uri)5 LatLng (com.google.android.libraries.maps.model.LatLng)5 GenericAd (admob.plus.core.GenericAd)4 GoogleSignInAccount (com.google.android.gms.auth.api.signin.GoogleSignInAccount)4 Gson (com.google.gson.Gson)4 PackageManager (android.content.pm.PackageManager)3 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)3 User (io.ionic.demo.ecommerce.data.model.User)3 Context (android.content.Context)2