Ejemplo n.º 1
0
        @Override
        public void showWithoutParse(String URI) throws RemoteException {
          Log.v(TAG, "Showing playing URI " + URI);
          // Show an URI without interrupting/losing the current stream

          if (!mLibVLC.isPlaying()) return;
          mEventManager.addHandler(mEventHandler);
          mMediaList.clear();
          mPrevious.clear();
          // Prevent re-parsing the media, which would mean losing the connection
          mCurrentMedia =
              new Media(
                  getApplicationContext(),
                  URI,
                  0,
                  0,
                  Media.TYPE_AUDIO,
                  null,
                  URI,
                  VLCApplication.getAppContext().getString(R.string.unknown_artist),
                  VLCApplication.getAppContext().getString(R.string.unknown_genre),
                  VLCApplication.getAppContext().getString(R.string.unknown_album),
                  0,
                  0,
                  "",
                  -1,
                  -1);
          mMediaList.add(mCurrentMedia);

          // Notify everyone
          mHandler.sendEmptyMessage(SHOW_PROGRESS);
          showNotification();
          executeUpdate();
        }
Ejemplo n.º 2
0
  private void updateWidget(Context context) {
    Log.d(TAG, "Updating widget");
    Intent i = new Intent();
    i.setClassName(WIDGET_PACKAGE, WIDGET_CLASS);
    i.setAction(ACTION_WIDGET_UPDATE);

    if (mCurrentMedia != null) {
      i.putExtra("title", mCurrentMedia.getTitle());
      i.putExtra("artist", mCurrentMedia.getArtist());
    } else {
      i.putExtra("title", "VLC mini player");
      i.putExtra("artist", "");
    }
    i.putExtra("isplaying", mLibVLC.isPlaying());

    Bitmap cover = mCurrentMedia != null ? AudioUtil.getCover(this, mCurrentMedia, 64) : null;
    i.putExtra("cover", cover);

    sendBroadcast(i);
  }
Ejemplo n.º 3
0
        @Override
        public void onReceive(Context context, Intent intent) {
          String action = intent.getAction();
          int state = intent.getIntExtra("state", 0);
          if (mLibVLC == null) {
            Log.w(TAG, "Intent received, but VLC is not loaded, skipping.");
            return;
          }

          // skip all headsets events if there is a call
          TelephonyManager telManager =
              (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
          if (telManager != null && telManager.getCallState() != TelephonyManager.CALL_STATE_IDLE)
            return;

          /*
           * Launch the activity if needed
           */
          if (action.startsWith(ACTION_REMOTE_GENERIC)
              && !mLibVLC.isPlaying()
              && mCurrentMedia == null) {
            Intent iVlc = new Intent(context, MainActivity.class);
            iVlc.putExtra(START_FROM_NOTIFICATION, true);
            iVlc.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
            context.startActivity(iVlc);
          }

          /*
           * Remote / headset control events
           */
          if (action.equalsIgnoreCase(ACTION_REMOTE_PLAYPAUSE)) {
            if (mLibVLC.isPlaying() && mCurrentMedia != null) pause();
            else if (!mLibVLC.isPlaying() && mCurrentMedia != null) play();
          } else if (action.equalsIgnoreCase(ACTION_REMOTE_PLAY)) {
            if (!mLibVLC.isPlaying() && mCurrentMedia != null) play();
          } else if (action.equalsIgnoreCase(ACTION_REMOTE_PAUSE)) {
            if (mLibVLC.isPlaying() && mCurrentMedia != null) pause();
          } else if (action.equalsIgnoreCase(ACTION_REMOTE_BACKWARD)) {
            previous();
          } else if (action.equalsIgnoreCase(ACTION_REMOTE_STOP)) {
            stop();
          } else if (action.equalsIgnoreCase(ACTION_REMOTE_FORWARD)) {
            next();
          } else if (action.equalsIgnoreCase(ACTION_REMOTE_LAST_PLAYLIST)) {
            loadLastPlaylist();
          }

          /*
           * headset plug events
           */
          if (mDetectHeadset) {
            if (action.equalsIgnoreCase(AudioManager.ACTION_AUDIO_BECOMING_NOISY)) {
              Log.i(TAG, "Headset Removed.");
              if (mLibVLC.isPlaying() && mCurrentMedia != null) pause();
            } else if (action.equalsIgnoreCase(Intent.ACTION_HEADSET_PLUG) && state != 0) {
              Log.i(TAG, "Headset Inserted.");
              if (!mLibVLC.isPlaying() && mCurrentMedia != null) play();
            }
          }

          /*
           * Sleep
           */
          if (action.equalsIgnoreCase(VLCApplication.SLEEP_INTENT)) {
            stop();
          }
        }
Ejemplo n.º 4
0
 @Override
 public boolean isPlaying() throws RemoteException {
   return mLibVLC.isPlaying();
 }
Ejemplo n.º 5
0
 public boolean isPlaying() {
   return mLibVlcInstance.isPlaying();
 }