Search in sources :

Example 96 with MediaWrapper

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

the class AudioUtil method getCover.

public static Bitmap getCover(Context context, List<MediaWrapper> list, int width, boolean fromMemCache) {
    Bitmap cover = null;
    LinkedList<String> testedAlbums = new LinkedList<String>();
    for (MediaWrapper media : list) {
        /* No list cover is artist or album are null */
        if (media.getAlbum() == null || media.getArtist() == null)
            continue;
        if (testedAlbums.contains(media.getAlbum()))
            continue;
        cover = fromMemCache ? AudioUtil.getCoverFromMemCache(context, media, width) : AudioUtil.getCover(context, media, width);
        if (cover != null)
            break;
        else if (media.getAlbum() != null)
            testedAlbums.add(media.getAlbum());
    }
    return cover;
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) Bitmap(android.graphics.Bitmap) LinkedList(java.util.LinkedList)

Example 97 with MediaWrapper

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

the class VideoListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    final MediaWrapper media = getDataset().get(position);
    if (media == null)
        return;
    holder.binding.setVariable(BR.scaleType, ImageView.ScaleType.CENTER_CROP);
    fillView(holder, media);
    holder.binding.setVariable(BR.media, media);
    holder.selectView(media.hasStateFlags(MediaLibraryItem.FLAG_SELECTED));
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper)

Example 98 with MediaWrapper

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

the class VideoPlayerActivity method onPlaying.

private void onPlaying() {
    mIsPlaying = true;
    setPlaybackParameters();
    stopLoading();
    updateOverlayPausePlay();
    updateNavStatus();
    final MediaWrapper mw = mService.getCurrentMediaWrapper();
    mMediaLength.set(mService.getLength());
    if (!mw.hasFlag(MediaWrapper.MEDIA_PAUSED))
        mHandler.sendEmptyMessageDelayed(FADE_OUT, OVERLAY_TIMEOUT);
    else {
        mw.removeFlags(MediaWrapper.MEDIA_PAUSED);
        mWasPaused = false;
    }
    setESTracks();
    if (mTitle != null && mTitle.length() == 0)
        mTitle.setText(mw.getTitle());
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper)

Example 99 with MediaWrapper

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

the class VideoPlayerActivity method onMediaPlayerEvent.

@Override
public void onMediaPlayerEvent(MediaPlayer.Event event) {
    switch(event.type) {
        case MediaPlayer.Event.Opening:
            mHasSubItems = false;
            break;
        case MediaPlayer.Event.Playing:
            onPlaying();
            break;
        case MediaPlayer.Event.Paused:
            updateOverlayPausePlay();
            break;
        case MediaPlayer.Event.Stopped:
            exitOK();
            break;
        case MediaPlayer.Event.EndReached:
            /* Don't end the activity if the media has subitems since the next child will be
                 * loaded by the PlaybackService */
            if (!mHasSubItems)
                endReached();
            break;
        case MediaPlayer.Event.EncounteredError:
            encounteredError();
            break;
        case MediaPlayer.Event.TimeChanged:
            mProgress.set((int) event.getTimeChanged());
            break;
        case MediaPlayer.Event.LengthChanged:
            mMediaLength.set(event.getLengthChanged());
            break;
        case MediaPlayer.Event.Vout:
            updateNavStatus();
            if (mMenuIdx == -1)
                handleVout(event.getVoutCount());
            break;
        case MediaPlayer.Event.ESAdded:
            if (mMenuIdx == -1) {
                MediaWrapper media = mMedialibrary.findMedia(mService.getCurrentMediaWrapper());
                if (media == null)
                    return;
                if (event.getEsChangedType() == Media.Track.Type.Audio) {
                    setESTrackLists();
                    int audioTrack = (int) media.getMetaLong(MediaWrapper.META_AUDIOTRACK);
                    if (audioTrack != 0 || mCurrentAudioTrack != -2)
                        mService.setAudioTrack(media.getId() == 0L ? mCurrentAudioTrack : audioTrack);
                } else if (event.getEsChangedType() == Media.Track.Type.Text) {
                    setESTrackLists();
                    int spuTrack = (int) media.getMetaLong(MediaWrapper.META_SUBTITLE_TRACK);
                    if (spuTrack != 0 || mCurrentSpuTrack != -2)
                        mService.setSpuTrack(media.getId() == 0L ? mCurrentAudioTrack : spuTrack);
                }
            }
        case MediaPlayer.Event.ESDeleted:
            if (mMenuIdx == -1 && event.getEsChangedType() == Media.Track.Type.Video) {
                mHandler.removeMessages(CHECK_VIDEO_TRACKS);
                mHandler.sendEmptyMessageDelayed(CHECK_VIDEO_TRACKS, 1000);
            }
            invalidateESTracks(event.getEsChangedType());
            break;
        case MediaPlayer.Event.ESSelected:
            if (event.getEsChangedType() == Media.VideoTrack.Type.Video) {
                Media.VideoTrack vt = mService.getCurrentVideoTrack();
                changeSurfaceLayout();
                if (vt != null)
                    mFov = vt.projection == Media.VideoTrack.Projection.Rectangular ? 0f : DEFAULT_FOV;
            }
            break;
        case MediaPlayer.Event.SeekableChanged:
            updateSeekable(event.getSeekable());
            break;
        case MediaPlayer.Event.PausableChanged:
            updatePausable(event.getPausable());
            break;
        case MediaPlayer.Event.Buffering:
            if (!mIsPlaying)
                break;
            if (event.getBuffering() == 100f)
                stopLoading();
            else if (!mHandler.hasMessages(LOADING_ANIMATION) && !mIsLoading && mTouchAction != TOUCH_SEEK && !mDragging)
                mHandler.sendEmptyMessageDelayed(LOADING_ANIMATION, LOADING_ANIMATION_DELAY);
            break;
    }
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) Media(org.videolan.libvlc.Media) SuppressLint(android.annotation.SuppressLint)

Example 100 with MediaWrapper

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

the class TvUtil method playMedia.

public static void playMedia(Activity activity, MediaWrapper media) {
    if (media.getType() == MediaWrapper.TYPE_AUDIO) {
        ArrayList<MediaWrapper> tracks = new ArrayList<>();
        tracks.add(media);
        Intent intent = new Intent(activity, AudioPlayerActivity.class);
        intent.putExtra(AudioPlayerActivity.MEDIA_LIST, tracks);
        activity.startActivity(intent);
    } else
        MediaUtils.openMedia(activity, media);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) ArrayList(java.util.ArrayList) Intent(android.content.Intent)

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