Play files from explorer (currently only if the matching song is in the MediaStore)
This commit is contained in:
parent
528d267ab3
commit
d8c7af3e09
2 changed files with 15 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ import android.content.Intent;
|
|||
import android.content.ServiceConnection;
|
||||
import android.media.audiofx.AudioEffect;
|
||||
import android.os.IBinder;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.widget.Toast;
|
||||
|
|
@ -305,6 +306,17 @@ public class MusicPlayerRemote {
|
|||
}
|
||||
|
||||
public static void playFile(String path) {
|
||||
//TODO
|
||||
if (musicService != null) {
|
||||
ArrayList<Song> songs = SongLoader.getSongs(SongLoader.makeSongCursor(
|
||||
musicService,
|
||||
MediaStore.Audio.AudioColumns.DATA + "=?",
|
||||
new String[]{path}
|
||||
));
|
||||
if (!songs.isEmpty()) {
|
||||
openQueue(songs, 0, true);
|
||||
} else {
|
||||
//TODO the file is not listed in the media store
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ import com.kabouzeid.gramophone.util.ViewUtil;
|
|||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -450,7 +451,7 @@ public class MainActivity extends AbsFabActivity
|
|||
MusicPlayerRemote.openQueue(SearchQueryHelper.getSongs(this, intent.getExtras()), 0, true);
|
||||
}
|
||||
if (uri != null && uri.toString().length() > 0) {
|
||||
MusicPlayerRemote.playFile(uri.toString());
|
||||
MusicPlayerRemote.playFile(new File(uri.getPath()).getAbsolutePath());
|
||||
handled = true;
|
||||
} else if (MediaStore.Audio.Playlists.CONTENT_TYPE.equals(mimeType)) {
|
||||
final int id = (int) parseIdFromIntent(intent, "playlistId", "playlist");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue