Ejemplo n.º 1
0
 public static String getMediaSubtitle(Context ctx, MediaWrapper media) {
   if (media.getType() == MediaWrapper.TYPE_AUDIO)
     return media.getNowPlaying() != null
         ? media.getNowPlaying()
         : getMediaArtist(ctx, media) + " - " + getMediaAlbum(ctx, media);
   else return "";
 }
Ejemplo n.º 2
0
  public void deleteMedia(int position) {
    final MediaWrapper media = mVideoAdapter.getItem(position);
    final String path = media.getUri().getPath();
    new Thread(
            new Runnable() {
              public void run() {
                Util.recursiveDelete(VLCApplication.getAppContext(), new File(path));
              }
            })
        .start();
    mMediaLibrary.getMediaItems().remove(media);
    mVideoAdapter.remove(media);
    PlaybackServiceClient.getMediaLocations(
        getActivity(),
        new PlaybackServiceClient.ResultCallback<List<String>>() {
          @Override
          public void onResult(PlaybackServiceClient client, List<String> result) {
            if (result != null && result.contains(media.getLocation()))
              client.removeLocation(media.getLocation());
          }

          @Override
          public void onError(PlaybackServiceClient client) {}
        });
  }
Ejemplo n.º 3
0
 private boolean handleContextItemSelected(MenuItem menu, int position) {
   if (position >= mVideoAdapter.getCount()) return false;
   MediaWrapper media = mVideoAdapter.getItem(position);
   if (media == null) return false;
   switch (menu.getItemId()) {
     case R.id.video_list_play_from_start:
       playVideo(media, true);
       return true;
     case R.id.video_list_play_audio:
       playAudio(media);
       return true;
     case R.id.video_list_info:
       Activity activity = getActivity();
       if (activity instanceof MainActivity)
         ((MainActivity) activity)
             .showSecondaryFragment(SecondaryActivity.MEDIA_INFO, media.getLocation());
       else {
         Intent i = new Intent(activity, SecondaryActivity.class);
         i.putExtra("fragment", "mediaInfo");
         i.putExtra("param", media.getLocation());
         startActivity(i);
       }
       return true;
     case R.id.video_list_delete:
       Snackbar.make(getView(), getString(R.string.file_deleted), Snackbar.LENGTH_LONG)
           .setAction(android.R.string.cancel, mCancelDeleteMediaListener)
           .show();
       Message msg = mDeleteHandler.obtainMessage(DELETE_MEDIA, position, 0);
       mDeleteHandler.sendMessageDelayed(msg, DELETE_DURATION);
       return true;
   }
   return false;
 }
Ejemplo n.º 4
0
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   MediaWrapper media = mVideoAdapter.getItem(position);
   if (media == null) return;
   if (media instanceof MediaGroup) {
     MainActivity activity = (MainActivity) getActivity();
     activity.showSecondaryFragment(SecondaryActivity.VIDEO_GROUP_LIST, media.getTitle());
   } else playVideo(media, false);
 }
Ejemplo n.º 5
0
 public static void openMedia(final Context context, final MediaWrapper media) {
   if (media == null) return;
   if (media.getType() == MediaWrapper.TYPE_VIDEO)
     VideoPlayerActivity.start(context, media.getUri(), media.getTitle());
   else if (media.getType() == MediaWrapper.TYPE_AUDIO) {
     new DialogCallback(
         context,
         new DialogCallback.Runnable() {
           @Override
           public void run(PlaybackService service) {
             service.load(media);
           }
         });
   }
 }
Ejemplo n.º 6
0
  private void setContextMenuItems(Menu menu, MediaWrapper mediaWrapper) {
    long lastTime = mediaWrapper.getTime();
    if (lastTime > 0) menu.findItem(R.id.video_list_play_from_start).setVisible(true);

    boolean hasInfo = false;
    final Media media = new Media(VLCInstance.get(), mediaWrapper.getUri());
    media.parse();
    media.release();
    if (media.getMeta(Media.Meta.Title) != null) hasInfo = true;
    menu.findItem(R.id.video_list_info).setVisible(hasInfo);
    menu.findItem(R.id.video_list_delete)
        .setVisible(
            !AndroidUtil.isLolliPopOrLater()
                || mediaWrapper
                    .getLocation()
                    .startsWith("file://" + AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY));
  }
Ejemplo n.º 7
0
 public void browse(MediaWrapper media, int position, boolean scanned) {
   FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
   Fragment next = createFragment();
   Bundle args = new Bundle();
   args.putParcelable(KEY_MEDIA, media);
   args.putBoolean(KEY_IN_MEDIALIB, mScannedDirectory || scanned);
   next.setArguments(args);
   ft.replace(R.id.fragment_placeholder, next, media.getLocation());
   ft.addToBackStack(mMrl);
   ft.commit();
 }
Ejemplo n.º 8
0
 protected void playVideo(MediaWrapper media, boolean fromStart) {
   VideoPlayerActivity.start(getActivity(), media.getUri(), fromStart);
 }
Ejemplo n.º 9
0
 public static String getMediaGenre(Context ctx, MediaWrapper media) {
   final String genre = media.getGenre();
   return genre != null ? genre : getMediaString(ctx, R.string.unknown_genre);
 }
Ejemplo n.º 10
0
 public static String getMediaAlbum(Context ctx, MediaWrapper media) {
   final String album = media.getAlbum();
   return album != null ? album : getMediaString(ctx, R.string.unknown_album);
 }
Ejemplo n.º 11
0
 public static String getMediaAlbumArtist(Context ctx, MediaWrapper media) {
   final String albumArtist = media.getAlbumArtist();
   return albumArtist != null ? albumArtist : getMediaString(ctx, R.string.unknown_artist);
 }