Ejemplo n.º 1
0
  @Override
  public boolean onInfo(MediaPlayer mp, int what, int extra) {
    String msg = "Unknown media issue.";

    switch (what) {
      case MediaPlayer.MEDIA_INFO_BAD_INTERLEAVING:
        msg = "Stream not interleaved or interleaved improperly.";
        break;
      case MediaPlayer.MEDIA_INFO_NOT_SEEKABLE:
        msg = "Stream does not support seeking";
        break;
      case MediaPlayer.MEDIA_INFO_UNKNOWN:
        msg = "Unknown media issue";
        break;
      case MediaPlayer.MEDIA_INFO_VIDEO_TRACK_LAGGING:
        msg = "Video is too complex for decoder, video lagging."; // shouldn't occur, but covering
        // bases.
        break;
    }

    KrollDict data = new KrollDict();
    data.put("code", 0);
    data.put("message", msg);
    proxy.fireEvent(EVENT_ERROR, data);

    return true;
  }
Ejemplo n.º 2
0
 public boolean fireAppEvent(KrollInvocation invocation, String eventName, KrollDict data) {
   boolean handled = false;
   for (KrollProxy appEventProxy : appEventProxies) {
     boolean proxyHandled = appEventProxy.fireEvent(eventName, data);
     handled = handled || proxyHandled;
   }
   return handled;
 }
Ejemplo n.º 3
0
  @Override
  public boolean onError(MediaPlayer mp, int what, int extra) {
    int code = 0;
    String msg = "Unknown media error.";
    if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
      msg = "Media server died";
    }
    release();

    KrollDict data = new KrollDict();
    data.put("code", code);
    data.put("message", msg);
    proxy.fireEvent(EVENT_ERROR, data);

    return true;
  }
Ejemplo n.º 4
0
  private void setState(int state) {
    proxy.setProperty("state", state);
    String stateDescription = "";

    switch (state) {
      case STATE_BUFFERING:
        stateDescription = STATE_BUFFERING_DESC;
        break;
      case STATE_INITIALIZED:
        stateDescription = STATE_INITIALIZED_DESC;
        break;
      case STATE_PAUSED:
        stateDescription = STATE_PAUSED_DESC;
        break;
      case STATE_PLAYING:
        stateDescription = STATE_PLAYING_DESC;
        break;
      case STATE_STARTING:
        stateDescription = STATE_STARTING_DESC;
        break;
      case STATE_STOPPED:
        stateDescription = STATE_STOPPED_DESC;
        break;
      case STATE_STOPPING:
        stateDescription = STATE_STOPPING_DESC;
        break;
      case STATE_WAITING_FOR_DATA:
        stateDescription = STATE_WAITING_FOR_DATA_DESC;
        break;
      case STATE_WAITING_FOR_QUEUE:
        stateDescription = STATE_WAITING_FOR_QUEUE_DESC;
        break;
    }

    proxy.setProperty("stateDescription", stateDescription);
    if (DBG) {
      Log.d(LCAT, "Audio state changed: " + stateDescription);
    }

    KrollDict data = new KrollDict();
    data.put("state", state);
    data.put("description", stateDescription);
    proxy.fireEvent(EVENT_CHANGE, data);
  }
Ejemplo n.º 5
0
 public void onCompletion(MediaPlayer mp) {
   proxy.fireEvent(EVENT_COMPLETE, null);
   stop();
 }
Ejemplo n.º 6
0
  @Override
  public boolean dispatchKeyEvent(KeyEvent event) {
    boolean handled = false;

    TiViewProxy window;
    if (this.window != null) {
      window = this.window;
    } else {
      window = this.view;
    }

    if (window == null) {
      return super.dispatchKeyEvent(event);
    }

    switch (event.getKeyCode()) {
      case KeyEvent.KEYCODE_BACK:
        {
          if (event.getAction() == KeyEvent.ACTION_UP) {
            String backEvent = "android:back";
            KrollProxy proxy = null;
            // android:back could be fired from a tabGroup window (activityProxy)
            // or hw window (window).This event is added specifically to the activity
            // proxy of a tab group in window.js
            if (activityProxy.hasListeners(backEvent)) {
              proxy = activityProxy;
            } else if (window.hasListeners(backEvent)) {
              proxy = window;
            }

            if (proxy != null) {
              proxy.fireEvent(backEvent, null);
              handled = true;
            }
          }
          break;
        }
      case KeyEvent.KEYCODE_CAMERA:
        {
          if (window.hasListeners(TiC.EVENT_ANDROID_CAMERA)) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
              window.fireEvent(TiC.EVENT_ANDROID_CAMERA, null);
            }
            handled = true;
          }
          // TODO: Deprecate old event
          if (window.hasListeners("android:camera")) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
              window.fireEvent("android:camera", null);
            }
            handled = true;
          }

          break;
        }
      case KeyEvent.KEYCODE_FOCUS:
        {
          if (window.hasListeners(TiC.EVENT_ANDROID_FOCUS)) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
              window.fireEvent(TiC.EVENT_ANDROID_FOCUS, null);
            }
            handled = true;
          }
          // TODO: Deprecate old event
          if (window.hasListeners("android:focus")) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
              window.fireEvent("android:focus", null);
            }
            handled = true;
          }

          break;
        }
      case KeyEvent.KEYCODE_SEARCH:
        {
          if (window.hasListeners(TiC.EVENT_ANDROID_SEARCH)) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
              window.fireEvent(TiC.EVENT_ANDROID_SEARCH, null);
            }
            handled = true;
          }
          // TODO: Deprecate old event
          if (window.hasListeners("android:search")) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
              window.fireEvent("android:search", null);
            }
            handled = true;
          }

          break;
        }
      case KeyEvent.KEYCODE_VOLUME_UP:
        {
          if (window.hasListeners(TiC.EVENT_ANDROID_VOLUP)) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
              window.fireEvent(TiC.EVENT_ANDROID_VOLUP, null);
            }
            handled = true;
          }
          // TODO: Deprecate old event
          if (window.hasListeners("android:volup")) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
              window.fireEvent("android:volup", null);
            }
            handled = true;
          }

          break;
        }
      case KeyEvent.KEYCODE_VOLUME_DOWN:
        {
          if (window.hasListeners(TiC.EVENT_ANDROID_VOLDOWN)) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
              window.fireEvent(TiC.EVENT_ANDROID_VOLDOWN, null);
            }
            handled = true;
          }
          // TODO: Deprecate old event
          if (window.hasListeners("android:voldown")) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
              window.fireEvent("android:voldown", null);
            }
            handled = true;
          }

          break;
        }
    }

    if (!handled) {
      handled = super.dispatchKeyEvent(event);
    }

    return handled;
  }