简体   繁体   English

仅从内部存储中检索下载的歌曲以在Android Studio中制作MP3播放器

[英]Retrieve ONLY dowloaded songs from internal storage to make MP3 player in Android Studio

This is my code. 这是我的代码。 As you can see I retrieve the songs from the internal storage but in the MP3 player shows all the other "default" music the device has. 如您所见,我从内部存储中检索了歌曲,但在MP3播放器中显示了设备具有的所有其他“默认”音乐。 Any help is appreciated. 任何帮助表示赞赏。

public void getSongList() {

    ContentResolver musicResolver = getContentResolver();


    Uri musicUri = MediaStore.Audio.Media.INTERNAL_CONTENT_URI;

    Cursor musicCursor = musicResolver.query(musicUri, null, null, null, null);

    if (musicCursor!=null && musicCursor.moveToFirst()){
        //get columns
        int titleColumn = musicCursor.getColumnIndex(MediaStore.Audio.Media.TITLE);
        int idColumn = musicCursor.getColumnIndex(MediaStore.Audio.Media._ID);
        int artistColumn = musicCursor.getColumnIndex(MediaStore.Audio.Media.ARTIST);
        //add songs to list

        do {
            long thisId = musicCursor.getLong(idColumn);
            String thisTitle = musicCursor.getString(titleColumn);
            String thisArtist = musicCursor.getString(artistColumn);
            songList.add(new Song(thisId, thisTitle, thisArtist));
        }
        while (musicCursor.moveToNext());
    }
}

The javadoc for that constant says: 该常量的javadoc说:

The content:// style URI for the internal storage. 内部存储的content://样式URI。

So, basically you lookup all internally stored content. 因此,基本上,您将查找所有内部存储的内容。

What makes you think that would be limited to downloaded content? 是什么使您认为仅限于下载的内容?

In other words: I think your whole idea will simply not work this way; 换句话说:我认为您的整个想法将无法完全按照这种方式工作; you simply ask "give me all media that is currently located in the internal storage". 您只需问“给我所有当前位于内部存储器中的媒体”。

将下载的歌曲存储在自己的目录中,并且仅从该特定目录加载?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM