Search in sources :

Example 56 with MediaWrapper

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

the class PlaybackService method showWithoutParse.

/**
 * Use this function to show an URI in the audio interface WITHOUT
 * interrupting the stream.
 *
 * Mainly used by VideoPlayerActivity in response to loss of video track.
 */
@MainThread
public void showWithoutParse(int index) {
    playlistManager.setVideoTrackEnabled(false);
    final MediaWrapper media = playlistManager.getMedia(index);
    if (media == null || !isPlaying())
        return;
    // Show an URI without interrupting/losing the current stream
    if (BuildConfig.DEBUG)
        Log.v(TAG, "Showing index " + index + " with playing URI " + media.getUri());
    playlistManager.setCurrentIndex(index);
    notifyTrackChanged();
    showNotification();
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) MainThread(android.support.annotation.MainThread)

Example 57 with MediaWrapper

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

the class PlaybackService method updateWidgetCover.

private void updateWidgetCover() {
    final MediaWrapper mw = playlistManager.getCurrentMedia();
    final String newWidgetCover = mw != null ? mw.getArtworkMrl() : null;
    if (!TextUtils.equals(mCurrentWidgetCover, newWidgetCover)) {
        mCurrentWidgetCover = newWidgetCover;
        sendWidgetBroadcast(new Intent(VLCAppWidgetProvider.ACTION_WIDGET_UPDATE_COVER).putExtra("artworkMrl", newWidgetCover));
    }
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent)

Example 58 with MediaWrapper

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

the class PlaybackService method broadcastMetadata.

private void broadcastMetadata() {
    final MediaWrapper media = playlistManager.getCurrentMedia();
    if (media == null || isVideoPlaying())
        return;
    sendBroadcast(new Intent("com.android.music.metachanged").putExtra("track", media.getTitle()).putExtra("artist", media.getArtist()).putExtra("album", media.getAlbum()).putExtra("duration", media.getLength()).putExtra("playing", isPlaying()).putExtra("package", "org.videolan.vlc"));
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent)

Example 59 with MediaWrapper

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

the class PlaybackService method updateWidgetPosition.

private void updateWidgetPosition(final float pos) {
    final MediaWrapper mw = playlistManager.getCurrentMedia();
    if (mw == null || mWidget == 0 || isVideoPlaying())
        return;
    // no more than one widget mUpdateMeta for each 1/50 of the song
    long timestamp = System.currentTimeMillis();
    if (!playlistManager.hasCurrentMedia() || timestamp - mWidgetPositionTimestamp < mw.getLength() / 50)
        return;
    mWidgetPositionTimestamp = timestamp;
    sendWidgetBroadcast(new Intent(VLCAppWidgetProvider.ACTION_WIDGET_UPDATE_POSITION).putExtra("position", pos));
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent)

Example 60 with MediaWrapper

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

the class Medialibrary method findMedia.

// If media is not in ML, find it with its path
public MediaWrapper findMedia(MediaWrapper mw) {
    if (mIsInitiated && mw != null && mw.getId() == 0L) {
        Uri uri = mw.getUri();
        MediaWrapper libraryMedia = getMedia(uri);
        if (libraryMedia == null && TextUtils.equals("file", uri.getScheme()) && uri.getPath() != null && uri.getPath().startsWith("/sdcard")) {
            uri = Tools.convertLocalUri(uri);
            libraryMedia = getMedia(uri);
        }
        if (libraryMedia != null)
            return libraryMedia;
    }
    return mw;
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) Uri(android.net.Uri)

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