Search in sources :

Example 16 with MediaWrapper

use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.

the class HistoryFragment method onDestroyActionMode.

@Override
public void onDestroyActionMode(ActionMode mode) {
    mActionMode = null;
    int index = -1;
    for (MediaWrapper media : mHistoryAdapter.getAll()) {
        ++index;
        if (media.hasStateFlags(MediaLibraryItem.FLAG_SELECTED)) {
            media.removeStateFlags(MediaLibraryItem.FLAG_SELECTED);
            mHistoryAdapter.notifyItemChanged(index, media);
        }
    }
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper)

Example 17 with MediaWrapper

use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.

the class InfoActivity method updateMeta.

private void updateMeta() {
    long length = 0L;
    MediaWrapper[] tracks = mItem.getTracks();
    int nbTracks = tracks != null ? tracks.length : 0;
    if (nbTracks > 0)
        for (MediaWrapper media : tracks) length += media.getLength();
    if (length > 0)
        mBinding.setLength(Tools.millisToText(length));
    if (mItem.getItemType() == MediaLibraryItem.TYPE_MEDIA) {
        MediaWrapper media = (MediaWrapper) mItem;
        mBinding.setPath(Uri.decode(media.getUri().getPath()));
        mBinding.setProgress(media.getLength() == 0 ? 0 : (int) ((long) 100 * media.getTime() / length));
        mBinding.setSizeTitleText(getString(R.string.file_size));
    } else if (mItem.getItemType() == MediaLibraryItem.TYPE_ARTIST) {
        Medialibrary ml = VLCApplication.getMLInstance();
        Album[] albums = ((Artist) mItem).getAlbums();
        int nbAlbums = albums == null ? 0 : albums.length;
        mBinding.setSizeTitleText(getString(R.string.albums));
        mBinding.setSizeValueText(String.valueOf(nbAlbums));
        mBinding.setExtraTitleText(getString(R.string.tracks));
        mBinding.setExtraValueText(String.valueOf(nbTracks));
    } else {
        mBinding.setSizeTitleText(getString(R.string.tracks));
        mBinding.setSizeValueText(String.valueOf(nbTracks));
    }
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) Medialibrary(org.videolan.medialibrary.Medialibrary)

Example 18 with MediaWrapper

use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.

the class PlaylistActivity method onActionItemClicked.

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    List<MediaLibraryItem> list = mAdapter.getSelection();
    List<MediaWrapper> tracks = new ArrayList<>();
    for (MediaLibraryItem mediaItem : list) tracks.addAll(Arrays.asList(mediaItem.getTracks()));
    if (item.getItemId() == R.id.action_mode_audio_playlist_up) {
        Toast.makeText(this, "UP !", Toast.LENGTH_SHORT).show();
        return true;
    }
    if (item.getItemId() == R.id.action_mode_audio_playlist_down) {
        Toast.makeText(this, "DOWN !", Toast.LENGTH_SHORT).show();
        return true;
    }
    stopActionMode();
    switch(item.getItemId()) {
        case R.id.action_mode_audio_play:
            mService.load(tracks, 0);
            break;
        case R.id.action_mode_audio_append:
            mService.append(tracks);
            break;
        case R.id.action_mode_audio_add_playlist:
            ;
            UiTools.addToPlaylist(this, tracks);
            break;
        case R.id.action_mode_audio_info:
            showInfoDialog((MediaWrapper) list.get(0));
            break;
        case R.id.action_mode_audio_set_song:
            AudioUtil.setRingtone((MediaWrapper) list.get(0), this);
            break;
        case R.id.action_mode_audio_delete:
            removeFromPlaylist(tracks);
            break;
        default:
            return false;
    }
    return true;
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) ArrayList(java.util.ArrayList)

Example 19 with MediaWrapper

use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.

the class SavePlaylistDialog method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mMedialibrary = VLCApplication.getMLInstance();
    mAdapter = new AudioBrowserAdapter(MediaLibraryItem.TYPE_PLAYLIST, this, false);
    mTracks = (MediaWrapper[]) getArguments().getParcelableArray(KEY_TRACKS);
    mNewTrack = (MediaWrapper[]) getArguments().getParcelableArray(KEY_NEW_TRACKS);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) AudioBrowserAdapter(org.videolan.vlc.gui.audio.AudioBrowserAdapter)

Example 20 with MediaWrapper

use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.

the class BaseBrowserFragment method inflate.

@Override
protected void inflate(Menu menu, int position) {
    MediaWrapper mw = (MediaWrapper) mAdapter.getItem(position);
    if (mw == null)
        return;
    int type = mw.getType();
    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(type == MediaWrapper.TYPE_DIR ? R.menu.directory_view_dir : R.menu.directory_view_file, menu);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) MenuInflater(android.view.MenuInflater)

Aggregations

MediaWrapper (org.videolan.medialibrary.media.MediaWrapper)157 ArrayList (java.util.ArrayList)36 MediaLibraryItem (org.videolan.medialibrary.media.MediaLibraryItem)23 Bitmap (android.graphics.Bitmap)18 Intent (android.content.Intent)16 Uri (android.net.Uri)15 List (java.util.List)11 Bundle (android.os.Bundle)10 Context (android.content.Context)9 MediaGroup (org.videolan.vlc.media.MediaGroup)9 PendingIntent (android.app.PendingIntent)8 View (android.view.View)8 TargetApi (android.annotation.TargetApi)6 Cursor (android.database.Cursor)6 FragmentManager (android.support.v4.app.FragmentManager)6 File (java.io.File)6 LinkedList (java.util.LinkedList)6 Medialibrary (org.videolan.medialibrary.Medialibrary)6 SavePlaylistDialog (org.videolan.vlc.gui.dialogs.SavePlaylistDialog)6 SharedPreferences (android.content.SharedPreferences)5