Ejemplo n.º 1
0
 private void next() {
   int index = mMediaList.indexOf(mCurrentMedia);
   mPrevious.push(mCurrentMedia);
   if (mRepeating == RepeatType.Once) mCurrentMedia = mMediaList.get(index);
   else if (mShuffling && mPrevious.size() < mMediaList.size()) {
     while (mPrevious.contains(
         mCurrentMedia = mMediaList.get((int) (Math.random() * mMediaList.size())))) ;
   } else if (!mShuffling && index < mMediaList.size() - 1) {
     mCurrentMedia = mMediaList.get(index + 1);
   } else {
     if (mRepeating == RepeatType.All && mMediaList.size() > 0) mCurrentMedia = mMediaList.get(0);
     else {
       stop();
       return;
     }
   }
   if (mLibVLCPlaylistActive) {
     if (mRepeating == RepeatType.None) mLibVLC.next();
     else if (mRepeating == RepeatType.Once) mLibVLC.playIndex(index);
     else mLibVLC.playIndex(mMediaList.indexOf(mCurrentMedia));
   } else {
     mLibVLC.readMedia(mCurrentMedia.getLocation(), true);
   }
   mHandler.sendEmptyMessage(SHOW_PROGRESS);
   setUpRemoteControlClient();
   showNotification();
   updateWidget(this);
   updateRemoteControlClientMetadata();
   saveCurrentMedia();
 }
Ejemplo n.º 2
0
 private void previous() {
   int index = mMediaList.indexOf(mCurrentMedia);
   if (mPrevious.size() > 0) mCurrentMedia = mPrevious.pop();
   else if (index > 0) mCurrentMedia = mMediaList.get(index - 1);
   else return;
   if (mLibVLCPlaylistActive) {
     if (mRepeating == RepeatType.None) mLibVLC.previous();
     else if (mRepeating == RepeatType.Once) mLibVLC.playIndex(index);
     else mLibVLC.playIndex(mMediaList.indexOf(mCurrentMedia));
   } else {
     mLibVLC.readMedia(mCurrentMedia.getLocation(), true);
   }
   mHandler.sendEmptyMessage(SHOW_PROGRESS);
   setUpRemoteControlClient();
   showNotification();
   updateWidget(this);
   updateRemoteControlClientMetadata();
   saveCurrentMedia();
 }
Ejemplo n.º 3
0
        @Override
        public void load(
            List<String> mediaPathList, int position, boolean libvlcBacked, boolean noVideo)
            throws RemoteException {
          mLibVLCPlaylistActive = libvlcBacked;

          Log.v(
              TAG,
              "Loading position "
                  + ((Integer) position).toString()
                  + " in "
                  + mediaPathList.toString());
          mEventManager.addHandler(mEventHandler);

          mMediaList.clear();
          mPrevious.clear();

          if (mLibVLCPlaylistActive) {
            for (int i = 0; i < mediaPathList.size(); i++)
              mMediaList.add(new Media(mediaPathList.get(i), i));
          } else {
            DatabaseManager db = DatabaseManager.getInstance(AudioService.this);
            for (int i = 0; i < mediaPathList.size(); i++) {
              String path = mediaPathList.get(i);
              Media media = db.getMedia(AudioService.this, path);
              if (media == null) {
                Log.v(TAG, "Creating on-the-fly Media object for " + path);
                media = new Media(path, false);
              }
              mMediaList.add(media);
            }
          }

          if (mMediaList.size() > position) {
            mCurrentMedia = mMediaList.get(position);
          }

          if (mCurrentMedia != null) {
            if (mLibVLCPlaylistActive) {
              mLibVLC.playIndex(position);
            } else {
              mLibVLC.readMedia(mCurrentMedia.getLocation(), noVideo);
            }
            setUpRemoteControlClient();
            showNotification();
            updateWidget(AudioService.this);
            updateRemoteControlClientMetadata();
          }
          AudioService.this.saveMediaList();
          AudioService.this.saveCurrentMedia();
        }