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 };
}
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);
}
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;
}
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");
}
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();
}
Aggregations