public void onSwapSourceClicked(Boolean onDevice) { if (onDevice) { mListView.setVisibility(View.GONE); mExpandableListView.setVisibility(View.VISIBLE); mMainActivity.findViewById(R.id.file_browsing_back).setVisibility(View.GONE); } else { mExpandableListView.setVisibility(View.GONE); mListView.setVisibility(View.VISIBLE); mMainActivity.findViewById(R.id.file_browsing_back).setVisibility(View.VISIBLE); } }
private void readFromMediaStoreAudio() { String columns[] = { MediaStore.Audio.AudioColumns._ID, MediaStore.Audio.AudioColumns.DATA, MediaStore.Audio.AudioColumns.MIME_TYPE }; Cursor cursor = mMainActivity .getContentResolver() .query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, columns, null, null, null); if (cursor.moveToFirst()) { mListDataHeader.add("MediaStore Audio"); ArrayList<MediaSource> children = new ArrayList<>(); do { String titleWithFiletype = cursor.getString(1).substring(cursor.getString(1).lastIndexOf("/") + 1); children.add( new MediaSource( titleWithFiletype, ContentUris.withAppendedId( MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, cursor.getLong(0)) .toString())); } while (cursor.moveToNext()); mListDataChild.put("MediaStore Audio", children); } cursor.close(); }
private void startMediaPlayer(String path, boolean useUri) { if (mMediaPlayer.getState() != MediaPlayer.State.IDLE) { mMainActivity.reset(); } try { if (LOGS_ENABLED) Log.d(TAG, "Setting datasource to: " + path); if (useUri) { mMediaPlayer.setDataSource(mContext, Uri.parse(path)); } else { mMediaPlayer.setDataSource(path); } mMediaPlayer.prepareAsync(); mDrawerLayout.closeDrawer(Gravity.START); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }