Search in sources :

Example 16 with Uri

use of android.net.Uri in project PlayerHater by chrisrhoden.

the class PlaylistParser method parsePls.

private static Uri[] parsePls(Uri uri) {
    try {
        HttpClient httpclient = new DefaultHttpClient();
        HttpResponse response = httpclient.execute(new HttpGet(uri.toString()));
        HttpEntity entity = response.getEntity();
        InputStream inputStream = entity.getContent();
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        String header = reader.readLine();
        if (header.trim().equalsIgnoreCase("[playlist]")) {
            String line;
            ArrayList<Uri> uriList = new ArrayList<Uri>();
            do {
                line = reader.readLine();
                if (line != null) {
                    if (line.startsWith("File")) {
                        String fileName = line.substring(line.indexOf("=") + 1).trim();
                        uriList.add(Uri.parse(fileName));
                    }
                }
            } while (line != null);
            if (uriList.size() > 0) {
                Uri[] res = new Uri[uriList.size()];
                return uriList.toArray(res);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return new Uri[] { uri };
}
Also used : HttpEntity(org.apache.http.HttpEntity) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) HttpGet(org.apache.http.client.methods.HttpGet) ArrayList(java.util.ArrayList) HttpResponse(org.apache.http.HttpResponse) Uri(android.net.Uri) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) HttpClient(org.apache.http.client.HttpClient) BufferedReader(java.io.BufferedReader)

Example 17 with Uri

use of android.net.Uri in project photo-picker-plus-android by chute.

the class MediaDAO method getAllMediaVideos.

/**
   * Request a specific record in {@link android.provider.MediaStore.Video.Media} database.
   *
   * @param context The application context.
   * @return Cursor object enabling read-write access to all videos on the
   * device.
   */
public static Cursor getAllMediaVideos(final Context context) {
    final String[] projection = new String[] { MediaStore.Video.Media._ID, MediaStore.Video.Media.DATA };
    final Uri videos = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
    return context.getContentResolver().query(videos, projection, null, null, MediaStore.Video.Media.DEFAULT_SORT_ORDER);
}
Also used : Uri(android.net.Uri)

Example 18 with Uri

use of android.net.Uri in project photo-picker-plus-android by chute.

the class MediaDAO method getImagePathFromCursor.

/**
   * Request a specific record in {@link android.provider.MediaStore.Images.Thumbnails}
   * database.
   *
   * @param context    The application context.
   * @param dataCursor Cursor object enabling read-write access to videos on the
   *                   device.
   * @param position   Cursor position.
   * @return Path of the image associated with the corresponding thumbnail.
   */
public static String getImagePathFromCursor(final Context context, final Cursor dataCursor, int position) {
    String imagePath = null;
    if (dataCursor.moveToPosition(position)) {
        int id = dataCursor.getInt(dataCursor.getColumnIndex(MediaStore.Images.Media._ID));
        Uri uri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id);
        Cursor imageCursor = context.getContentResolver().query(uri, null, null, null, null);
        if (imageCursor.moveToFirst()) {
            imagePath = imageCursor.getString(imageCursor.getColumnIndex(MediaStore.Images.Media.DATA));
        }
        safelyCloseCursor(imageCursor);
    }
    return imagePath;
}
Also used : Cursor(android.database.Cursor) Uri(android.net.Uri)

Example 19 with Uri

use of android.net.Uri in project photo-picker-plus-android by chute.

the class MediaDAO method getCameraThumbnails.

/**
   * Request a specific record in {@link android.provider.MediaStore.Images.Thumbnails}
   * database.
   *
   * @param context The application context.
   * @return Cursor object enabling read-write access to camera photos on the
   * device.
   */
public static Cursor getCameraThumbnails(final Context context) {
    final String[] projection = new String[] { MediaStore.Images.Thumbnails._ID, MediaStore.Images.Thumbnails.IMAGE_ID, MediaStore.Images.Thumbnails.DATA };
    final Uri images = MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI;
    final String query = MediaStore.Images.Thumbnails.DATA + " LIKE \"%DCIM%\"";
    return context.getContentResolver().query(images, projection, query, null, MediaStore.Images.Thumbnails._ID + " DESC");
}
Also used : Uri(android.net.Uri)

Example 20 with Uri

use of android.net.Uri in project PlayerHater by chrisrhoden.

the class MediaPlayerPool method release.

public synchronized void release() {
    for (SynchronousPlayer player : mIdlePlayers) {
        player.release();
    }
    mIdlePlayers.clear();
    for (Uri uri : mRequests) {
        mMediaPlayers.remove(uri).release();
    }
    mRequests.clear();
    for (SynchronousPlayer player : mMediaPlayers.values()) {
        player.release();
    }
    mMediaPlayers.clear();
}
Also used : Uri(android.net.Uri)

Aggregations

Uri (android.net.Uri)6747 Intent (android.content.Intent)1547 Cursor (android.database.Cursor)894 File (java.io.File)744 Test (org.junit.Test)632 ContentValues (android.content.ContentValues)614 IOException (java.io.IOException)571 ContentResolver (android.content.ContentResolver)449 ArrayList (java.util.ArrayList)446 Bundle (android.os.Bundle)289 Context (android.content.Context)276 Bitmap (android.graphics.Bitmap)273 InputStream (java.io.InputStream)257 View (android.view.View)251 RemoteException (android.os.RemoteException)228 PendingIntent (android.app.PendingIntent)209 SuppressLint (android.annotation.SuppressLint)180 FileNotFoundException (java.io.FileNotFoundException)177 TextView (android.widget.TextView)175 ActivityNotFoundException (android.content.ActivityNotFoundException)169